From c6b73c1a6c2a9ea564befcc0b45bcb101f7931c3 Mon Sep 17 00:00:00 2001 From: libretroadmin <> Date: Tue, 11 Aug 2026 04:51:03 +0000 Subject: [PATCH] Remove the dead standalone-Fuse UI: 277 files, 39% off the binary With __LIBRETRO__ gone this is the only build, and the only build has no way into any of the standalone frontend machinery it was still compiling and shipping. The proof is one flag: display_ui_initialised is set to 1 exclusively by the fb, gtk, sdl, svga, wii, win32 and xlib display drivers, none of which are in the build, so it is permanently 0 here and widget_do() - the sole entry into the widget UI - returns on its first line. Every menu, dialog, and the widget error popup were compiled, linked, and unreachable. Likewise the movie recorder and the profiler could only ever be started from those menus, the scaler was selected once at startup and then never used (scalers16.o/scalers32.o linked with zero references to any symbol in them), and the seven other frontends' source trees were never compiled at all. Deleted: fuse/ui/{fb,gtk,sdl,svga,wii,win32,xlib,null,widget,scaler}, fuse/menu.c, fuse/movie.[ch], fuse/profile.[ch], fuse/screenshot.[ch], src/fuse/scalers16.c, src/fuse/scalers32.c, src/fuse/error.c (it compiled the widget error dialog under another name), the platform sound drivers in fuse/sound/ (blipbuffer stays - it is the mixer), the platform compat trees in fuse/compat/ (getopt.h stays - the generated settings code needs struct option on platforms without getopt.h), fuse/timer/sdl.c, fuse/z80/coretest.c, libspectrum/test/, and USE_WIDGET and the never-definable SOUND_FIFO branch with them. What real code pulled out of the deleted cluster survives, relocated: - The option_enumerate_*() string-to-enum mappings that sound.c, the disk peripherals, the +3 and uimedia.c consume move verbatim from the generated widget options.c into src/fuse/options_enumerate.c - they were the only lines of that file the core ever executed. - The rest of the ui_* surface is stubbed in src/compat/ui.c with the answer each caller already effectively received: file dialogs return NULL (cancel, handled quietly by tape/disk/mdr save), eject with unsaved changes returns DONTSAVE, ui_confirm_joystick makes the identical decision the widget version resolved to with joy_prompt off (this core's only configuration), rollback returns "no point chosen". - ui_error_specific() now only logs. It previously also called into the widget dialog, which drew nothing for the reason above. The movie and profile frame hooks are deleted from display.c, machine.c, rzx.c, sound.c, spectrum.c and the z80 opcode loop (z80_ops.c and z80_checks.h stay consistent - both derive from the same SETUP_CHECK list), fuse.c loses movie_init/movie_stop, the start_scaler block and the screenshot startup registration, and utils_read_screen() goes with screenshot.h since nothing called it. ui_widget_level, pinned at -1 forever, is gone along with its checks in input.c. The built core shrinks from 2952496 to 1796304 bytes, 39%. No functional change: the full verification matrix from issues #176 and #177 - Kempston Mouse hotplug and Fuller joystick wiring with and without fastload, option flips mid-autoload, all five border modes measured from the framebuffer, runtime border cycling, the keyboard overlay, machine boots including Timex and NTSC, and a savestate round trip - produces identical reset counts, port reads, framebuffer hashes and audio sample counts to the build before this change, and the corrupt-content error path hashes identically too, confirming the widget error dialog never contributed a pixel. ASan and UBSan clean across all of it. accessor.pl still regenerates snap_accessors.c byte-identically. --- build/Makefile.common | 26 +- fuse/compat/amiga/osname.c | 59 - fuse/compat/amiga/paths.c | 116 - fuse/compat/dirname.c | 99 - fuse/compat/getopt.c | 1280 ----- fuse/compat/getopt1.c | 198 - fuse/compat/linux/relative_paths.c | 43 - fuse/compat/morphos/osname.c | 34 - fuse/compat/unix/dir.c | 61 - fuse/compat/unix/file.c | 110 - fuse/compat/unix/osname.c | 48 - fuse/compat/unix/paths.c | 115 - fuse/compat/unix/relative_paths.c | 44 - fuse/compat/unix/socket.c | 134 - fuse/compat/unix/timer.c | 53 - fuse/compat/unix/tuntap.c | 59 - fuse/compat/wii/dir.c | 48 - fuse/compat/wii/osname.c | 37 - fuse/compat/wii/paths.c | 121 - fuse/compat/wii/timer.c | 55 - fuse/compat/win32/osname.c | 58 - fuse/compat/win32/paths.c | 121 - fuse/compat/win32/socket.c | 243 - fuse/compat/win32/timer.c | 40 - fuse/display.c | 15 +- fuse/fuse.c | 30 +- fuse/input.c | 23 - fuse/machine.c | 2 - fuse/menu.c | 1248 ----- fuse/movie.c | 490 -- fuse/movie.h | 36 - fuse/profile.c | 151 - fuse/profile.h | 35 - fuse/rzx.c | 3 - fuse/screenshot.c | 708 --- fuse/screenshot.h | 48 - fuse/sound.c | 5 - fuse/sound/alsasound.c | 390 -- fuse/sound/aosound.c | 233 - fuse/sound/coreaudiosound.c | 317 -- fuse/sound/dxsound.c | 230 - fuse/sound/hpsound.c | 163 - fuse/sound/nullsound.c | 44 - fuse/sound/osssound.c | 179 - fuse/sound/pulsesound.c | 144 - fuse/sound/sdlsound.c | 210 - fuse/sound/sfifo.c | 330 -- fuse/sound/sfifo.h | 98 - fuse/sound/sunsound.c | 203 - fuse/sound/wiisound.c | 111 - fuse/sound/win32sound.c | 229 - fuse/spectrum.c | 2 - fuse/timer/sdl.c | 40 - fuse/timer/timer.c | 28 - fuse/ui.c | 18 - fuse/ui/fb/Makefile.am | 49 - fuse/ui/fb/fbdisplay.c | 549 -- fuse/ui/fb/fbdisplay.h | 30 - fuse/ui/fb/fbjoystick.c | 29 - fuse/ui/fb/fbkeyboard.c | 147 - fuse/ui/fb/fbkeyboard.h | 36 - fuse/ui/fb/fbmouse.c | 264 - fuse/ui/fb/fbmouse.h | 31 - fuse/ui/fb/fbui.c | 114 - fuse/ui/gtk/Makefile.am | 101 - fuse/ui/gtk/binary.c | 447 -- fuse/ui/gtk/browse.c | 321 -- fuse/ui/gtk/confirm.c | 139 - fuse/ui/gtk/debugger.c | 1393 ----- fuse/ui/gtk/fileselector.c | 357 -- fuse/ui/gtk/gtkcompat.c | 56 - fuse/ui/gtk/gtkcompat.h | 198 - fuse/ui/gtk/gtkdisplay.c | 687 --- fuse/ui/gtk/gtkinternals.h | 171 - fuse/ui/gtk/gtkjoystick.c | 466 -- fuse/ui/gtk/gtkkeyboard.c | 106 - fuse/ui/gtk/gtkmouse.c | 270 - fuse/ui/gtk/gtkui.c | 1000 ---- fuse/ui/gtk/memory.c | 460 -- fuse/ui/gtk/memory_gtk2.c | 195 - fuse/ui/gtk/options-header.pl | 117 - fuse/ui/gtk/options.pl | 355 -- fuse/ui/gtk/picture.c | 146 - fuse/ui/gtk/pixmaps.c | 349 -- fuse/ui/gtk/pokefinder.c | 332 -- fuse/ui/gtk/pokemem.c | 599 --- fuse/ui/gtk/rollback.c | 155 - fuse/ui/gtk/roms.c | 161 - fuse/ui/gtk/statusbar.c | 223 - fuse/ui/gtk/stock.c | 187 - fuse/ui/null/Makefile.am | 45 - fuse/ui/null/null_ui.c | 259 - fuse/ui/null/options-header.pl | 59 - fuse/ui/null/options.pl | 59 - fuse/ui/scaler/Makefile.am | 51 - fuse/ui/scaler/scaler.c | 284 -- fuse/ui/scaler/scaler.h | 96 - fuse/ui/scaler/scaler_hq2x.c | 2134 -------- fuse/ui/scaler/scaler_hq3x.c | 3107 ------------ fuse/ui/scaler/scaler_hq4x.c | 4470 ----------------- fuse/ui/scaler/scaler_internals.h | 71 - fuse/ui/scaler/scalers.c | 2371 --------- fuse/ui/sdl/Makefile.am | 48 - fuse/ui/sdl/sdldisplay.c | 928 ---- fuse/ui/sdl/sdldisplay.h | 29 - fuse/ui/sdl/sdljoystick.c | 255 - fuse/ui/sdl/sdljoystick.h | 34 - fuse/ui/sdl/sdlkeyboard.c | 123 - fuse/ui/sdl/sdlkeyboard.h | 33 - fuse/ui/sdl/sdlui.c | 201 - fuse/ui/svga/Makefile.am | 47 - fuse/ui/svga/svgadisplay.c | 822 --- fuse/ui/svga/svgadisplay.h | 30 - fuse/ui/svga/svgajoystick.c | 159 - fuse/ui/svga/svgakeyboard.c | 99 - fuse/ui/svga/svgakeyboard.h | 30 - fuse/ui/svga/svgaui.c | 124 - fuse/ui/ui.h | 2 - fuse/ui/uijoystick.c | 285 -- fuse/ui/widget/Makefile.am | 84 - fuse/ui/widget/about.c | 92 - fuse/ui/widget/binary.c | 433 -- fuse/ui/widget/browse.c | 234 - fuse/ui/widget/debugger.c | 586 --- fuse/ui/widget/error.c | 182 - fuse/ui/widget/filesel.c | 1023 ---- fuse/ui/widget/fuse.font.sbf | 2232 -------- fuse/ui/widget/memory.c | 99 - fuse/ui/widget/menu.c | 788 --- fuse/ui/widget/menu_data.c | 934 ---- fuse/ui/widget/mkfusefont.pl | 71 - fuse/ui/widget/options-header.pl | 104 - fuse/ui/widget/options.c | 3004 ----------- fuse/ui/widget/options.pl | 666 --- fuse/ui/widget/options_internals.h | 64 - fuse/ui/widget/picture.c | 68 - fuse/ui/widget/pokefinder.c | 251 - fuse/ui/widget/pokemem.c | 522 -- fuse/ui/widget/query.c | 327 -- fuse/ui/widget/roms.c | 166 - fuse/ui/widget/select.c | 211 - fuse/ui/widget/text.c | 177 - fuse/ui/widget/widget.c | 848 ---- fuse/ui/widget/widget.h | 322 -- fuse/ui/widget/widget_internals.h | 292 -- fuse/ui/wii/Makefile.am | 50 - fuse/ui/wii/wiidisplay.c | 537 -- fuse/ui/wii/wiidisplay.h | 32 - fuse/ui/wii/wiijoystick.c | 197 - fuse/ui/wii/wiikeyboard.c | 215 - fuse/ui/wii/wiikeyboard.h | 36 - fuse/ui/wii/wiikeysyms.h | 111 - fuse/ui/wii/wiimouse.c | 205 - fuse/ui/wii/wiimouse.h | 33 - fuse/ui/wii/wiiui.c | 92 - fuse/ui/win32/Makefile.am | 144 - fuse/ui/win32/about.c | 113 - fuse/ui/win32/about.h | 28 - fuse/ui/win32/about.rc | 37 - fuse/ui/win32/binary.c | 348 -- fuse/ui/win32/binary.h | 31 - fuse/ui/win32/binary.rc | 41 - fuse/ui/win32/browse.c | 255 - fuse/ui/win32/browse.h | 26 - fuse/ui/win32/browse.rc | 41 - fuse/ui/win32/confirm.c | 90 - fuse/ui/win32/debugger.c | 1337 ----- fuse/ui/win32/debugger.h | 107 - fuse/ui/win32/debugger.rc | 132 - fuse/ui/win32/fileselector.c | 143 - fuse/ui/win32/hyperlinks.c | 170 - fuse/ui/win32/hyperlinks.h | 28 - fuse/ui/win32/icons/disk_active.bmp | Bin 1014 -> 0 bytes fuse/ui/win32/icons/disk_inactive.bmp | Bin 1014 -> 0 bytes fuse/ui/win32/icons/mdr_active.bmp | Bin 1014 -> 0 bytes fuse/ui/win32/icons/mdr_inactive.bmp | Bin 1014 -> 0 bytes fuse/ui/win32/icons/mouse_active.bmp | Bin 978 -> 0 bytes fuse/ui/win32/icons/mouse_inactive.bmp | Bin 978 -> 0 bytes fuse/ui/win32/icons/pause_active.bmp | Bin 1986 -> 0 bytes fuse/ui/win32/icons/pause_inactive.bmp | Bin 1986 -> 0 bytes fuse/ui/win32/icons/tape_active.bmp | Bin 1482 -> 0 bytes fuse/ui/win32/icons/tape_inactive.bmp | Bin 1482 -> 0 bytes fuse/ui/win32/icons/tape_marker.bmp | Bin 438 -> 0 bytes fuse/ui/win32/icons/tape_marker_mask.bmp | Bin 126 -> 0 bytes fuse/ui/win32/memorybrowser.c | 381 -- fuse/ui/win32/memorybrowser.h | 26 - fuse/ui/win32/memorybrowser.rc | 38 - fuse/ui/win32/options-header.pl | 116 - fuse/ui/win32/options-resource.pl | 100 - fuse/ui/win32/options.pl | 343 -- fuse/ui/win32/picture.c | 565 --- fuse/ui/win32/picture.h | 25 - fuse/ui/win32/picture.rc | 38 - fuse/ui/win32/pokefinder.c | 373 -- fuse/ui/win32/pokefinder.h | 32 - fuse/ui/win32/pokefinder.rc | 46 - fuse/ui/win32/pokemem.c | 654 --- fuse/ui/win32/pokemem.h | 34 - fuse/ui/win32/pokemem.rc | 49 - fuse/ui/win32/rollback.c | 133 - fuse/ui/win32/rollback.h | 25 - fuse/ui/win32/rollback.rc | 35 - fuse/ui/win32/roms.c | 269 - fuse/ui/win32/roms.h | 24 - fuse/ui/win32/roms.rc | 46 - fuse/ui/win32/select_template.h | 25 - fuse/ui/win32/select_template.rc | 35 - fuse/ui/win32/statusbar.c | 289 -- fuse/ui/win32/statusbar.rc | 33 - fuse/ui/win32/win32display.c | 525 -- fuse/ui/win32/win32internals.h | 147 - fuse/ui/win32/win32joystick.c | 474 -- fuse/ui/win32/win32joystick.h | 90 - fuse/ui/win32/win32joystick.rc | 224 - fuse/ui/win32/win32keyboard.c | 155 - fuse/ui/win32/win32mouse.c | 95 - fuse/ui/win32/win32ui.c | 1232 ----- fuse/ui/xlib/Makefile.am | 61 - fuse/ui/xlib/keysyms.c | 178 - fuse/ui/xlib/xdisplay.c | 1211 ----- fuse/ui/xlib/xdisplay.h | 42 - fuse/ui/xlib/xerror.c | 64 - fuse/ui/xlib/xjoystick.c | 37 - fuse/ui/xlib/xkeyboard.c | 74 - fuse/ui/xlib/xkeyboard.h | 30 - fuse/ui/xlib/xstatusbar.pl | 276 - fuse/ui/xlib/xui.c | 301 -- fuse/ui/xlib/xui.h | 36 - fuse/utils.c | 25 - fuse/utils.h | 1 - fuse/z80/coretest.c | 677 --- fuse/z80/z80_checks.h | 1 - fuse/z80/z80_ops.c | 8 - libspectrum/make-perl.c | 375 -- libspectrum/myglib/glock.c | 47 - libspectrum/test/Makefile.am | 96 - libspectrum/test/complete-tzx.pl | 283 -- libspectrum/test/edges.c | 66 - libspectrum/test/empty-drb.tzx | Bin 19 -> 0 bytes libspectrum/test/empty.csw | Bin 52 -> 0 bytes libspectrum/test/empty.szx | Bin 348 -> 0 bytes libspectrum/test/empty.z80 | Bin 877 -> 0 bytes libspectrum/test/invalid-archiveinfo.tzx | Bin 27 -> 0 bytes libspectrum/test/invalid-custominfo.tzx | Bin 31 -> 0 bytes libspectrum/test/invalid-gdb.tzx | Bin 40 -> 0 bytes libspectrum/test/invalid-hardwareinfo.tzx | 1 - .../test/invalid-warajevo-blockoffset.tap | Bin 12 -> 0 bytes libspectrum/test/invalid.gz | Bin 26 -> 0 bytes libspectrum/test/invalid.szx | Bin 17 -> 0 bytes libspectrum/test/invalid.tzx | 1 - libspectrum/test/jump.tzx | Bin 23 -> 0 bytes libspectrum/test/loop.tzx | Bin 14 -> 0 bytes libspectrum/test/loop2.tzx | Bin 19 -> 0 bytes libspectrum/test/loopend.tzx | 1 - libspectrum/test/no-pilot-gdb.tzx | Bin 47 -> 0 bytes libspectrum/test/plus3.z80 | Bin 878 -> 0 bytes libspectrum/test/random.szx | Bin 49402 -> 0 bytes libspectrum/test/raw-data-block.tzx | Bin 22 -> 0 bytes libspectrum/test/sp-2000.sna.gz | Bin 99 -> 0 bytes libspectrum/test/sp-ffff.sna.gz | Bin 99 -> 0 bytes libspectrum/test/standard-tap.tap | Bin 37 -> 0 bytes libspectrum/test/szx-chunks/AMXM.szx | Bin 23 -> 0 bytes .../test/szx-chunks/ATRP-uncompressed.szx.gz | Bin 89 -> 0 bytes libspectrum/test/szx-chunks/ATRP.szx | Bin 58 -> 0 bytes libspectrum/test/szx-chunks/AY.szx | Bin 34 -> 0 bytes .../test/szx-chunks/CFRP-uncompressed.szx.gz | Bin 90 -> 0 bytes libspectrum/test/szx-chunks/CFRP.szx | Bin 58 -> 0 bytes libspectrum/test/szx-chunks/COVX.szx | Bin 20 -> 0 bytes libspectrum/test/szx-chunks/DRUM.szx | Bin 17 -> 0 bytes libspectrum/test/szx-chunks/JOY.szx | Bin 22 -> 0 bytes libspectrum/test/szx-chunks/KEYB.szx | Bin 21 -> 0 bytes .../test/szx-chunks/RAMP-uncompressed.szx.gz | Bin 90 -> 0 bytes libspectrum/test/szx-chunks/RAMP.szx | Bin 58 -> 0 bytes libspectrum/test/szx-chunks/SCLD.szx | Bin 18 -> 0 bytes libspectrum/test/szx-chunks/SIDE.szx | Bin 16 -> 0 bytes libspectrum/test/szx-chunks/SPCR.szx | Bin 24 -> 0 bytes libspectrum/test/szx-chunks/Z80R.szx | Bin 53 -> 0 bytes libspectrum/test/szx-chunks/ZMMC.szx | Bin 16 -> 0 bytes libspectrum/test/szx-chunks/ZXAT.szx | Bin 24 -> 0 bytes libspectrum/test/szx-chunks/ZXCF.szx | Bin 20 -> 0 bytes libspectrum/test/szx-chunks/ZXPR.szx | Bin 18 -> 0 bytes libspectrum/test/szx.c | 997 ---- libspectrum/test/test.c | 1073 ---- libspectrum/test/test.h | 81 - libspectrum/test/test_edges.c | 264 - libspectrum/test/trailing-pause-block.tzx | Bin 19 -> 0 bytes libspectrum/test/turbo-zeropilot.tzx | Bin 29 -> 0 bytes libspectrum/test/writeprotected.mdr | Bin 5432 -> 0 bytes libspectrum/test/zero-tail.pzx | Bin 49 -> 0 bytes src/compat/ui.c | 128 +- src/config_fuse.h | 3 - src/externs.h | 1 - src/fuse/error.c | 7 - src/fuse/options_enumerate.c | 231 + src/fuse/scalers16.c | 2 - src/fuse/scalers32.c | 2 - 296 files changed, 364 insertions(+), 66812 deletions(-) delete mode 100644 fuse/compat/amiga/osname.c delete mode 100644 fuse/compat/amiga/paths.c delete mode 100644 fuse/compat/dirname.c delete mode 100644 fuse/compat/getopt.c delete mode 100644 fuse/compat/getopt1.c delete mode 100644 fuse/compat/linux/relative_paths.c delete mode 100644 fuse/compat/morphos/osname.c delete mode 100644 fuse/compat/unix/dir.c delete mode 100644 fuse/compat/unix/file.c delete mode 100644 fuse/compat/unix/osname.c delete mode 100644 fuse/compat/unix/paths.c delete mode 100644 fuse/compat/unix/relative_paths.c delete mode 100644 fuse/compat/unix/socket.c delete mode 100644 fuse/compat/unix/timer.c delete mode 100644 fuse/compat/unix/tuntap.c delete mode 100644 fuse/compat/wii/dir.c delete mode 100644 fuse/compat/wii/osname.c delete mode 100644 fuse/compat/wii/paths.c delete mode 100644 fuse/compat/wii/timer.c delete mode 100644 fuse/compat/win32/osname.c delete mode 100644 fuse/compat/win32/paths.c delete mode 100644 fuse/compat/win32/socket.c delete mode 100644 fuse/compat/win32/timer.c delete mode 100644 fuse/menu.c delete mode 100644 fuse/movie.c delete mode 100644 fuse/movie.h delete mode 100644 fuse/profile.c delete mode 100644 fuse/profile.h delete mode 100644 fuse/screenshot.c delete mode 100644 fuse/screenshot.h delete mode 100644 fuse/sound/alsasound.c delete mode 100644 fuse/sound/aosound.c delete mode 100644 fuse/sound/coreaudiosound.c delete mode 100644 fuse/sound/dxsound.c delete mode 100644 fuse/sound/hpsound.c delete mode 100644 fuse/sound/nullsound.c delete mode 100644 fuse/sound/osssound.c delete mode 100644 fuse/sound/pulsesound.c delete mode 100644 fuse/sound/sdlsound.c delete mode 100644 fuse/sound/sfifo.c delete mode 100644 fuse/sound/sfifo.h delete mode 100644 fuse/sound/sunsound.c delete mode 100644 fuse/sound/wiisound.c delete mode 100644 fuse/sound/win32sound.c delete mode 100644 fuse/timer/sdl.c delete mode 100644 fuse/ui/fb/Makefile.am delete mode 100644 fuse/ui/fb/fbdisplay.c delete mode 100644 fuse/ui/fb/fbdisplay.h delete mode 100644 fuse/ui/fb/fbjoystick.c delete mode 100644 fuse/ui/fb/fbkeyboard.c delete mode 100644 fuse/ui/fb/fbkeyboard.h delete mode 100644 fuse/ui/fb/fbmouse.c delete mode 100644 fuse/ui/fb/fbmouse.h delete mode 100644 fuse/ui/fb/fbui.c delete mode 100644 fuse/ui/gtk/Makefile.am delete mode 100644 fuse/ui/gtk/binary.c delete mode 100644 fuse/ui/gtk/browse.c delete mode 100644 fuse/ui/gtk/confirm.c delete mode 100644 fuse/ui/gtk/debugger.c delete mode 100644 fuse/ui/gtk/fileselector.c delete mode 100644 fuse/ui/gtk/gtkcompat.c delete mode 100644 fuse/ui/gtk/gtkcompat.h delete mode 100644 fuse/ui/gtk/gtkdisplay.c delete mode 100644 fuse/ui/gtk/gtkinternals.h delete mode 100644 fuse/ui/gtk/gtkjoystick.c delete mode 100644 fuse/ui/gtk/gtkkeyboard.c delete mode 100644 fuse/ui/gtk/gtkmouse.c delete mode 100644 fuse/ui/gtk/gtkui.c delete mode 100644 fuse/ui/gtk/memory.c delete mode 100644 fuse/ui/gtk/memory_gtk2.c delete mode 100755 fuse/ui/gtk/options-header.pl delete mode 100755 fuse/ui/gtk/options.pl delete mode 100644 fuse/ui/gtk/picture.c delete mode 100644 fuse/ui/gtk/pixmaps.c delete mode 100644 fuse/ui/gtk/pokefinder.c delete mode 100644 fuse/ui/gtk/pokemem.c delete mode 100644 fuse/ui/gtk/rollback.c delete mode 100644 fuse/ui/gtk/roms.c delete mode 100644 fuse/ui/gtk/statusbar.c delete mode 100644 fuse/ui/gtk/stock.c delete mode 100644 fuse/ui/null/Makefile.am delete mode 100644 fuse/ui/null/null_ui.c delete mode 100644 fuse/ui/null/options-header.pl delete mode 100755 fuse/ui/null/options.pl delete mode 100644 fuse/ui/scaler/Makefile.am delete mode 100644 fuse/ui/scaler/scaler.c delete mode 100644 fuse/ui/scaler/scaler.h delete mode 100644 fuse/ui/scaler/scaler_hq2x.c delete mode 100644 fuse/ui/scaler/scaler_hq3x.c delete mode 100644 fuse/ui/scaler/scaler_hq4x.c delete mode 100644 fuse/ui/scaler/scaler_internals.h delete mode 100644 fuse/ui/scaler/scalers.c delete mode 100644 fuse/ui/sdl/Makefile.am delete mode 100644 fuse/ui/sdl/sdldisplay.c delete mode 100644 fuse/ui/sdl/sdldisplay.h delete mode 100644 fuse/ui/sdl/sdljoystick.c delete mode 100644 fuse/ui/sdl/sdljoystick.h delete mode 100644 fuse/ui/sdl/sdlkeyboard.c delete mode 100644 fuse/ui/sdl/sdlkeyboard.h delete mode 100644 fuse/ui/sdl/sdlui.c delete mode 100644 fuse/ui/svga/Makefile.am delete mode 100644 fuse/ui/svga/svgadisplay.c delete mode 100644 fuse/ui/svga/svgadisplay.h delete mode 100644 fuse/ui/svga/svgajoystick.c delete mode 100644 fuse/ui/svga/svgakeyboard.c delete mode 100644 fuse/ui/svga/svgakeyboard.h delete mode 100644 fuse/ui/svga/svgaui.c delete mode 100644 fuse/ui/uijoystick.c delete mode 100644 fuse/ui/widget/Makefile.am delete mode 100644 fuse/ui/widget/about.c delete mode 100644 fuse/ui/widget/binary.c delete mode 100644 fuse/ui/widget/browse.c delete mode 100644 fuse/ui/widget/debugger.c delete mode 100644 fuse/ui/widget/error.c delete mode 100644 fuse/ui/widget/filesel.c delete mode 100644 fuse/ui/widget/fuse.font.sbf delete mode 100644 fuse/ui/widget/memory.c delete mode 100644 fuse/ui/widget/menu.c delete mode 100644 fuse/ui/widget/menu_data.c delete mode 100755 fuse/ui/widget/mkfusefont.pl delete mode 100755 fuse/ui/widget/options-header.pl delete mode 100644 fuse/ui/widget/options.c delete mode 100755 fuse/ui/widget/options.pl delete mode 100644 fuse/ui/widget/options_internals.h delete mode 100644 fuse/ui/widget/picture.c delete mode 100644 fuse/ui/widget/pokefinder.c delete mode 100644 fuse/ui/widget/pokemem.c delete mode 100644 fuse/ui/widget/query.c delete mode 100644 fuse/ui/widget/roms.c delete mode 100644 fuse/ui/widget/select.c delete mode 100644 fuse/ui/widget/text.c delete mode 100644 fuse/ui/widget/widget.c delete mode 100644 fuse/ui/widget/widget.h delete mode 100644 fuse/ui/widget/widget_internals.h delete mode 100644 fuse/ui/wii/Makefile.am delete mode 100644 fuse/ui/wii/wiidisplay.c delete mode 100644 fuse/ui/wii/wiidisplay.h delete mode 100644 fuse/ui/wii/wiijoystick.c delete mode 100644 fuse/ui/wii/wiikeyboard.c delete mode 100644 fuse/ui/wii/wiikeyboard.h delete mode 100644 fuse/ui/wii/wiikeysyms.h delete mode 100644 fuse/ui/wii/wiimouse.c delete mode 100644 fuse/ui/wii/wiimouse.h delete mode 100644 fuse/ui/wii/wiiui.c delete mode 100644 fuse/ui/win32/Makefile.am delete mode 100644 fuse/ui/win32/about.c delete mode 100644 fuse/ui/win32/about.h delete mode 100644 fuse/ui/win32/about.rc delete mode 100644 fuse/ui/win32/binary.c delete mode 100644 fuse/ui/win32/binary.h delete mode 100644 fuse/ui/win32/binary.rc delete mode 100644 fuse/ui/win32/browse.c delete mode 100644 fuse/ui/win32/browse.h delete mode 100644 fuse/ui/win32/browse.rc delete mode 100644 fuse/ui/win32/confirm.c delete mode 100644 fuse/ui/win32/debugger.c delete mode 100644 fuse/ui/win32/debugger.h delete mode 100644 fuse/ui/win32/debugger.rc delete mode 100644 fuse/ui/win32/fileselector.c delete mode 100644 fuse/ui/win32/hyperlinks.c delete mode 100644 fuse/ui/win32/hyperlinks.h delete mode 100644 fuse/ui/win32/icons/disk_active.bmp delete mode 100644 fuse/ui/win32/icons/disk_inactive.bmp delete mode 100644 fuse/ui/win32/icons/mdr_active.bmp delete mode 100644 fuse/ui/win32/icons/mdr_inactive.bmp delete mode 100644 fuse/ui/win32/icons/mouse_active.bmp delete mode 100644 fuse/ui/win32/icons/mouse_inactive.bmp delete mode 100644 fuse/ui/win32/icons/pause_active.bmp delete mode 100644 fuse/ui/win32/icons/pause_inactive.bmp delete mode 100644 fuse/ui/win32/icons/tape_active.bmp delete mode 100644 fuse/ui/win32/icons/tape_inactive.bmp delete mode 100644 fuse/ui/win32/icons/tape_marker.bmp delete mode 100644 fuse/ui/win32/icons/tape_marker_mask.bmp delete mode 100644 fuse/ui/win32/memorybrowser.c delete mode 100644 fuse/ui/win32/memorybrowser.h delete mode 100644 fuse/ui/win32/memorybrowser.rc delete mode 100755 fuse/ui/win32/options-header.pl delete mode 100755 fuse/ui/win32/options-resource.pl delete mode 100755 fuse/ui/win32/options.pl delete mode 100755 fuse/ui/win32/picture.c delete mode 100755 fuse/ui/win32/picture.h delete mode 100755 fuse/ui/win32/picture.rc delete mode 100644 fuse/ui/win32/pokefinder.c delete mode 100644 fuse/ui/win32/pokefinder.h delete mode 100644 fuse/ui/win32/pokefinder.rc delete mode 100644 fuse/ui/win32/pokemem.c delete mode 100644 fuse/ui/win32/pokemem.h delete mode 100644 fuse/ui/win32/pokemem.rc delete mode 100644 fuse/ui/win32/rollback.c delete mode 100644 fuse/ui/win32/rollback.h delete mode 100644 fuse/ui/win32/rollback.rc delete mode 100644 fuse/ui/win32/roms.c delete mode 100644 fuse/ui/win32/roms.h delete mode 100644 fuse/ui/win32/roms.rc delete mode 100644 fuse/ui/win32/select_template.h delete mode 100644 fuse/ui/win32/select_template.rc delete mode 100644 fuse/ui/win32/statusbar.c delete mode 100644 fuse/ui/win32/statusbar.rc delete mode 100644 fuse/ui/win32/win32display.c delete mode 100755 fuse/ui/win32/win32internals.h delete mode 100644 fuse/ui/win32/win32joystick.c delete mode 100644 fuse/ui/win32/win32joystick.h delete mode 100644 fuse/ui/win32/win32joystick.rc delete mode 100644 fuse/ui/win32/win32keyboard.c delete mode 100644 fuse/ui/win32/win32mouse.c delete mode 100755 fuse/ui/win32/win32ui.c delete mode 100644 fuse/ui/xlib/Makefile.am delete mode 100644 fuse/ui/xlib/keysyms.c delete mode 100644 fuse/ui/xlib/xdisplay.c delete mode 100644 fuse/ui/xlib/xdisplay.h delete mode 100644 fuse/ui/xlib/xerror.c delete mode 100644 fuse/ui/xlib/xjoystick.c delete mode 100644 fuse/ui/xlib/xkeyboard.c delete mode 100644 fuse/ui/xlib/xkeyboard.h delete mode 100644 fuse/ui/xlib/xstatusbar.pl delete mode 100644 fuse/ui/xlib/xui.c delete mode 100644 fuse/ui/xlib/xui.h delete mode 100644 fuse/z80/coretest.c delete mode 100644 libspectrum/make-perl.c delete mode 100644 libspectrum/myglib/glock.c delete mode 100644 libspectrum/test/Makefile.am delete mode 100755 libspectrum/test/complete-tzx.pl delete mode 100644 libspectrum/test/edges.c delete mode 100644 libspectrum/test/empty-drb.tzx delete mode 100644 libspectrum/test/empty.csw delete mode 100644 libspectrum/test/empty.szx delete mode 100644 libspectrum/test/empty.z80 delete mode 100644 libspectrum/test/invalid-archiveinfo.tzx delete mode 100644 libspectrum/test/invalid-custominfo.tzx delete mode 100644 libspectrum/test/invalid-gdb.tzx delete mode 100644 libspectrum/test/invalid-hardwareinfo.tzx delete mode 100644 libspectrum/test/invalid-warajevo-blockoffset.tap delete mode 100644 libspectrum/test/invalid.gz delete mode 100644 libspectrum/test/invalid.szx delete mode 100644 libspectrum/test/invalid.tzx delete mode 100644 libspectrum/test/jump.tzx delete mode 100644 libspectrum/test/loop.tzx delete mode 100644 libspectrum/test/loop2.tzx delete mode 100644 libspectrum/test/loopend.tzx delete mode 100644 libspectrum/test/no-pilot-gdb.tzx delete mode 100644 libspectrum/test/plus3.z80 delete mode 100644 libspectrum/test/random.szx delete mode 100644 libspectrum/test/raw-data-block.tzx delete mode 100644 libspectrum/test/sp-2000.sna.gz delete mode 100644 libspectrum/test/sp-ffff.sna.gz delete mode 100644 libspectrum/test/standard-tap.tap delete mode 100644 libspectrum/test/szx-chunks/AMXM.szx delete mode 100644 libspectrum/test/szx-chunks/ATRP-uncompressed.szx.gz delete mode 100644 libspectrum/test/szx-chunks/ATRP.szx delete mode 100644 libspectrum/test/szx-chunks/AY.szx delete mode 100644 libspectrum/test/szx-chunks/CFRP-uncompressed.szx.gz delete mode 100644 libspectrum/test/szx-chunks/CFRP.szx delete mode 100644 libspectrum/test/szx-chunks/COVX.szx delete mode 100644 libspectrum/test/szx-chunks/DRUM.szx delete mode 100644 libspectrum/test/szx-chunks/JOY.szx delete mode 100644 libspectrum/test/szx-chunks/KEYB.szx delete mode 100644 libspectrum/test/szx-chunks/RAMP-uncompressed.szx.gz delete mode 100644 libspectrum/test/szx-chunks/RAMP.szx delete mode 100644 libspectrum/test/szx-chunks/SCLD.szx delete mode 100644 libspectrum/test/szx-chunks/SIDE.szx delete mode 100644 libspectrum/test/szx-chunks/SPCR.szx delete mode 100644 libspectrum/test/szx-chunks/Z80R.szx delete mode 100644 libspectrum/test/szx-chunks/ZMMC.szx delete mode 100644 libspectrum/test/szx-chunks/ZXAT.szx delete mode 100644 libspectrum/test/szx-chunks/ZXCF.szx delete mode 100644 libspectrum/test/szx-chunks/ZXPR.szx delete mode 100644 libspectrum/test/szx.c delete mode 100644 libspectrum/test/test.c delete mode 100644 libspectrum/test/test.h delete mode 100644 libspectrum/test/test_edges.c delete mode 100644 libspectrum/test/trailing-pause-block.tzx delete mode 100644 libspectrum/test/turbo-zeropilot.tzx delete mode 100644 libspectrum/test/writeprotected.mdr delete mode 100644 libspectrum/test/zero-tail.pzx delete mode 100644 src/fuse/error.c create mode 100644 src/fuse/options_enumerate.c delete mode 100644 src/fuse/scalers16.c delete mode 100644 src/fuse/scalers32.c diff --git a/build/Makefile.common b/build/Makefile.common index 5a79915..b3cbb92 100644 --- a/build/Makefile.common +++ b/build/Makefile.common @@ -13,8 +13,6 @@ SOURCES_C += $(CORE_DIR)/src/coreopt.c SOURCES_C += $(CORE_DIR)/src/missing.c SOURCES_C += $(CORE_DIR)/src/version.c -SOURCES_C += $(CORE_DIR)/src/fuse/scalers16.c -SOURCES_C += $(CORE_DIR)/src/fuse/scalers32.c SOURCES_C += $(CORE_DIR)/src/compat/dir.c SOURCES_C += $(CORE_DIR)/src/compat/display.c @@ -120,26 +118,7 @@ SOURCES_C += $(CORE_DIR)/fuse/sound/blipbuffer.c SOURCES_C += $(CORE_DIR)/fuse/timer/timer.c SOURCES_C += $(CORE_DIR)/fuse/timer/native.c -SOURCES_C += $(CORE_DIR)/fuse/ui/widget/browse.c -SOURCES_C += $(CORE_DIR)/fuse/ui/widget/debugger.c -SOURCES_C += $(CORE_DIR)/src/fuse/error.c -SOURCES_C += $(CORE_DIR)/fuse/ui/widget/filesel.c -SOURCES_C += $(CORE_DIR)/fuse/ui/widget/memory.c -SOURCES_C += $(CORE_DIR)/fuse/ui/widget/menu.c -SOURCES_C += $(CORE_DIR)/fuse/ui/widget/menu_data.c -SOURCES_C += $(CORE_DIR)/fuse/ui/widget/options.c -SOURCES_C += $(CORE_DIR)/fuse/ui/widget/picture.c -SOURCES_C += $(CORE_DIR)/fuse/ui/widget/pokemem.c -SOURCES_C += $(CORE_DIR)/fuse/ui/widget/pokefinder.c -SOURCES_C += $(CORE_DIR)/fuse/ui/widget/query.c -SOURCES_C += $(CORE_DIR)/fuse/ui/widget/roms.c -SOURCES_C += $(CORE_DIR)/fuse/ui/widget/select.c -SOURCES_C += $(CORE_DIR)/fuse/ui/widget/text.c -SOURCES_C += $(CORE_DIR)/fuse/ui/widget/widget.c -SOURCES_C += $(CORE_DIR)/fuse/ui/widget/about.c -SOURCES_C += $(CORE_DIR)/fuse/ui/widget/binary.c -SOURCES_C += $(CORE_DIR)/fuse/ui/scaler/scaler.c SOURCES_C += $(CORE_DIR)/fuse/unittests/unittests.c @@ -156,16 +135,13 @@ SOURCES_C += $(CORE_DIR)/fuse/loader.c SOURCES_C += $(CORE_DIR)/fuse/machine.c SOURCES_C += $(CORE_DIR)/fuse/memory_pages.c SOURCES_C += $(CORE_DIR)/fuse/mempool.c -SOURCES_C += $(CORE_DIR)/fuse/menu.c -SOURCES_C += $(CORE_DIR)/fuse/movie.c SOURCES_C += $(CORE_DIR)/fuse/module.c SOURCES_C += $(CORE_DIR)/fuse/periph.c -SOURCES_C += $(CORE_DIR)/fuse/profile.c SOURCES_C += $(CORE_DIR)/fuse/psg.c SOURCES_C += $(CORE_DIR)/fuse/rectangle.c SOURCES_C += $(CORE_DIR)/fuse/rzx.c -SOURCES_C += $(CORE_DIR)/fuse/screenshot.c SOURCES_C += $(CORE_DIR)/src/fuse/settings.c +SOURCES_C += $(CORE_DIR)/src/fuse/options_enumerate.c SOURCES_C += $(CORE_DIR)/fuse/slt.c SOURCES_C += $(CORE_DIR)/src/fuse/snapshot.c SOURCES_C += $(CORE_DIR)/fuse/sound.c diff --git a/fuse/compat/amiga/osname.c b/fuse/compat/amiga/osname.c deleted file mode 100644 index 61df98e..0000000 --- a/fuse/compat/amiga/osname.c +++ /dev/null @@ -1,59 +0,0 @@ -/* osname.c: Get a representation of the OS we're running on - Copyright (c) 1999-2007 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include -#include -#include - -#include "ui/ui.h" - -struct Library *ExpansionBase; -struct ExpansionIFace *IExpansion; - -int compat_osname( char *buffer, size_t length ) -{ - STRPTR machine; - - if( ExpansionBase = IExec->OpenLibrary( "expansion.library", 52 ) ) { - if( IExpansion = ( struct ExpansionIFace * ) IExec->GetInterface( ExpansionBase,"main",1,NULL ) ) { - - IExpansion->GetMachineInfoTags( GMIT_MachineString, &machine, - TAG_DONE ); - - snprintf( buffer, length, "%s %s %s", "AmigaOS", machine, "4.0" ); - - IExec->DropInterface( ( struct Interface * )IExpansion ); - } - IExec->CloseLibrary( ExpansionBase ); - } - else - { - return 1; - } - - return 0; -} diff --git a/fuse/compat/amiga/paths.c b/fuse/compat/amiga/paths.c deleted file mode 100644 index b981723..0000000 --- a/fuse/compat/amiga/paths.c +++ /dev/null @@ -1,116 +0,0 @@ -/* paths.c: Path-related compatibility routines - Copyright (c) 1999-2012 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#ifdef HAVE_LIBGEN_H -#include -#endif /* #ifdef HAVE_LIBGEN_H */ -#include -#include - -#include "compat.h" -#include "fuse.h" -#include "ui/ui.h" - -const char* -compat_get_temp_path( void ) -{ - return "T:"; -} - -const char* -compat_get_config_path( void ) -{ - return "PROGDIR:settings"; -} - -int -compat_is_absolute_path( const char *path ) -{ - return strchr(path,':'); -} - -int -compat_get_next_path( path_context *ctx ) -{ - char buffer[ PATH_MAX ]; - const char *path_segment, *path2; - - switch( (ctx->state)++ ) { - - /* First look relative to the current directory */ - case 0: - strncpy( ctx->path, "PROGDIR:", PATH_MAX ); - return 1; - - /* Then relative to the Fuse executable */ - case 1: - - switch( ctx->type ) { - case UTILS_AUXILIARY_LIB: strncpy( ctx->path, "PROGDIR:lib/", PATH_MAX); return 1; - case UTILS_AUXILIARY_ROM: strncpy( ctx->path, "PROGDIR:roms/", PATH_MAX); return 1; - case UTILS_AUXILIARY_WIDGET: strncpy( ctx->path, "PROGDIR:ui/widget/", PATH_MAX); return 1; - case UTILS_AUXILIARY_GTK: strncpy( ctx->path, "PROGDIR:ui/gtk/", PATH_MAX); return 1; - default: - ui_error( UI_ERROR_ERROR, "unknown auxiliary file type %d", ctx->type ); - return 0; - } - - if( compat_is_absolute_path( fuse_progname ) ) { - strncpy( buffer, fuse_progname, PATH_MAX ); - buffer[ PATH_MAX - 1 ] = '\0'; - } else { - size_t len; - len = PATH_MAX - strlen( fuse_progname ) - strlen( FUSE_DIR_SEP_STR ); - if( !getcwd( buffer, len ) ) { - ui_error( UI_ERROR_ERROR, "error getting current working directory: %s", - strerror( errno ) ); - return 0; - } - strcat( buffer, FUSE_DIR_SEP_STR ); - strcat( buffer, fuse_progname ); - } - - path2 = dirname( buffer ); - snprintf( ctx->path, PATH_MAX, "%s" FUSE_DIR_SEP_STR "%s", path2, - path_segment ); - return 1; - - /* Then where we may have installed the data files */ - case 2: - -#ifndef ROMSDIR - path2 = FUSEDATADIR; -#else /* #ifndef ROMSDIR */ - path2 = ctx->type == UTILS_AUXILIARY_ROM ? ROMSDIR : FUSEDATADIR; -#endif /* #ifndef ROMSDIR */ - strncpy( ctx->path, path2, PATH_MAX ); buffer[ PATH_MAX - 1 ] = '\0'; - return 1; - - case 3: return 0; - } - ui_error( UI_ERROR_ERROR, "unknown path_context state %d", ctx->state ); - fuse_abort(); -} diff --git a/fuse/compat/dirname.c b/fuse/compat/dirname.c deleted file mode 100644 index 570d718..0000000 --- a/fuse/compat/dirname.c +++ /dev/null @@ -1,99 +0,0 @@ -/* dirname - return directory part of PATH. - Copyright (C) 1996, 2000, 2001, 2002 Free Software Foundation, Inc. - This file was part of the GNU C Library, version 2.3.2. - Contributed by Ulrich Drepper , 1996. - Very slightly modified for use in Fuse by Philip Kendall, 2004. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include - -#include "fuse.h" - -static char * -__memrchr (char *s, int c, size_t n) -{ - for (s += n - 1; n; n--, s--) - if (*s == c) - return s; - - return NULL; -} - -char * -dirname (char *path) -{ - static const char dot[] = "."; - char *last_slash; - - /* Find last '/'. */ - last_slash = path != NULL ? strrchr (path, FUSE_DIR_SEP_CHR) : NULL; - - if (last_slash != NULL && last_slash != path && last_slash[1] == '\0') - { - /* Determine whether all remaining characters are slashes. */ - char *runp; - - for (runp = last_slash; runp != path; --runp) - if (runp[-1] != FUSE_DIR_SEP_CHR) - break; - - /* The '/' is the last character, we have to look further. */ - if (runp != path) - last_slash = __memrchr (path, FUSE_DIR_SEP_CHR, runp - path); - } - - if (last_slash != NULL) - { - /* Determine whether all remaining characters are slashes. */ - char *runp; - - for (runp = last_slash; runp != path; --runp) - if (runp[-1] != FUSE_DIR_SEP_CHR) - break; - - /* Terminate the path. */ - if (runp == path) - { - /* The last slash is the first character in the string. We have to - return "/". As a special case we have to return "//" if there - are exactly two slashes at the beginning of the string. See - XBD 4.10 Path Name Resolution for more information. */ - if (last_slash == path + 1) - ++last_slash; - else - last_slash = path + 1; - } - else - last_slash = runp; - - last_slash[0] = '\0'; - } - else - /* This assignment is ill-designed but the XPG specs require to - return a string containing "." in any case no directory part is - found and so a static and constant string is required. */ - path = (char *) dot; - - return path; -} diff --git a/fuse/compat/getopt.c b/fuse/compat/getopt.c deleted file mode 100644 index 36fbea2..0000000 --- a/fuse/compat/getopt.c +++ /dev/null @@ -1,1280 +0,0 @@ -/* Getopt for GNU. - NOTE: getopt is now part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to drepper@gnu.org - before changing it! - Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002 - Free Software Foundation, Inc. - This file is part of the GNU C Library. - - Modifications (c) 2003 Philip Kendall - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA. */ - - -/* This tells Alpha OSF/1 not to define a getopt prototype in . - Ditto for AIX 3.2 and . */ -#ifndef _NO_PROTO -# define _NO_PROTO -#endif - -#ifdef HAVE_CONFIG_H -# include -#endif - -#if !defined __STDC__ || !__STDC__ -/* This is a separate conditional since some stdc systems - reject `defined (const)'. */ -# ifndef const -# define const -# endif -#endif - -#include - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#define GETOPT_INTERFACE_VERSION 2 -#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 -# include -# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -# define ELIDE_CODE -# endif -#endif - -#ifndef ELIDE_CODE - - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -/* Don't include stdlib.h for non-GNU C libraries because some of them - contain conflicting prototypes for getopt. */ -# include -# include -#endif /* GNU C library. */ - -#ifdef VMS -# include -# if HAVE_STRING_H - 0 -# include -# endif -#endif - -#ifndef _ -/* This is for other GNU distributions with internationalized messages. */ -# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC -# include -# ifndef _ -# define _(msgid) gettext (msgid) -# endif -# else -# define _(msgid) (msgid) -# endif -# if defined _LIBC && defined USE_IN_LIBIO -# include -# endif -#endif - -#ifndef attribute_hidden -# define attribute_hidden -#endif - -/* This version of `getopt' appears to the caller like standard Unix `getopt' - but it behaves differently for the user, since it allows the user - to intersperse the options with the other arguments. - - As `getopt' works, it permutes the elements of ARGV so that, - when it is done, all the options precede everything else. Thus - all application programs are extended to handle flexible argument order. - - Setting the environment variable POSIXLY_CORRECT disables permutation. - Then the behavior is completely standard. - - GNU application programs can use a third alternative mode in which - they can distinguish the relative order of options and other arguments. */ - -#include "getopt.h" - -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -char *optarg; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns -1, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -/* 1003.2 says this must be 1 before any call. */ -int optind = 1; - -/* Formerly, initialization of getopt depended on optind==0, which - causes problems with re-calling getopt as programs generally don't - know that. */ - -int __getopt_initialized attribute_hidden; - -/* The next char to be scanned in the option-element - in which the last option character we returned was found. - This allows us to pick up the scan where we left off. - - If this is zero, or a null string, it means resume the scan - by advancing to the next ARGV-element. */ - -static char *nextchar; - -/* Callers store zero here to inhibit the error message - for unrecognized options. */ - -int opterr = 1; - -/* Set to an option character which was unrecognized. - This must be initialized on some systems to avoid linking in the - system's own getopt implementation. */ - -int optopt = '?'; - -/* Describe how to deal with options that follow non-option ARGV-elements. - - If the caller did not specify anything, - the default is REQUIRE_ORDER if the environment variable - POSIXLY_CORRECT is defined, PERMUTE otherwise. - - REQUIRE_ORDER means don't recognize them as options; - stop option processing when the first non-option is seen. - This is what Unix does. - This mode of operation is selected by either setting the environment - variable POSIXLY_CORRECT, or using `+' as the first character - of the list of option characters. - - PERMUTE is the default. We permute the contents of ARGV as we scan, - so that eventually all the non-options are at the end. This allows options - to be given in any order, even with programs that were not written to - expect this. - - RETURN_IN_ORDER is an option available to programs that were written - to expect options and other ARGV-elements in any order and that care about - the ordering of the two. We describe each non-option ARGV-element - as if it were the argument of an option with character code 1. - Using `-' as the first character of the list of option characters - selects this mode of operation. - - The special argument `--' forces an end of option-scanning regardless - of the value of `ordering'. In the case of RETURN_IN_ORDER, only - `--' can cause `getopt' to return -1 with `optind' != ARGC. */ - -static enum -{ - REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER -} ordering; - -/* Value of POSIXLY_CORRECT environment variable. */ -static char *posixly_correct; - -#ifdef __GNU_LIBRARY__ -/* We want to avoid inclusion of string.h with non-GNU libraries - because there are many ways it can cause trouble. - On some systems, it contains special magic macros that don't work - in GCC. */ -# include -# define my_index strchr -#else - -# if HAVE_STRING_H -# include -# else -# include -# endif - -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -#ifndef getenv -extern char *getenv (); -#endif - -static char * -my_index (str, chr) - const char *str; - int chr; -{ - while (*str) - { - if (*str == chr) - return (char *) str; - str++; - } - return 0; -} - -/* If using GCC, we can safely declare strlen this way. - If not using GCC, it is ok not to declare it. */ -#ifdef __GNUC__ -/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. - That was relevant to code that was here before. */ -# if (!defined __STDC__ || !__STDC__) && !defined strlen -/* gcc with -traditional declares the built-in strlen to return int, - and has done so at least since version 2.4.5. -- rms. */ -extern int strlen (const char *); -# endif /* not __STDC__ */ -#endif /* __GNUC__ */ - -#endif /* not __GNU_LIBRARY__ */ - -/* Handle permutation of arguments. */ - -/* Describe the part of ARGV that contains non-options that have - been skipped. `first_nonopt' is the index in ARGV of the first of them; - `last_nonopt' is the index after the last of them. */ - -static int first_nonopt; -static int last_nonopt; - -#ifdef _LIBC -/* Stored original parameters. - XXX This is no good solution. We should rather copy the args so - that we can compare them later. But we must not use malloc(3). */ -extern int __libc_argc; -extern char **__libc_argv; - -/* Bash 2.0 gives us an environment variable containing flags - indicating ARGV elements that should not be considered arguments. */ - -# ifdef USE_NONOPTION_FLAGS -/* Defined in getopt_init.c */ -extern char *__getopt_nonoption_flags; - -static int nonoption_flags_max_len; -static int nonoption_flags_len; -# endif - -# ifdef USE_NONOPTION_FLAGS -# define SWAP_FLAGS(ch1, ch2) \ - if (nonoption_flags_len > 0) \ - { \ - char __tmp = __getopt_nonoption_flags[ch1]; \ - __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ - __getopt_nonoption_flags[ch2] = __tmp; \ - } -# else -# define SWAP_FLAGS(ch1, ch2) -# endif -#else /* !_LIBC */ -# define SWAP_FLAGS(ch1, ch2) -#endif /* _LIBC */ - -/* Exchange two adjacent subsequences of ARGV. - One subsequence is elements [first_nonopt,last_nonopt) - which contains all the non-options that have been skipped so far. - The other is elements [last_nonopt,optind), which contains all - the options processed since those non-options were skipped. - - `first_nonopt' and `last_nonopt' are relocated so that they describe - the new indices of the non-options in ARGV after they are moved. */ - -#if defined __STDC__ && __STDC__ -static void exchange (char **); -#endif - -static void -exchange (argv) - char **argv; -{ - int bottom = first_nonopt; - int middle = last_nonopt; - int top = optind; - char *tem; - - /* Exchange the shorter segment with the far end of the longer segment. - That puts the shorter segment into the right place. - It leaves the longer segment in the right place overall, - but it consists of two parts that need to be swapped next. */ - -#if defined _LIBC && defined USE_NONOPTION_FLAGS - /* First make sure the handling of the `__getopt_nonoption_flags' - string can work normally. Our top argument must be in the range - of the string. */ - if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) - { - /* We must extend the array. The user plays games with us and - presents new arguments. */ - char *new_str = malloc (top + 1); - if (new_str == NULL) - nonoption_flags_len = nonoption_flags_max_len = 0; - else - { - memset (__mempcpy (new_str, __getopt_nonoption_flags, - nonoption_flags_max_len), - '\0', top + 1 - nonoption_flags_max_len); - nonoption_flags_max_len = top + 1; - __getopt_nonoption_flags = new_str; - } - } -#endif - - while (top > middle && middle > bottom) - { - if (top - middle > middle - bottom) - { - /* Bottom segment is the short one. */ - int len = middle - bottom; - register int i; - - /* Swap it with the top part of the top segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[top - (middle - bottom) + i]; - argv[top - (middle - bottom) + i] = tem; - SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); - } - /* Exclude the moved bottom segment from further swapping. */ - top -= len; - } - else - { - /* Top segment is the short one. */ - int len = top - middle; - register int i; - - /* Swap it with the bottom part of the bottom segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[middle + i]; - argv[middle + i] = tem; - SWAP_FLAGS (bottom + i, middle + i); - } - /* Exclude the moved top segment from further swapping. */ - bottom += len; - } - } - - /* Update records for the slots the non-options now occupy. */ - - first_nonopt += (optind - last_nonopt); - last_nonopt = optind; -} - -/* Initialize the internal data when the first call is made. */ - -#if defined __STDC__ && __STDC__ -static const char *_getopt_initialize (int, char *const *, const char *); -#endif -static const char * -_getopt_initialize (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; -{ - /* Start processing options with ARGV-element 1 (since ARGV-element 0 - is the program name); the sequence of previously skipped - non-option ARGV-elements is empty. */ - - first_nonopt = last_nonopt = optind; - - nextchar = NULL; - - posixly_correct = getenv ("POSIXLY_CORRECT"); - - /* Determine how to handle the ordering of options and nonoptions. */ - - if (optstring[0] == '-') - { - ordering = RETURN_IN_ORDER; - ++optstring; - } - else if (optstring[0] == '+') - { - ordering = REQUIRE_ORDER; - ++optstring; - } - else if (posixly_correct != NULL) - ordering = REQUIRE_ORDER; - else - ordering = PERMUTE; - -#if defined _LIBC && defined USE_NONOPTION_FLAGS - if (posixly_correct == NULL - && argc == __libc_argc && argv == __libc_argv) - { - if (nonoption_flags_max_len == 0) - { - if (__getopt_nonoption_flags == NULL - || __getopt_nonoption_flags[0] == '\0') - nonoption_flags_max_len = -1; - else - { - const char *orig_str = __getopt_nonoption_flags; - int len = nonoption_flags_max_len = strlen (orig_str); - if (nonoption_flags_max_len < argc) - nonoption_flags_max_len = argc; - __getopt_nonoption_flags = - (char *) malloc (nonoption_flags_max_len); - if (__getopt_nonoption_flags == NULL) - nonoption_flags_max_len = -1; - else - memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), - '\0', nonoption_flags_max_len - len); - } - } - nonoption_flags_len = nonoption_flags_max_len; - } - else - nonoption_flags_len = 0; -#endif - - return optstring; -} - -/* Scan elements of ARGV (whose length is ARGC) for option characters - given in OPTSTRING. - - If an element of ARGV starts with '-', and is not exactly "-" or "--", - then it is an option element. The characters of this element - (aside from the initial '-') are option characters. If `getopt' - is called repeatedly, it returns successively each of the option characters - from each of the option elements. - - If `getopt' finds another option character, it returns that character, - updating `optind' and `nextchar' so that the next call to `getopt' can - resume the scan with the following option character or ARGV-element. - - If there are no more option characters, `getopt' returns -1. - Then `optind' is the index in ARGV of the first ARGV-element - that is not an option. (The ARGV-elements have been permuted - so that those that are not options now come last.) - - OPTSTRING is a string containing the legitimate option characters. - If an option character is seen that is not listed in OPTSTRING, - return '?' after printing an error message. If you set `opterr' to - zero, the error message is suppressed but we still return '?'. - - If a char in OPTSTRING is followed by a colon, that means it wants an arg, - so the following text in the same ARGV-element, or the text of the following - ARGV-element, is returned in `optarg'. Two colons mean an option that - wants an optional arg; if there is text in the current ARGV-element, - it is returned in `optarg', otherwise `optarg' is set to zero. - - If OPTSTRING starts with `-' or `+', it requests different methods of - handling the non-option ARGV-elements. - See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. - - Long-named options begin with `--' instead of `-'. - Their names may be abbreviated as long as the abbreviation is unique - or is an exact match for some defined option. If they have an - argument, it follows the option name in the same ARGV-element, separated - from the option name by a `=', or else the in next ARGV-element. - When `getopt' finds a long-named option, it returns 0 if that option's - `flag' field is nonzero, the value of the option's `val' field - if the `flag' field is zero. - - The elements of ARGV aren't really const, because we permute them. - But we pretend they're const in the prototype to be compatible - with other systems. - - LONGOPTS is a vector of `struct option' terminated by an - element containing a name which is zero. - - LONGIND returns the index in LONGOPT of the long-named option found. - It is only valid when a long-named option has been found by the most - recent call. - - If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. */ - -int -_getopt_internal (argc, argv, optstring, longopts, longind, long_only) - int argc; - char *const *argv; - const char *optstring; - const struct option *longopts; - int *longind; - int long_only; -{ - int print_errors = opterr; - if (optstring[0] == ':') - print_errors = 0; - - if (argc < 1) - return -1; - - optarg = NULL; - - if (optind == 0 || !__getopt_initialized) - { - if (optind == 0) - optind = 1; /* Don't scan ARGV[0], the program name. */ - optstring = _getopt_initialize (argc, argv, optstring); - __getopt_initialized = 1; - } - - /* Test whether ARGV[optind] points to a non-option argument. - Either it does not have option syntax, or there is an environment flag - from the shell indicating it is not an option. The later information - is only used when the used in the GNU libc. */ -#if defined _LIBC && defined USE_NONOPTION_FLAGS -# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ - || (optind < nonoption_flags_len \ - && __getopt_nonoption_flags[optind] == '1')) -#else -# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') -#endif - - if (nextchar == NULL || *nextchar == '\0') - { - /* Advance to the next ARGV-element. */ - - /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been - moved back by the user (who may also have changed the arguments). */ - if (last_nonopt > optind) - last_nonopt = optind; - if (first_nonopt > optind) - first_nonopt = optind; - - if (ordering == PERMUTE) - { - /* If we have just processed some options following some non-options, - exchange them so that the options come first. */ - - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (last_nonopt != optind) - first_nonopt = optind; - - /* Skip any additional non-options - and extend the range of non-options previously skipped. */ - - while (optind < argc && NONOPTION_P) - optind++; - last_nonopt = optind; - } - - /* The special ARGV-element `--' means premature end of options. - Skip it like a null option, - then exchange with previous non-options as if it were an option, - then skip everything else like a non-option. */ - - if (optind != argc && !strcmp (argv[optind], "--")) - { - optind++; - - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (first_nonopt == last_nonopt) - first_nonopt = optind; - last_nonopt = argc; - - optind = argc; - } - - /* If we have done all the ARGV-elements, stop the scan - and back over any non-options that we skipped and permuted. */ - - if (optind == argc) - { - /* Set the next-arg-index to point at the non-options - that we previously skipped, so the caller will digest them. */ - if (first_nonopt != last_nonopt) - optind = first_nonopt; - return -1; - } - - /* If we have come to a non-option and did not permute it, - either stop the scan or describe it to the caller and pass it by. */ - - if (NONOPTION_P) - { - if (ordering == REQUIRE_ORDER) - return -1; - optarg = argv[optind++]; - return 1; - } - - /* We have found another option-ARGV-element. - Skip the initial punctuation. */ - - nextchar = (argv[optind] + 1 - + (longopts != NULL && argv[optind][1] == '-')); - } - - /* Decode the current option-ARGV-element. */ - - /* Check whether the ARGV-element is a long option. - - If long_only and the ARGV-element has the form "-f", where f is - a valid short option, don't consider it an abbreviated form of - a long option that starts with f. Otherwise there would be no - way to give the -f short option. - - On the other hand, if there's a long option "fubar" and - the ARGV-element is "-fu", do consider that an abbreviation of - the long option, just like "--fu", and not "-f" with arg "u". - - This distinction seems to be the most useful approach. */ - - if (longopts != NULL - && (argv[optind][1] == '-' - || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) - { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = -1; - int option_index; - - for (nameend = nextchar; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; - - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, nextchar, nameend - nextchar)) - { - if ((unsigned int) (nameend - nextchar) - == (unsigned int) strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else if (long_only - || pfound->has_arg != p->has_arg - || pfound->flag != p->flag - || pfound->val != p->val) - /* Second or later nonexact match found. */ - ambig = 1; - } - - if (ambig && !exact) - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, _("%s: option `%s' is ambiguous\n"), - argv[0], argv[optind]) >= 0) - { - - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); - - free (buf); - } -#else - fprintf (stderr, _("%s: option `%s' is ambiguous\n"), - argv[0], argv[optind]); -#endif - } - nextchar += strlen (nextchar); - optind++; - optopt = 0; - return '?'; - } - - if (pfound != NULL) - { - option_index = indfound; - optind++; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = nameend + 1; - else - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - int n; -#endif - - if (argv[optind - 1][1] == '-') - { - /* --option */ -#if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("\ -%s: option `--%s' doesn't allow an argument\n"), - argv[0], pfound->name); -#else - fprintf (stderr, _("\ -%s: option `--%s' doesn't allow an argument\n"), - argv[0], pfound->name); -#endif - } - else - { - /* +option or -option */ -#if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("\ -%s: option `%c%s' doesn't allow an argument\n"), - argv[0], argv[optind - 1][0], - pfound->name); -#else - fprintf (stderr, _("\ -%s: option `%c%s' doesn't allow an argument\n"), - argv[0], argv[optind - 1][0], pfound->name); -#endif - } - -#if defined _LIBC && defined USE_IN_LIBIO - if (n >= 0) - { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); - - free (buf); - } -#endif - } - - nextchar += strlen (nextchar); - - optopt = pfound->val; - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (optind < argc) - optarg = argv[optind++]; - else - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, _("\ -%s: option `%s' requires an argument\n"), - argv[0], argv[optind - 1]) >= 0) - { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); - - free (buf); - } -#else - fprintf (stderr, - _("%s: option `%s' requires an argument\n"), - argv[0], argv[optind - 1]); -#endif - } - nextchar += strlen (nextchar); - optopt = pfound->val; - return optstring[0] == ':' ? ':' : '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - - /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[optind][1] == '-' - || my_index (optstring, *nextchar) == NULL) - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - int n; -#endif - - if (argv[optind][1] == '-') - { - /* --option */ -#if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("%s: unrecognized option `--%s'\n"), - argv[0], nextchar); -#else - fprintf (stderr, _("%s: unrecognized option `--%s'\n"), - argv[0], nextchar); -#endif - } - else - { - /* +option or -option */ -#if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"), - argv[0], argv[optind][0], nextchar); -#else - fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), - argv[0], argv[optind][0], nextchar); -#endif - } - -#if defined _LIBC && defined USE_IN_LIBIO - if (n >= 0) - { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); - - free (buf); - } -#endif - } - nextchar = (char *) ""; - optind++; - optopt = 0; - return '?'; - } - } - - /* Look at and handle the next short option-character. */ - - { - char c = *nextchar++; - char *temp = my_index (optstring, c); - - /* Increment `optind' when we start to process its last character. */ - if (*nextchar == '\0') - ++optind; - - if (temp == NULL || c == ':') - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - int n; -#endif - - if (posixly_correct) - { - /* 1003.2 specifies the format of this message. */ -#if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("%s: illegal option -- %c\n"), - argv[0], c); -#else - fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); -#endif - } - else - { -#if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("%s: invalid option -- %c\n"), - argv[0], c); -#else - fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); -#endif - } - -#if defined _LIBC && defined USE_IN_LIBIO - if (n >= 0) - { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); - - free (buf); - } -#endif - } - optopt = c; - return '?'; - } - /* Convenience. Treat POSIX -W foo same as long option --foo */ - if (temp[0] == 'W' && temp[1] == ';') - { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = 0; - int option_index; - - /* This is an option that requires an argument. */ - if (*nextchar != '\0') - { - optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - optind++; - } - else if (optind == argc) - { - if (print_errors) - { - /* 1003.2 specifies the format of this message. */ -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, - _("%s: option requires an argument -- %c\n"), - argv[0], c) >= 0) - { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); - - free (buf); - } -#else - fprintf (stderr, _("%s: option requires an argument -- %c\n"), - argv[0], c); -#endif - } - optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - return c; - } - else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - optarg = argv[optind++]; - - /* optarg is now the argument, see if it's in the - table of longopts. */ - - for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; - - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, nextchar, nameend - nextchar)) - { - if ((unsigned int) (nameend - nextchar) == strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second or later nonexact match found. */ - ambig = 1; - } - if (ambig && !exact) - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"), - argv[0], argv[optind]) >= 0) - { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); - - free (buf); - } -#else - fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), - argv[0], argv[optind]); -#endif - } - nextchar += strlen (nextchar); - optind++; - return '?'; - } - if (pfound != NULL) - { - option_index = indfound; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = nameend + 1; - else - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, _("\ -%s: option `-W %s' doesn't allow an argument\n"), - argv[0], pfound->name) >= 0) - { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); - - free (buf); - } -#else - fprintf (stderr, _("\ -%s: option `-W %s' doesn't allow an argument\n"), - argv[0], pfound->name); -#endif - } - - nextchar += strlen (nextchar); - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (optind < argc) - optarg = argv[optind++]; - else - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, _("\ -%s: option `%s' requires an argument\n"), - argv[0], argv[optind - 1]) >= 0) - { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); - - free (buf); - } -#else - fprintf (stderr, - _("%s: option `%s' requires an argument\n"), - argv[0], argv[optind - 1]); -#endif - } - nextchar += strlen (nextchar); - return optstring[0] == ':' ? ':' : '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - nextchar = NULL; - return 'W'; /* Let the application handle it. */ - } - if (temp[1] == ':') - { - if (temp[2] == ':') - { - /* This is an option that accepts an argument optionally. */ - if (*nextchar != '\0') - { - optarg = nextchar; - optind++; - } - else - optarg = NULL; - nextchar = NULL; - } - else - { - /* This is an option that requires an argument. */ - if (*nextchar != '\0') - { - optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - optind++; - } - else if (optind == argc) - { - if (print_errors) - { - /* 1003.2 specifies the format of this message. */ -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, _("\ -%s: option requires an argument -- %c\n"), - argv[0], c) >= 0) - { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); - - free (buf); - } -#else - fprintf (stderr, - _("%s: option requires an argument -- %c\n"), - argv[0], c); -#endif - } - optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - } - else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - optarg = argv[optind++]; - nextchar = NULL; - } - } - return c; - } -} - -int -getopt (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; -{ - return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0); -} - -#endif /* Not ELIDE_CODE. */ - -#ifdef TEST - -/* Compile with -DTEST to make an executable for use in testing - the above definition of `getopt'. */ - -int -main (argc, argv) - int argc; - char **argv; -{ - int c; - int digit_optind = 0; - - while (1) - { - int this_option_optind = optind ? optind : 1; - - c = getopt (argc, argv, "abc:d:0123456789"); - if (c == -1) - break; - - switch (c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value `%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } - - if (optind < argc) - { - printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); - printf ("\n"); - } - - exit (0); -} - -#endif /* TEST */ diff --git a/fuse/compat/getopt1.c b/fuse/compat/getopt1.c deleted file mode 100644 index 40b3cb2..0000000 --- a/fuse/compat/getopt1.c +++ /dev/null @@ -1,198 +0,0 @@ -/* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 - Free Software Foundation, Inc. - This file is part of the GNU C Library. - - Modifications copyright (c) 2003 Philip Kendall - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA. */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef _LIBC -# include -#else -# include "getopt.h" -#endif - -#if !defined __STDC__ || !__STDC__ -/* This is a separate conditional since some stdc systems - reject `defined (const)'. */ -#ifndef const -#define const -#endif -#endif - -#include - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#define GETOPT_INTERFACE_VERSION 2 -#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 -#include -#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -#define ELIDE_CODE -#endif -#endif - -#ifndef ELIDE_CODE - - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#include -#endif - -#ifndef NULL -#define NULL 0 -#endif - -int -getopt_long (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 0); -} - -/* Like getopt_long, but '-' as well as '--' can indicate a long option. - If an option that starts with '-' (not '--') doesn't match a long option, - but does match a short option, it is parsed as a short option - instead. */ - -int -getopt_long_only (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 1); -} - -# ifdef _LIBC -libc_hidden_def (getopt_long) -libc_hidden_def (getopt_long_only) -# endif - -#endif /* Not ELIDE_CODE. */ - -#ifdef TEST - -#include - -int -main (argc, argv) - int argc; - char **argv; -{ - int c; - int digit_optind = 0; - - while (1) - { - int this_option_optind = optind ? optind : 1; - int option_index = 0; - static struct option long_options[] = - { - {"add", 1, 0, 0}, - {"append", 0, 0, 0}, - {"delete", 1, 0, 0}, - {"verbose", 0, 0, 0}, - {"create", 0, 0, 0}, - {"file", 1, 0, 0}, - {0, 0, 0, 0} - }; - - c = getopt_long (argc, argv, "abc:d:0123456789", - long_options, &option_index); - if (c == -1) - break; - - switch (c) - { - case 0: - printf ("option %s", long_options[option_index].name); - if (optarg) - printf (" with arg %s", optarg); - printf ("\n"); - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value `%s'\n", optarg); - break; - - case 'd': - printf ("option d with value `%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } - - if (optind < argc) - { - printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); - printf ("\n"); - } - - exit (0); -} - -#endif /* TEST */ diff --git a/fuse/compat/linux/relative_paths.c b/fuse/compat/linux/relative_paths.c deleted file mode 100644 index bbdbc04..0000000 --- a/fuse/compat/linux/relative_paths.c +++ /dev/null @@ -1,43 +0,0 @@ -/* relative_paths.c: Path-related compatibility routines - Copyright (c) 1999-2012 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include - -#include "fuse.h" -#include "ui/ui.h" - -void -get_relative_directory( char *buffer, size_t bufsize ) -{ - ssize_t retval = readlink( "/proc/self/exe", buffer, bufsize - 1 ); - if( retval < 0 ) { - ui_error( UI_ERROR_ERROR, "error getting current working directory: %s", - strerror( -errno ) ); - fuse_abort(); - } - buffer[ retval ] = '\0'; -} diff --git a/fuse/compat/morphos/osname.c b/fuse/compat/morphos/osname.c deleted file mode 100644 index 1cd0f1c..0000000 --- a/fuse/compat/morphos/osname.c +++ /dev/null @@ -1,34 +0,0 @@ -/* osname.c: Get a representation of the OS we're running on - Copyright (c) 1999-2007 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -int compat_osname( char *buffer, size_t length ) -{ - snprintf( buffer, length, "%s %s %s", "MorphOS", "Pegasos", "1.4.4" ); - - return 0; -} diff --git a/fuse/compat/unix/dir.c b/fuse/compat/unix/dir.c deleted file mode 100644 index 7064313..0000000 --- a/fuse/compat/unix/dir.c +++ /dev/null @@ -1,61 +0,0 @@ -/* dir.c: Directory-related compatibility routines - Copyright (c) 2009 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include "compat.h" - -compat_dir -compat_opendir( const char *path ) -{ - return opendir( path ); -} - -compat_dir_result_t -compat_readdir( compat_dir directory, char *name, size_t length ) -{ - compat_dir_result_t r; - struct dirent *dirent; - - errno = 0; - dirent = readdir( directory ); - - if( dirent ) { - r = COMPAT_DIR_RESULT_OK; - strncpy( name, dirent->d_name, length ); - name[ length - 1 ] = 0; - } else { - r = ( errno == 0 ? COMPAT_DIR_RESULT_END : COMPAT_DIR_RESULT_ERROR ); - } - - return r; -} - -int -compat_closedir( compat_dir directory ) -{ - return closedir( directory ); -} diff --git a/fuse/compat/unix/file.c b/fuse/compat/unix/file.c deleted file mode 100644 index f7e9ff2..0000000 --- a/fuse/compat/unix/file.c +++ /dev/null @@ -1,110 +0,0 @@ -/* file.c: File-related compatibility routines - Copyright (c) 2008 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include -#include -#include -#include - -#include "compat.h" -#include "utils.h" -#include "ui/ui.h" - -const compat_fd COMPAT_FILE_OPEN_FAILED = NULL; - -compat_fd -compat_file_open( const char *path, int write ) -{ - struct stat statbuf; - - if( !write ) { - if( stat( path, &statbuf ) ) { - return NULL; - } - - /* Check file type */ - if( !S_ISREG( statbuf.st_mode ) ) { - errno = EINVAL; - return NULL; - } - } - - return fopen( path, write ? "wb" : "rb" ); -} - -off_t -compat_file_get_length( compat_fd fd ) -{ - struct stat file_info; - - if( fstat( fileno( fd ), &file_info ) ) { - ui_error( UI_ERROR_ERROR, "couldn't stat file: %s", strerror( errno ) ); - return -1; - } - - return file_info.st_size; -} - -int -compat_file_read( compat_fd fd, utils_file *file ) -{ - size_t bytes = fread( file->buffer, 1, file->length, fd ); - if( bytes != file->length ) { - ui_error( UI_ERROR_ERROR, - "error reading file: expected %lu bytes, but read only %lu", - (unsigned long)file->length, (unsigned long)bytes ); - return 1; - } - - return 0; -} - -int -compat_file_write( compat_fd fd, const unsigned char *buffer, size_t length ) -{ - size_t bytes = fwrite( buffer, 1, length, fd ); - if( bytes != length ) { - ui_error( UI_ERROR_ERROR, - "error writing file: expected %lu bytes, but wrote only %lu", - (unsigned long)length, (unsigned long)bytes ); - return 1; - } - - return 0; -} - -int -compat_file_close( compat_fd fd ) -{ - return fclose( fd ); -} - -int -compat_file_exists( const char *path ) -{ - return ( access( path, R_OK ) != -1 ); -} diff --git a/fuse/compat/unix/osname.c b/fuse/compat/unix/osname.c deleted file mode 100644 index eb5c65f..0000000 --- a/fuse/compat/unix/osname.c +++ /dev/null @@ -1,48 +0,0 @@ -/* osname.c: Get a representation of the OS we're running on - Copyright (c) 1999-2007 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include -#include - -#include "ui/ui.h" - -int compat_osname( char *buffer, size_t length ) -{ - struct utsname osname; - int error; - - error = uname( &osname ); - if( error < 0 ) { - ui_error( UI_ERROR_ERROR, "error getting system information: %s", - strerror( errno ) ); - return 1; - } - - snprintf( buffer, length, "%s %s %s", osname.sysname, osname.machine, - osname.release ); - return 0; -} diff --git a/fuse/compat/unix/paths.c b/fuse/compat/unix/paths.c deleted file mode 100644 index a3c89a1..0000000 --- a/fuse/compat/unix/paths.c +++ /dev/null @@ -1,115 +0,0 @@ -/* paths.c: Path-related compatibility routines - Copyright (c) 1999-2012 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#ifdef HAVE_LIBGEN_H -#include -#endif /* #ifdef HAVE_LIBGEN_H */ -#include -#include - -#include "compat.h" -#include "fuse.h" -#include "ui/ui.h" - -void get_relative_directory( char *buffer, size_t bufsize ); - -const char* -compat_get_temp_path( void ) -{ - const char *dir; - - /* Use TMPDIR if specified, if not /tmp */ - dir = getenv( "TMPDIR" ); if( dir ) return dir; - return "/tmp"; -} - -const char* -compat_get_config_path( void ) -{ - const char *dir; - dir = getenv( "HOME" ); if( dir ) return dir; - return "."; -} - -int -compat_is_absolute_path( const char *path ) -{ - return path[0] == '/'; -} - -int -compat_get_next_path( path_context *ctx ) -{ - char buffer[ PATH_MAX ]; - const char *path_segment, *path2; - - switch( (ctx->state)++ ) { - - /* First look relative to the current directory */ - case 0: - strncpy( ctx->path, ".", PATH_MAX ); - return 1; - - /* Then relative to the Fuse executable */ - case 1: - - switch( ctx->type ) { - case UTILS_AUXILIARY_LIB: path_segment = "lib"; break; - case UTILS_AUXILIARY_ROM: path_segment = "roms"; break; - case UTILS_AUXILIARY_WIDGET: path_segment = "ui/widget"; break; - case UTILS_AUXILIARY_GTK: path_segment = "ui/gtk"; break; - default: - ui_error( UI_ERROR_ERROR, "unknown auxiliary file type %d", ctx->type ); - return 0; - } - - if( compat_is_absolute_path( fuse_progname ) ) { - strncpy( buffer, fuse_progname, PATH_MAX ); - buffer[ PATH_MAX - 1 ] = '\0'; - } else { - get_relative_directory( buffer, PATH_MAX ); - } - - path2 = dirname( buffer ); - snprintf( ctx->path, PATH_MAX, "%s" FUSE_DIR_SEP_STR "%s", path2, - path_segment ); - return 1; - - /* Then where we may have installed the data files */ - case 2: - -#ifndef ROMSDIR - path2 = FUSEDATADIR; -#else /* #ifndef ROMSDIR */ - path2 = ctx->type == UTILS_AUXILIARY_ROM ? ROMSDIR : FUSEDATADIR; -#endif /* #ifndef ROMSDIR */ - strncpy( ctx->path, path2, PATH_MAX ); buffer[ PATH_MAX - 1 ] = '\0'; - return 1; - - case 3: return 0; - } - ui_error( UI_ERROR_ERROR, "unknown path_context state %d", ctx->state ); - fuse_abort(); -} diff --git a/fuse/compat/unix/relative_paths.c b/fuse/compat/unix/relative_paths.c deleted file mode 100644 index b6263f8..0000000 --- a/fuse/compat/unix/relative_paths.c +++ /dev/null @@ -1,44 +0,0 @@ -/* relative_paths.c: Path-related compatibility routines - Copyright (c) 1999-2012 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include - -#include "fuse.h" -#include "ui/ui.h" - -void -get_relative_directory( char *buffer, size_t bufsize ) -{ - size_t len = bufsize - strlen( fuse_progname ) - strlen( FUSE_DIR_SEP_STR ); - if( !getcwd( buffer, len ) ) { - ui_error( UI_ERROR_ERROR, "error getting current working directory: %s", - strerror( -errno ) ); - fuse_abort(); - } - strcat( buffer, FUSE_DIR_SEP_STR ); - strcat( buffer, fuse_progname ); -} diff --git a/fuse/compat/unix/socket.c b/fuse/compat/unix/socket.c deleted file mode 100644 index 9f00af7..0000000 --- a/fuse/compat/unix/socket.c +++ /dev/null @@ -1,134 +0,0 @@ -/* socket.c: Socket-related compatibility routines - Copyright (c) 2011-2015 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include -#include - -#include "compat.h" -#include "fuse.h" -#include "ui/ui.h" - -const compat_socket_t compat_socket_invalid = -1; -const int compat_socket_EBADF = EBADF; - -struct compat_socket_selfpipe_t { - int read_fd; - int write_fd; -}; - -void -compat_socket_networking_init( void ) -{ - /* No action necessary */ -} - -void -compat_socket_networking_end( void ) -{ - /* No action necessary */ -} - -int -compat_socket_blocking_mode( compat_socket_t fd, int blocking ) -{ - int flags = fcntl( fd, F_GETFL, 0 ); - if( flags == -1 ) - return -1; - flags = blocking ? ( flags | O_NONBLOCK ) : ( flags & ~O_NONBLOCK ); - return ( fcntl( fd, F_SETFL, flags ) != 0 ); -} - -int -compat_socket_close( compat_socket_t fd ) -{ - return close( fd ); -} - -int compat_socket_get_error( void ) -{ - return errno; -} - -const char * -compat_socket_get_strerror( void ) -{ - return strerror( errno ); -} - -compat_socket_selfpipe_t* compat_socket_selfpipe_alloc( void ) -{ - int error; - int pipefd[2]; - - compat_socket_selfpipe_t *self = - libspectrum_new( compat_socket_selfpipe_t, 1 ); - - error = pipe( pipefd ); - if( error ) { - ui_error( UI_ERROR_ERROR, "%s: %d: error %d creating pipe", __FILE__, __LINE__, error ); - fuse_abort(); - } - - self->read_fd = pipefd[0]; - self->write_fd = pipefd[1]; - - return self; -} - -void compat_socket_selfpipe_free( compat_socket_selfpipe_t *self ) -{ - close( self->read_fd ); - close( self->write_fd ); - libspectrum_free( self ); -} - -compat_socket_t compat_socket_selfpipe_get_read_fd( compat_socket_selfpipe_t *self ) -{ - return self->read_fd; -} - -void compat_socket_selfpipe_wake( compat_socket_selfpipe_t *self ) -{ - const char dummy = 0; - ssize_t unused = write( self->write_fd, &dummy, 1 ); - (void) unused; -} - -void compat_socket_selfpipe_discard_data( compat_socket_selfpipe_t *self ) -{ - char bitbucket; - ssize_t bytes_read; - - do { - bytes_read = read( self->read_fd, &bitbucket, 1 ); - if( bytes_read == -1 && errno != EINTR ) { - ui_error( UI_ERROR_ERROR, - "%s: %d: unexpected error %d (%s) reading from pipe", __FILE__, - __LINE__, errno, strerror(errno) ); - } - } while( bytes_read < 0 ); -} diff --git a/fuse/compat/unix/timer.c b/fuse/compat/unix/timer.c deleted file mode 100644 index 95a0d6f..0000000 --- a/fuse/compat/unix/timer.c +++ /dev/null @@ -1,53 +0,0 @@ -/* timer.c: UNIX speed routines for Fuse - Copyright (c) 1999-2008 Philip Kendall, Marek Januszewski, Fredrick Meunier - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include -#include - -#include "compat.h" -#include "ui/ui.h" - -double -compat_timer_get_time( void ) -{ - struct timeval tv; - int error; - - error = gettimeofday( &tv, NULL ); - if( error ) { - ui_error( UI_ERROR_ERROR, "%s: error getting time: %s", __func__, strerror( errno ) ); - return -1; - } - - return tv.tv_sec + tv.tv_usec / 1000000.0; -} - -void -compat_timer_sleep( int ms ) -{ - usleep( ms * 1000 ); -} diff --git a/fuse/compat/unix/tuntap.c b/fuse/compat/unix/tuntap.c deleted file mode 100644 index 3226a0a..0000000 --- a/fuse/compat/unix/tuntap.c +++ /dev/null @@ -1,59 +0,0 @@ -/* tuntap.c: TUN/TAP compatability layer - Copyright (c) 2009-2010 Patrik Persson, Philip Kendall - Copyright (c) 2016 Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include "config.h" - -#include -#include -#include -#include - -#include -#include -#include - -#include "ui/ui.h" - -int -compat_get_tap( const char *interface_name ) -{ - int fd = -1; - - if ( (fd = open( "/dev/net/tun", O_RDWR | O_NONBLOCK )) < 0 ) - ui_error( UI_ERROR_ERROR, "couldn't open TUN/TAP device '/dev/net/tun'" ); - else { - struct ifreq ifr; - memset( &ifr, 0, sizeof( ifr ) ); - ifr.ifr_flags = IFF_TAP | IFF_NO_PI; - strncpy( ifr.ifr_name, interface_name, IFNAMSIZ ); - ifr.ifr_name[ IFNAMSIZ - 1 ] = '\0'; - - if ( ioctl( fd, TUNSETIFF, (void *) &ifr ) < 0 ) { - ui_error( UI_ERROR_ERROR, "couldn't select TAP interface '%s'", - ifr.ifr_name ); - } - } - - return fd; -} diff --git a/fuse/compat/wii/dir.c b/fuse/compat/wii/dir.c deleted file mode 100644 index 7876019..0000000 --- a/fuse/compat/wii/dir.c +++ /dev/null @@ -1,48 +0,0 @@ -/* dir.c: Directory-related compatibility routines - Copyright (c) 2009 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include "compat.h" - -compat_dir -compat_opendir( const char *path ) -{ - return diropen( path ); -} - -compat_dir_result_t -compat_readdir( compat_dir directory, char *path, size_t length ) -{ - struct stat fstat; - - int done = dirnext( directory, path, &fstat ); - - return done ? COMPAT_DIR_RESULT_END : COMPAT_DIR_RESULT_OK; -} - -int -compat_closedir( compat_dir directory ) -{ - return dirclose( directory ); -} diff --git a/fuse/compat/wii/osname.c b/fuse/compat/wii/osname.c deleted file mode 100644 index ca9e446..0000000 --- a/fuse/compat/wii/osname.c +++ /dev/null @@ -1,37 +0,0 @@ -/* osname.c: Get a representation of the OS we're running on - Copyright (c) 1999-2009 Philip Kendall, Bjoern Giesler - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include - -#include "ui/ui.h" - -int -compat_osname( char *buffer, size_t length ) -{ - snprintf(buffer, length, "Wii"); - return 0; -} diff --git a/fuse/compat/wii/paths.c b/fuse/compat/wii/paths.c deleted file mode 100644 index ae888f2..0000000 --- a/fuse/compat/wii/paths.c +++ /dev/null @@ -1,121 +0,0 @@ -/* paths.c: Path-related compatibility routines - Copyright (c) 1999-2012 Philip Kendall, Bjoern Giesler - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#ifdef HAVE_LIBGEN_H -#include -#endif /* #ifdef HAVE_LIBGEN_H */ -#include -#include -#include - -#include "compat.h" -#include "fuse.h" -#include "ui/ui.h" - -const char* -compat_get_temp_path( void ) -{ - return "/tmp"; -} - -const char* -compat_get_config_path( void ) -{ - return "sd:/apps/fuse"; -} - -int -compat_is_absolute_path( const char *path ) -{ - if(strlen(path) >= 1 && path[0] == '/') - return 1; - if(strlen(path) >= strlen("fat:/") && - strncmp(path, "fat:/", strlen("fat:/")) == 0) - return 1; - if(strlen(path) >= strlen("sd:/") && - strncmp(path, "sd:/", strlen("sd:/")) == 0) - return 1; - return 0; -} - -int -compat_get_next_path( path_context *ctx ) -{ - char buffer[ PATH_MAX ]; - const char *path_segment, *path2; - - switch( (ctx->state)++ ) { - - /* First look relative to the current directory */ - case 0: - strncpy( ctx->path, ".", PATH_MAX ); - return 1; - - /* Then relative to the Fuse executable */ - case 1: - - switch( ctx->type ) { - case UTILS_AUXILIARY_LIB: path_segment = "lib"; break; - case UTILS_AUXILIARY_ROM: path_segment = "roms"; break; - case UTILS_AUXILIARY_WIDGET: path_segment = "ui/widget"; break; - case UTILS_AUXILIARY_GTK: path_segment = "ui/gtk"; break; - default: - ui_error( UI_ERROR_ERROR, "unknown auxiliary file type %d", ctx->type ); - return 0; - } - - if( compat_is_absolute_path( fuse_progname ) ) { - strncpy( buffer, fuse_progname, PATH_MAX ); - buffer[ PATH_MAX - 1 ] = '\0'; - } else { - size_t len; - len = PATH_MAX - strlen( fuse_progname ) - strlen( FUSE_DIR_SEP_STR ); - if( !getcwd( buffer, len ) ) { - ui_error( UI_ERROR_ERROR, "error getting current working directory: %s", - strerror( errno ) ); - return 0; - } - strcat( buffer, FUSE_DIR_SEP_STR ); - strcat( buffer, fuse_progname ); - } - - path2 = dirname( buffer ); - snprintf( ctx->path, PATH_MAX, "%s" FUSE_DIR_SEP_STR "%s", path2, - path_segment ); - return 1; - - /* Then where we may have installed the data files */ - case 2: - - path2 = "sd:/apps/fuse"; - strncpy( ctx->path, path2, PATH_MAX ); buffer[ PATH_MAX - 1 ] = '\0'; - return 1; - - case 3: return 0; - } - ui_error( UI_ERROR_ERROR, "unknown path_context state %d", ctx->state ); - fuse_abort(); -} diff --git a/fuse/compat/wii/timer.c b/fuse/compat/wii/timer.c deleted file mode 100644 index 842ebb4..0000000 --- a/fuse/compat/wii/timer.c +++ /dev/null @@ -1,55 +0,0 @@ -/* unix.c: UNIX speed routines for Fuse - Copyright (c) 1999-2007 Philip Kendall, Marek Januszewski, Fredrick Meunier - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include - -#include "compat.h" -#include "ui/ui.h" - -/* FIXME: where should we get this prototype from? */ -extern int clock_gettime(struct timespec *tp); - -double -compat_timer_get_time( void ) -{ - int error; - struct timespec tp; - - error = clock_gettime(&tp); - if( error ) { - ui_error( UI_ERROR_ERROR, "%s: error getting time: %s", __func__, strerror( errno ) ); - return -1; - } - - return tp.tv_sec + tp.tv_nsec / 1000000000.0; -} - -void -compat_timer_sleep( int ms ) -{ - usleep( ms * 1000 ); -} diff --git a/fuse/compat/win32/osname.c b/fuse/compat/win32/osname.c deleted file mode 100644 index 1379a5c..0000000 --- a/fuse/compat/win32/osname.c +++ /dev/null @@ -1,58 +0,0 @@ -/* osname.c: Get a representation of the OS we're running on - Copyright (c) 1999-2007 Philip Kendall - Copyright (c) 2015 Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include - -#include "ui/ui.h" - -int compat_osname( char *osname, size_t length ) -{ - OSVERSIONINFO buf; - const char *windows_name; - int error; - - buf.dwOSVersionInfoSize = sizeof( buf ); - error = GetVersionEx( &buf ); - if( error == 0 ) { - ui_error( UI_ERROR_ERROR, "error getting system information." ); - return 1; - } - - switch( buf.dwPlatformId ) { - case VER_PLATFORM_WIN32_NT: windows_name = "NT"; break; - case VER_PLATFORM_WIN32_WINDOWS: windows_name = "95/98"; break; - case VER_PLATFORM_WIN32s: windows_name = "3.1"; break; - default: windows_name = "unknown"; break; - } - - /* FIXME: verify function below is unicode compliant */ - /* The casts to int work around a suspected Wine (or MinGW) bug */ - snprintf( osname, length, "Windows %s %i.%i build %i %s", - windows_name, (int)buf.dwMajorVersion, (int)buf.dwMinorVersion, - (int)buf.dwBuildNumber, buf.szCSDVersion ); - - return 0; -} diff --git a/fuse/compat/win32/paths.c b/fuse/compat/win32/paths.c deleted file mode 100644 index 4ccc0ae..0000000 --- a/fuse/compat/win32/paths.c +++ /dev/null @@ -1,121 +0,0 @@ -/* paths.c: Path-related compatibility routines - Copyright (c) 1999-2012 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#ifdef HAVE_LIBGEN_H -#include -#endif /* #ifdef HAVE_LIBGEN_H */ -#include -#include -#include - -#include "compat.h" -#include "fuse.h" -#include "ui/ui.h" - -const char* -compat_get_temp_path( void ) -{ - const char *dir; - - /* Something close to this algorithm specified at - http://msdn.microsoft.com/en-us/library/windows/desktop/aa364992%28v=vs.85%29.aspx - */ - dir = getenv( "TMP" ); if( dir ) return dir; - dir = getenv( "TEMP" ); if( dir ) return dir; - return "."; -} - -const char* -compat_get_config_path( void ) -{ - const char *dir; - dir = getenv( "USERPROFILE" ); if( dir ) return dir; - dir = getenv( "WINDIR" ); if( dir ) return dir; - return "."; -} - -int -compat_is_absolute_path( const char *path ) -{ - if( path[0] == '\\' ) return 1; - if( path[0] && path[1] == ':' ) return 1; - return 0; -} - -int -compat_get_next_path( path_context *ctx ) -{ - char buffer[ PATH_MAX ]; - const char *path_segment, *path2; - - switch( ctx->type ) { - case UTILS_AUXILIARY_LIB: path_segment = "lib"; break; - case UTILS_AUXILIARY_ROM: path_segment = "roms"; break; - case UTILS_AUXILIARY_WIDGET: path_segment = "ui/widget"; break; - case UTILS_AUXILIARY_GTK: path_segment = "ui/gtk"; break; - default: - ui_error( UI_ERROR_ERROR, "unknown auxiliary file type %d", ctx->type ); - return 0; - } - - switch( (ctx->state)++ ) { - - /* First look relative to the Fuse executable */ - case 0: - if( compat_is_absolute_path( fuse_progname ) ) { - strncpy( buffer, fuse_progname, PATH_MAX ); - buffer[ PATH_MAX - 1 ] = '\0'; - } else { - DWORD retval; - retval = GetModuleFileName( NULL, buffer, PATH_MAX ); - if( !retval ) return 0; - } - - path2 = dirname( buffer ); - snprintf( ctx->path, PATH_MAX, "%s" FUSE_DIR_SEP_STR "%s", path2, - path_segment ); - return 1; - - /* Then relative to %APPDATA%/Fuse directory */ - case 1: - path2 = getenv( "APPDATA" ); - if( !path2 ) return 0; - snprintf( ctx->path, PATH_MAX, "%s" FUSE_DIR_SEP_STR "Fuse" - FUSE_DIR_SEP_STR "%s", path2, path_segment ); - - return 1; - - /* Then relative to the current directory */ - case 2: - snprintf( ctx->path, PATH_MAX, "." FUSE_DIR_SEP_STR "%s", - path_segment ); - return 1; - - case 3: return 0; - } - - ui_error( UI_ERROR_ERROR, "unknown path_context state %d", ctx->state ); - fuse_abort(); -} diff --git a/fuse/compat/win32/socket.c b/fuse/compat/win32/socket.c deleted file mode 100644 index 961e677..0000000 --- a/fuse/compat/win32/socket.c +++ /dev/null @@ -1,243 +0,0 @@ -/* socket.c: Socket-related compatibility routines - Copyright (c) 2011-2015 Sergio Baldoví, Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include "compat.h" -#include "fuse.h" -#include "ui/ui.h" - -const compat_socket_t compat_socket_invalid = INVALID_SOCKET; -const int compat_socket_EBADF = WSAENOTSOCK; - -struct compat_socket_selfpipe_t { - SOCKET self_socket; - libspectrum_word port; -}; - -int -compat_socket_blocking_mode( compat_socket_t fd, int blocking ) -{ - u_long mode = blocking ? 1 : 0; - return ( ioctlsocket( fd, FIONBIO, &mode ) ); -} - -int -compat_socket_close( compat_socket_t fd ) -{ - return closesocket( fd ); -} - -int compat_socket_get_error( void ) -{ - return WSAGetLastError(); -} - -const char * -compat_socket_get_strerror( void ) -{ - static TCHAR buffer[256]; - TCHAR *ptr; - DWORD msg_size; - - /* get description of last winsock error */ - msg_size = FormatMessage( - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, WSAGetLastError(), - MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), - buffer, ARRAY_SIZE( buffer ), NULL ); - - if( !msg_size ) return NULL; - - /* skip 'new line' like chars */ - for( ptr = buffer; *ptr; ptr++ ) { - if( ( *ptr == '\r' ) || ( *ptr == '\n' ) ) { - *ptr = '\0'; - break; - } - } - - return (const char *)buffer; -} - -static int -selfpipe_test( compat_socket_selfpipe_t *self ) -{ - fd_set readfds; - int active; - struct timeval tv = { 1, 0 }; - - /* Send testing packet */ - compat_socket_selfpipe_wake( self ); - - /* Safe reading from control socket */ - FD_ZERO( &readfds ); - FD_SET( self->self_socket, &readfds ); - active = select( 0, &readfds, NULL, NULL, &tv ); - if( active == 0 || active == compat_socket_invalid ) { - return -1; - } - - /* Discard testing packet */ - if( FD_ISSET( self->self_socket, &readfds ) ) { - compat_socket_selfpipe_discard_data( self ); - } - - return 0; -} - -compat_socket_selfpipe_t * -compat_socket_selfpipe_alloc( void ) -{ - unsigned long mode = 1; - struct sockaddr_in sa; - socklen_t sa_len = sizeof(sa); - - compat_socket_selfpipe_t *self = - libspectrum_new( compat_socket_selfpipe_t, 1 ); - - self->self_socket = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ); - if( self->self_socket == compat_socket_invalid ) { - ui_error( UI_ERROR_ERROR, - "%s: %d: failed to open socket; errno %d: %s\n", - __FILE__, __LINE__, compat_socket_get_error(), - compat_socket_get_strerror() ); - fuse_abort(); - } - - /* Set nonblocking mode */ - if( ioctlsocket( self->self_socket, FIONBIO, &mode ) == -1 ) { - ui_error( UI_ERROR_ERROR, - "%s: %d: failed to set socket nonblocking; errno %d: %s\n", - __FILE__, __LINE__, compat_socket_get_error(), - compat_socket_get_strerror() ); - fuse_abort(); - } - - memset( &sa, 0, sizeof(sa) ); - sa.sin_family = AF_INET; - sa.sin_addr.s_addr = htonl( INADDR_LOOPBACK ); - - if( bind( self->self_socket, (struct sockaddr*)&sa, sizeof(sa) ) == -1 ) { - ui_error( UI_ERROR_ERROR, - "%s: %d: failed to bind socket; errno %d: %s\n", - __FILE__, __LINE__, compat_socket_get_error(), - compat_socket_get_strerror() ); - fuse_abort(); - } - - /* Get ephemeral port number */ - if( getsockname( self->self_socket, (struct sockaddr *)&sa, &sa_len ) == -1 ) { - ui_error( UI_ERROR_ERROR, - "%s: %d: failed to get socket name; errno %d: %s\n", - __FILE__, __LINE__, compat_socket_get_error(), - compat_socket_get_strerror() ); - fuse_abort(); - } - - self->port = ntohs( sa.sin_port ); - - /* Test communications in order to detect blocking firewalls */ - if( selfpipe_test( self ) == -1 ) { - ui_error( UI_ERROR_ERROR, - "Networking: failed to test internal communications" ); - fuse_abort(); - } - - return self; -} - -void -compat_socket_selfpipe_free( compat_socket_selfpipe_t *self ) -{ - compat_socket_close( self->self_socket ); - libspectrum_free( self ); -} - -compat_socket_t -compat_socket_selfpipe_get_read_fd( compat_socket_selfpipe_t *self ) -{ - return self->self_socket; -} - -void -compat_socket_selfpipe_wake( compat_socket_selfpipe_t *self ) -{ - struct sockaddr_in sa; - - memset( &sa, 0, sizeof(sa) ); - sa.sin_family = AF_INET; - sa.sin_addr.s_addr = htonl( INADDR_LOOPBACK ); - sa.sin_port = htons( self->port ); - - sendto( self->self_socket, NULL, 0, 0, (struct sockaddr*)&sa, sizeof(sa) ); -} - -void -compat_socket_selfpipe_discard_data( compat_socket_selfpipe_t *self ) -{ - ssize_t bytes_read; - struct sockaddr_in sa; - socklen_t sa_length = sizeof(sa); - static char bitbucket[0x100]; - - do { - /* Socket is non blocking, so we can do this safely */ - bytes_read = recvfrom( self->self_socket, bitbucket, sizeof( bitbucket ), - 0, (struct sockaddr*)&sa, &sa_length ); - } while( bytes_read != -1 ); -} - - -void -compat_socket_networking_init( void ) -{ - WORD wVersionRequested; - WSADATA wsaData; - int error; - - wVersionRequested = MAKEWORD( 2, 2 ); - error = WSAStartup( wVersionRequested, &wsaData ); - if( error ) { - ui_error( UI_ERROR_ERROR, "%s:%d: error %d from WSAStartup()", __FILE__, - __LINE__, error ); - fuse_abort(); - } - - if( LOBYTE( wsaData.wVersion ) != 2 || HIBYTE( wsaData.wVersion ) != 2 ) { - ui_error( UI_ERROR_ERROR, - "%s:%d: unexpected version 0x%02x from WSAStartup()", - __FILE__, __LINE__, wsaData.wVersion ); - fuse_abort(); - } -} - -void -compat_socket_networking_end( void ) -{ - WSACleanup(); -} - diff --git a/fuse/compat/win32/timer.c b/fuse/compat/win32/timer.c deleted file mode 100644 index 3099f57..0000000 --- a/fuse/compat/win32/timer.c +++ /dev/null @@ -1,40 +0,0 @@ -/* timer.c: Win32 speed routines for Fuse - Copyright (c) 1999-2008 Philip Kendall, Marek Januszewski, Fredrick Meunier - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include - -#include "compat.h" - -double -compat_timer_get_time( void ) -{ - return GetTickCount() / 1000.0; -} - -void -compat_timer_sleep( int ms ) -{ - Sleep( ms ); -} diff --git a/fuse/display.c b/fuse/display.c index 8702c41..6efe59d 100644 --- a/fuse/display.c +++ b/fuse/display.c @@ -33,10 +33,8 @@ #include "fuse.h" #include "infrastructure/startup_manager.h" #include "machine.h" -#include "movie.h" #include "peripherals/scld.h" #include "rectangle.h" -#include "screenshot.h" #include "settings.h" #include "spectrum.h" #include "ui/ui.h" @@ -926,15 +924,7 @@ update_ui_screen( void ) if( settings_current.frame_rate <= ++frame_count ) { frame_count = 0; - if( movie_recording ) { - movie_start_frame(); - } - if( display_redraw_all ) { - if( movie_recording ) { - movie_add_area( 0, 0, DISPLAY_ASPECT_WIDTH >> 3, - DISPLAY_SCREEN_HEIGHT ); - } uidisplay_area( 0, 0, scale * DISPLAY_ASPECT_WIDTH, scale * DISPLAY_SCREEN_HEIGHT ); @@ -943,10 +933,7 @@ update_ui_screen( void ) for( i = 0, ptr = rectangle_inactive; i < rectangle_inactive_count; i++, ptr++ ) { - if( movie_recording ) { - movie_add_area( ptr->x, ptr->y, ptr->w, ptr->h ); - } - uidisplay_area( 8 * scale * ptr->x, scale * ptr->y, + uidisplay_area( 8 * scale * ptr->x, scale * ptr->y, 8 * scale * ptr->w, scale * ptr->h ); } } diff --git a/fuse/fuse.c b/fuse/fuse.c index ab43627..97162fb 100644 --- a/fuse/fuse.c +++ b/fuse/fuse.c @@ -63,7 +63,6 @@ #include "machines/machines_periph.h" #include "memory_pages.h" #include "module.h" -#include "movie.h" #include "mempool.h" #include "peripherals/ay.h" #include "peripherals/dck.h" @@ -93,10 +92,8 @@ #include "peripherals/usource.h" #include "phantom_typist.h" #include "pokefinder/pokemem.h" -#include "profile.h" #include "psg.h" #include "rzx.h" -#include "screenshot.h" #include "settings.h" #include "slt.h" #include "snapshot.h" @@ -104,7 +101,6 @@ #include "spectrum.h" #include "tape.h" #include "timer/timer.h" -#include "ui/scaler/scaler.h" #include "ui/ui.h" #include "ui/uimedia.h" #include "unittests/unittests.h" @@ -325,11 +321,9 @@ run_startup_manager( int *argc, char ***argv ) phantom_typist_register_startup(); plusd_register_startup(); printer_register_startup(); - profile_register_startup(); psg_register_startup(); rzx_register_startup(); scld_register_startup(); - screenshot_register_startup(); settings_register_startup(); setuid_register_startup(); simpleide_register_startup(); @@ -356,7 +350,6 @@ run_startup_manager( int *argc, char ***argv ) static int fuse_init(int argc, char **argv) { int error, first_arg; - char *start_scaler; start_files_t start_files; /* Seed the bad but widely-available random number @@ -387,27 +380,14 @@ static int fuse_init(int argc, char **argv) return 0; } - start_scaler = utils_safe_strdup( settings_current.start_scaler_mode ); - fuse_show_copyright(); - /* Everything between here and the scaler_select_id() below owns - start_scaler and has to release it before bailing out. machine_select_id() - is a path users reach: selecting a model whose ROMs are not installed - fails there, and a libretro core retries on the next content load rather - than exiting. */ - if( run_startup_manager( &argc, &argv ) ) { - libspectrum_free( start_scaler ); - return 1; - } + /* machine_select_id() is a path users reach: selecting a model whose ROMs + are not installed fails there, and a libretro core retries on the next + content load rather than exiting. */ + if( run_startup_manager( &argc, &argv ) ) return 1; error = machine_select_id( settings_current.start_machine ); - if( error ) { - libspectrum_free( start_scaler ); - return error; - } - - error = scaler_select_id( start_scaler ); libspectrum_free( start_scaler ); if( error ) return error; if( setup_start_files( &start_files ) ) return 1; @@ -420,7 +400,6 @@ static int fuse_init(int argc, char **argv) if( ui_mouse_present ) ui_mouse_grabbed = ui_mouse_grab( 1 ); fuse_emulation_paused = 0; - movie_init(); return 0; } @@ -997,7 +976,6 @@ do_start_files( start_files_t *start_files ) /* Tidy-up function called at end of emulation */ static int fuse_end(void) { - movie_stop(); /* stop movie recording */ startup_manager_run_end(); diff --git a/fuse/input.c b/fuse/input.c index e8c4528..9cb5471 100644 --- a/fuse/input.c +++ b/fuse/input.c @@ -236,11 +236,6 @@ keypress( const input_event_key_t *event ) { int swallow; - if( ui_widget_level >= 0 ) { - ui_widget_keyhandler( event->native_key ); - return 0; - } - /* Escape => ask UI to end mouse grab, return if grab ended */ if( event->native_key == INPUT_KEY_Escape && ui_mouse_grabbed ) { ui_mouse_grabbed = ui_mouse_release( 0 ); @@ -364,24 +359,6 @@ do_joystick( const input_event_joystick_t *joystick_event, int press ) { int which; -#ifdef USE_WIDGET - if( ui_widget_level >= 0 ) { - if( press ) ui_widget_keyhandler( joystick_event->button ); - return 0; - } - -#ifndef GEKKO /* Home button opens the menu on Wii */ - switch( joystick_event->button ) { - case INPUT_JOYSTICK_FIRE_2: - if( press ) ui_popup_menu( INPUT_KEY_F1 ); - break; - - default: break; /* Remove gcc warning */ - - } -#endif /* #ifndef GEKKO */ - -#endif /* #ifdef USE_WIDGET */ which = joystick_event->which; diff --git a/fuse/machine.c b/fuse/machine.c index d2c2e74..6be2545 100644 --- a/fuse/machine.c +++ b/fuse/machine.c @@ -38,7 +38,6 @@ #include "machines/tc2068.h" #include "memory_pages.h" #include "module.h" -#include "movie.h" #include "peripherals/ula.h" #include "pokefinder/pokemem.h" #include "rzx.h" @@ -141,7 +140,6 @@ machine_select( libspectrum_machine type ) /* We don't want to have to deal with screen size changes in the movie code and recording movies where we change machines seems pretty obscure */ - movie_stop(); for( i=0; i < machine_count; i++ ) { if( machine_types[i]->machine == type ) { diff --git a/fuse/menu.c b/fuse/menu.c deleted file mode 100644 index 22a6fd9..0000000 --- a/fuse/menu.c +++ /dev/null @@ -1,1248 +0,0 @@ -/* menu.c: general menu callbacks - Copyright (c) 2004-2018 Philip Kendall and others - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - Philip Kendall - -*/ - -#include - -#include - -#include "event.h" -#include "fuse.h" -#include "menu.h" -#include "movie.h" -#include "machines/specplus3.h" -#include "peripherals/dck.h" -#include "peripherals/disk/beta.h" -#include "peripherals/disk/didaktik.h" -#include "peripherals/disk/disciple.h" -#include "peripherals/disk/opus.h" -#include "peripherals/disk/plusd.h" -#include "peripherals/ide/divide.h" -#include "peripherals/ide/divmmc.h" -#include "peripherals/ide/simpleide.h" -#include "peripherals/ide/zxatasp.h" -#include "peripherals/ide/zxcf.h" -#include "peripherals/ide/zxmmc.h" -#include "peripherals/if1.h" -#include "peripherals/if2.h" -#include "peripherals/joystick.h" -#include "peripherals/multiface.h" -#include "peripherals/scld.h" -#include "profile.h" -#include "psg.h" -#include "rzx.h" -#include "screenshot.h" -#include "settings.h" -#include "snapshot.h" -#include "svg.h" -#include "tape.h" -#include "ui/scaler/scaler.h" -#include "ui/ui.h" -#include "ui/uimedia.h" -#include "utils.h" -#include "z80/z80.h" - -static int menu_select_machine_roms( libspectrum_machine machine, size_t start, - size_t n ); - -static int menu_select_peripheral_roms( const char *peripheral_name, - size_t start, size_t n ); - -MENU_CALLBACK( menu_file_open ) -{ - char *filename; - - fuse_emulation_pause(); - - filename = ui_get_open_filename( "Fuse - Open Spectrum File" ); - if( !filename ) { fuse_emulation_unpause(); return; } - - utils_open_file( filename, tape_can_autoload(), NULL ); - - libspectrum_free( filename ); - - display_refresh_all(); - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_file_recording_insertsnapshot ) -{ - libspectrum_snap *snap; - libspectrum_error error; - - if( !rzx_recording ) return; - - ui_widget_finish(); - - libspectrum_rzx_stop_input( rzx ); - - snap = libspectrum_snap_alloc(); - - error = snapshot_copy_to( snap ); - if( error ) { libspectrum_snap_free( snap ); return; } - - libspectrum_rzx_add_snap( rzx, snap, 0 ); - - libspectrum_rzx_start_input( rzx, tstates ); -} - -MENU_CALLBACK( menu_file_recording_rollback ) -{ - libspectrum_error error; - - if( !rzx_recording ) return; - - ui_widget_finish(); - - fuse_emulation_pause(); - - error = rzx_rollback(); - if( error ) { fuse_emulation_unpause(); return; } - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_file_recording_rollbackto ) -{ - libspectrum_error error; - - if( !rzx_recording ) return; - - ui_widget_finish(); - - fuse_emulation_pause(); - - error = rzx_rollback_to(); - if( error ) { fuse_emulation_unpause(); return; } - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_file_recording_play ) -{ - char *recording; - - if( rzx_playback || rzx_recording ) return; - - fuse_emulation_pause(); - - recording = ui_get_open_filename( "Fuse - Start Replay" ); - if( !recording ) { fuse_emulation_unpause(); return; } - - rzx_start_playback( recording, 1 ); - - libspectrum_free( recording ); - - display_refresh_all(); - - if( rzx_playback ) ui_menu_activate( UI_MENU_ITEM_RECORDING, 1 ); - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_file_recording_stop ) -{ - if( !( rzx_recording || rzx_playback ) ) return; - - ui_widget_finish(); - - if( rzx_recording ) rzx_stop_recording(); - if( rzx_playback ) rzx_stop_playback( 1 ); -} - -MENU_CALLBACK( menu_file_recording_finalise ) -{ - char *rzx_filename; - int error; - - if( rzx_playback || rzx_recording ) return; - - fuse_emulation_pause(); - - rzx_filename = ui_get_open_filename( "Fuse - Finalise Recording" ); - if( !rzx_filename ) { fuse_emulation_unpause(); return; } - - error = rzx_finalise_recording( rzx_filename ); - - if( error == LIBSPECTRUM_ERROR_NONE ) { - ui_error( UI_ERROR_INFO, "RZX file finalised" ); - } else { - ui_error( UI_ERROR_WARNING, "RZX file cannot be finalised" ); - } - - libspectrum_free( rzx_filename ); - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_file_aylogging_stop ) -{ - if ( !psg_recording ) return; - - ui_widget_finish(); - - psg_stop_recording(); - ui_menu_activate( UI_MENU_ITEM_AY_LOGGING, 0 ); -} - -MENU_CALLBACK( menu_file_screenshot_openscrscreenshot ) -{ - char *filename; - - fuse_emulation_pause(); - - filename = ui_get_open_filename( "Fuse - Open SCR Screenshot" ); - if( !filename ) { fuse_emulation_unpause(); return; } - - screenshot_scr_read( filename ); - - libspectrum_free( filename ); - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_file_screenshot_openmltscreenshot ) -{ - char *filename; - - fuse_emulation_pause(); - - filename = ui_get_open_filename( "Fuse - Open MLT Screenshot" ); - if( !filename ) { fuse_emulation_unpause(); return; } - - screenshot_mlt_read( filename ); - - libspectrum_free( filename ); - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_file_movie_stop ) -{ - ui_widget_finish(); - - movie_stop(); -} - -MENU_CALLBACK( menu_file_movie_pause ) -{ - ui_widget_finish(); - - movie_pause(); -} - -MENU_CALLBACK_WITH_ACTION( menu_options_selectroms_machine_select ) -{ - switch( action ) { - - case 1: menu_select_machine_roms( LIBSPECTRUM_MACHINE_16, 0, 1 ); return; - case 2: menu_select_machine_roms( LIBSPECTRUM_MACHINE_48, 1, 1 ); return; - case 3: menu_select_machine_roms( LIBSPECTRUM_MACHINE_128, 2, 2 ); return; - case 4: menu_select_machine_roms( LIBSPECTRUM_MACHINE_PLUS2, 4, 2 ); return; - case 5: menu_select_machine_roms( LIBSPECTRUM_MACHINE_PLUS2A, 6, 4 ); return; - case 6: menu_select_machine_roms( LIBSPECTRUM_MACHINE_PLUS3, 10, 4 ); return; - case 7: menu_select_machine_roms( LIBSPECTRUM_MACHINE_PLUS3E, 14, 4 ); return; - case 8: menu_select_machine_roms( LIBSPECTRUM_MACHINE_TC2048, 18, 1 ); return; - case 9: menu_select_machine_roms( LIBSPECTRUM_MACHINE_TC2068, 19, 2 ); return; - case 10: menu_select_machine_roms( LIBSPECTRUM_MACHINE_TS2068, 21, 2 ); return; - case 11: menu_select_machine_roms( LIBSPECTRUM_MACHINE_PENT, 23, 3 ); return; - case 12: menu_select_machine_roms( LIBSPECTRUM_MACHINE_PENT512, 26, 4 ); return; - case 13: menu_select_machine_roms( LIBSPECTRUM_MACHINE_PENT1024, 30, 4 ); return; - case 14: menu_select_machine_roms( LIBSPECTRUM_MACHINE_SCORP, 34, 4 ); return; - case 15: menu_select_machine_roms( LIBSPECTRUM_MACHINE_SE, 38, 2 ); return; - - } - - ui_error( UI_ERROR_ERROR, - "menu_options_selectroms_machine_select: unknown action %d", action ); - fuse_abort(); -} - -MENU_CALLBACK_WITH_ACTION( menu_options_selectroms_peripheral_select ) -{ - switch( action ) { - - case 1: menu_select_peripheral_roms( "Interface 1", 0, 1 ); return; - case 2: menu_select_peripheral_roms( "Beta 128", 1, 1 ); return; - case 3: menu_select_peripheral_roms( "+D", 2, 1 ); return; - case 4: menu_select_peripheral_roms( "Didaktik 80", 3, 1 ); return; - case 5: menu_select_peripheral_roms( "DISCiPLE", 4, 1 ); return; - case 6: menu_select_peripheral_roms( "Multiface One", 5, 1 ); return; - case 7: menu_select_peripheral_roms( "Multiface 128", 6, 1 ); return; - case 8: menu_select_peripheral_roms( "Multiface 3", 7, 1 ); return; - case 9: menu_select_peripheral_roms( "Opus Discovery", 8, 1 ); return; - case 10: menu_select_peripheral_roms( "SpeccyBoot", 9, 1 ); return; - case 11: menu_select_peripheral_roms( "TTX2000S", 10, 1 ); return; - case 12: menu_select_peripheral_roms( "uSource", 11, 1 ); return; - - } - - ui_error( UI_ERROR_ERROR, - "menu_options_selectroms_peripheral_select: unknown action %d", action ); - fuse_abort(); -} - -MENU_CALLBACK( menu_options_filter ) -{ - scaler_type scaler; - - /* Stop emulation */ - fuse_emulation_pause(); - - scaler = menu_get_scaler( scaler_is_supported ); - if( scaler != SCALER_NUM && scaler != current_scaler ) - scaler_select_scaler( scaler ); - - /* Carry on with emulation again */ - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_options_fullscreen ) -{ - ui_widget_finish(); - settings_current.full_screen = !settings_current.full_screen; -} - -MENU_CALLBACK( menu_options_save ) -{ - ui_widget_finish(); - settings_write_config( &settings_current ); -} - -MENU_CALLBACK( menu_machine_profiler_start ) -{ - ui_widget_finish(); - profile_start(); -} - -MENU_CALLBACK( menu_machine_profiler_stop ) -{ - char *filename; - - fuse_emulation_pause(); - - filename = ui_get_save_filename( "Fuse - Save Profile Data" ); - if( !filename ) { fuse_emulation_unpause(); return; } - - profile_finish( filename ); - - libspectrum_free( filename ); - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_machine_nmi ) -{ - ui_widget_finish(); - event_add( 0, z80_nmi_event ); -} - -MENU_CALLBACK( menu_machine_multifaceredbutton ) -{ - ui_widget_finish(); - multiface_red_button(); -} - -MENU_CALLBACK( menu_media_tape_open ) -{ - char *filename; - - fuse_emulation_pause(); - - filename = ui_get_open_filename( "Fuse - Open Tape" ); - if( !filename ) { fuse_emulation_unpause(); return; } - - tape_open( filename, 0 ); - - libspectrum_free( filename ); - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_media_tape_play ) -{ - ui_widget_finish(); - tape_toggle_play( 0 ); -} - -MENU_CALLBACK( menu_media_tape_rewind ) -{ - ui_widget_finish(); - tape_rewind(); -} - -MENU_CALLBACK( menu_media_tape_clear ) -{ - ui_widget_finish(); - tape_close(); -} - -MENU_CALLBACK( menu_media_tape_write ) -{ - ui_tape_write(); -} - -MENU_CALLBACK( menu_media_tape_recordstart ) -{ - ui_widget_finish(); - tape_record_start(); -} - -MENU_CALLBACK( menu_media_tape_recordstop ) -{ - ui_widget_finish(); - tape_record_stop(); -} - -MENU_CALLBACK_WITH_ACTION( menu_media_if1_rs232 ) -{ - char *filename; - - fuse_emulation_pause(); - - if( action & 0xf0 ) { - ui_widget_finish(); - if1_unplug( action & 0x0f ); - } else { - filename = ui_get_open_filename( "Fuse - Select File for Communication" ); - if( !filename ) { fuse_emulation_unpause(); return; } - - if1_plug( filename, action ); - - libspectrum_free( filename ); - } - fuse_emulation_unpause(); - -} - -MENU_CALLBACK_WITH_ACTION( menu_media_insert_new ) -{ - int which, type; - ui_media_drive_info_t *drive; - - ui_widget_finish(); - - action--; - which = action & 0x0f; - type = ( action & 0xf0 ) >> 4; - - switch( type ) { - case 3: - if1_mdr_insert( which, NULL ); - break; - default: - drive = ui_media_drive_find( type, which ); - if( !drive ) - return; - ui_media_drive_insert( drive, NULL, 0 ); - break; - } -} - -MENU_CALLBACK_WITH_ACTION( menu_media_insert ) -{ - char *filename; - char title[80]; - int which, type; - ui_media_drive_info_t *drive = NULL; - - action--; - which = action & 0x0f; - type = ( action & 0xf0 ) >> 4; - - fuse_emulation_pause(); - - switch( type ) { - case 3: - snprintf( title, 80, "Fuse - Insert Microdrive Cartridge %i", which + 1 ); - break; - default: - drive = ui_media_drive_find( type, which ); - if( !drive ) - return; - snprintf( title, sizeof(title), "Fuse - Insert %s", drive->name ); - break; - } - filename = ui_get_open_filename( title ); - if( !filename ) { fuse_emulation_unpause(); return; } - - switch( type ) { - case 3: - if1_mdr_insert( which, filename ); - break; - default: - ui_media_drive_insert( drive, filename, 0 ); - break; - } - - libspectrum_free( filename ); - - fuse_emulation_unpause(); -} - -MENU_CALLBACK_WITH_ACTION( menu_media_eject ) -{ - int which, type; - - ui_widget_finish(); - - action--; - which = action & 0x00f; - type = ( action & 0x0f0 ) >> 4; - - switch( type ) { - case 3: - if1_mdr_eject( which ); - break; - default: - ui_media_drive_eject( type, which ); - break; - } -} - -MENU_CALLBACK_WITH_ACTION( menu_media_save ) -{ - int which, saveas, type; - - ui_widget_finish(); - - action--; - which = action & 0x00f; - type = ( action & 0x0f0 ) >> 4; - saveas = ( action & 0xf00 ) >> 8; - - switch( type ) { - case 3: - if1_mdr_save( which, saveas ); - break; - default: - ui_media_drive_save( type, which, saveas ); - break; - } -} - -MENU_CALLBACK_WITH_ACTION( menu_media_flip ) -{ - int which, type, flip; - - ui_widget_finish(); - - action--; - which = action & 0x0f; - type = ( action & 0xf0 ) >> 4; - flip = !!( action & 0x100 ); - - switch( type ) { - /* No flip option for IF1 */ - default: - ui_media_drive_flip( type, which, flip ); - break; - } -} - -MENU_CALLBACK_WITH_ACTION( menu_media_writeprotect ) -{ - int which, wrprot, type; - - ui_widget_finish(); - - action--; - which = action & 0x00f; - type = ( action & 0x0f0 ) >> 4; - wrprot = !!( action & 0x100 ); - - switch( type ) { - case 3: - if1_mdr_writeprotect( which, wrprot ); - break; - default: - ui_media_drive_writeprotect( type, which, wrprot ); - break; - } - -} - -MENU_CALLBACK( menu_media_cartridge_timexdock_insert ) -{ - char *filename; - - fuse_emulation_pause(); - - filename = ui_get_open_filename( "Fuse - Insert Timex Dock Cartridge" ); - if( !filename ) { fuse_emulation_unpause(); return; } - - dck_insert( filename ); - - libspectrum_free( filename ); - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_media_cartridge_timexdock_eject ) -{ - ui_widget_finish(); - dck_eject(); -} - -MENU_CALLBACK( menu_media_cartridge_interface2_insert ) -{ - char *filename; - - fuse_emulation_pause(); - - filename = ui_get_open_filename( "Fuse - Insert Interface 2 Cartridge" ); - if( !filename ) { fuse_emulation_unpause(); return; } - - if2_insert( filename ); - - libspectrum_free( filename ); - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_media_cartridge_interface2_eject ) -{ - ui_widget_finish(); - if2_eject(); -} - -MENU_CALLBACK_WITH_ACTION( menu_media_ide_insert ) -{ - char *filename; - - fuse_emulation_pause(); - - filename = ui_get_open_filename( "Fuse - Insert Hard Disk File" ); - if( !filename ) { fuse_emulation_unpause(); return; } - - switch( action ) { - case 1: simpleide_insert( filename, LIBSPECTRUM_IDE_MASTER ); break; - case 2: simpleide_insert( filename, LIBSPECTRUM_IDE_SLAVE ); break; - case 3: zxatasp_insert( filename, LIBSPECTRUM_IDE_MASTER ); break; - case 4: zxatasp_insert( filename, LIBSPECTRUM_IDE_SLAVE ); break; - case 5: zxcf_insert( filename ); break; - case 6: divide_insert( filename, LIBSPECTRUM_IDE_MASTER ); break; - case 7: divide_insert( filename, LIBSPECTRUM_IDE_SLAVE ); break; - case 8: divmmc_insert( filename ); break; - case 9: zxmmc_insert( filename ); break; - } - - libspectrum_free( filename ); - - fuse_emulation_unpause(); -} - -MENU_CALLBACK_WITH_ACTION( menu_media_ide_commit ) -{ - fuse_emulation_pause(); - - switch( action ) { - case 1: simpleide_commit( LIBSPECTRUM_IDE_MASTER ); break; - case 2: simpleide_commit( LIBSPECTRUM_IDE_SLAVE ); break; - case 3: zxatasp_commit( LIBSPECTRUM_IDE_MASTER ); break; - case 4: zxatasp_commit( LIBSPECTRUM_IDE_SLAVE ); break; - case 5: zxcf_commit(); break; - case 6: divide_commit( LIBSPECTRUM_IDE_MASTER ); break; - case 7: divide_commit( LIBSPECTRUM_IDE_SLAVE ); break; - case 8: divmmc_commit(); break; - case 9: zxmmc_commit(); break; - } - - fuse_emulation_unpause(); - - ui_widget_finish(); -} - -MENU_CALLBACK_WITH_ACTION( menu_media_ide_eject ) -{ - fuse_emulation_pause(); - - switch( action ) { - case 1: simpleide_eject( LIBSPECTRUM_IDE_MASTER ); break; - case 2: simpleide_eject( LIBSPECTRUM_IDE_SLAVE ); break; - case 3: zxatasp_eject( LIBSPECTRUM_IDE_MASTER ); break; - case 4: zxatasp_eject( LIBSPECTRUM_IDE_SLAVE ); break; - case 5: zxcf_eject(); break; - case 6: divide_eject( LIBSPECTRUM_IDE_MASTER ); break; - case 7: divide_eject( LIBSPECTRUM_IDE_SLAVE ); break; - case 8: divmmc_eject(); break; - } - - fuse_emulation_unpause(); - - ui_widget_finish(); -} - -MENU_CALLBACK( menu_file_savesnapshot ) -{ - char *filename; - - ui_widget_finish(); - - fuse_emulation_pause(); - - filename = ui_get_save_filename( "Fuse - Save Snapshot" ); - if( !filename ) { fuse_emulation_unpause(); return; } - - snapshot_write( filename ); - - libspectrum_free( filename ); - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_file_screenshot_savescreenasscr ) -{ - char *filename; - - ui_widget_finish(); - - fuse_emulation_pause(); - - filename = ui_get_save_filename( "Fuse - Save Screenshot as SCR" ); - if( !filename ) { fuse_emulation_unpause(); return; } - - screenshot_scr_write( filename ); - - libspectrum_free( filename ); - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_file_screenshot_savescreenasmlt ) -{ - char *filename; - - ui_widget_finish(); - - fuse_emulation_pause(); - - if( machine_current->timex && scld_last_dec.name.hires ) { - ui_error( UI_ERROR_ERROR, - "MLT format not supported for Timex hi-res screen mode" ); - fuse_emulation_unpause(); - return; - } - - filename = ui_get_save_filename( "Fuse - Save Screenshot as MLT" ); - if( !filename ) { fuse_emulation_unpause(); return; } - - screenshot_mlt_write( filename ); - - libspectrum_free( filename ); - - fuse_emulation_unpause(); -} - -#ifdef USE_LIBPNG - -MENU_CALLBACK( menu_file_screenshot_savescreenaspng ) -{ - scaler_type scaler; - char *filename; - - ui_widget_finish(); - - fuse_emulation_pause(); - - scaler = menu_get_scaler( screenshot_available_scalers ); - if( scaler == SCALER_NUM ) { - fuse_emulation_unpause(); - return; - } - - filename = - ui_get_save_filename( "Fuse - Save Screenshot as PNG" ); - if( !filename ) { fuse_emulation_unpause(); return; } - - screenshot_write( filename, scaler ); - - libspectrum_free( filename ); - - fuse_emulation_unpause(); -} - -#endif - -#ifdef HAVE_LIB_XML2 - -MENU_CALLBACK( menu_file_scalablevectorgraphics_startcaptureinlinemode ) -{ - char *filename; - - ui_widget_finish(); - if( !svg_capture_active ) { - - fuse_emulation_pause(); - - filename = ui_get_save_filename( "Fuse - Capture to SVG File" ); - if( !filename ) { fuse_emulation_unpause(); return; } - - ui_menu_activate( UI_MENU_ITEM_FILE_SVG_CAPTURE, 1 ); - svg_startcapture( filename, SVG_CAPTURE_LINES ); - - fuse_emulation_unpause(); - } -} - -MENU_CALLBACK( menu_file_scalablevectorgraphics_startcaptureindotmode ) -{ - char *filename; - - ui_widget_finish(); - if( !svg_capture_active ) { - - fuse_emulation_pause(); - - filename = ui_get_save_filename( "Fuse - Capture to SVG File" ); - if( !filename ) { fuse_emulation_unpause(); return; } - ui_menu_activate( UI_MENU_ITEM_FILE_SVG_CAPTURE, 1 ); - - svg_startcapture( filename, SVG_CAPTURE_DOTS ); - - fuse_emulation_unpause(); - } -} - -MENU_CALLBACK( menu_file_scalablevectorgraphics_stopcapture ) -{ - ui_widget_finish(); - if( svg_capture_active ) { - - fuse_emulation_pause(); - - svg_stopcapture(); - ui_menu_activate( UI_MENU_ITEM_FILE_SVG_CAPTURE, 0 ); - - fuse_emulation_unpause(); - } -} - -#endif /* HAVE_LIB_XML2 */ - - -MENU_CALLBACK( menu_file_movie_record ) -{ - char *filename; - - ui_widget_finish(); - - fuse_emulation_pause(); - - filename = ui_get_save_filename( "Fuse - Record Movie File" ); - if( !filename ) { fuse_emulation_unpause(); return; } - - movie_start( filename ); - libspectrum_free( filename ); - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_file_movie_record_recordfromrzx ) -{ - char *rzx_file, *fmf_file; - - ui_widget_finish(); - - if( rzx_playback || rzx_recording || movie_recording ) return; - - fuse_emulation_pause(); - - rzx_file = ui_get_open_filename( "Fuse - Load RZX" ); - if( !rzx_file ) { fuse_emulation_unpause(); return; } - - rzx_start_playback( rzx_file, 1 ); - libspectrum_free( rzx_file ); - display_refresh_all(); - - if( rzx_playback ) { - fmf_file = ui_get_save_filename( "Fuse - Record Movie File" ); - if( !fmf_file ) { - rzx_stop_playback( 1 ); - fuse_emulation_unpause(); - return; - } - - movie_start( fmf_file ); - libspectrum_free( fmf_file ); - ui_menu_activate( UI_MENU_ITEM_RECORDING, 1 ); - } - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_file_recording_record ) -{ - char *recording; - - if( rzx_playback || rzx_recording ) return; - - fuse_emulation_pause(); - - recording = ui_get_save_filename( "Fuse - Start Recording" ); - if( !recording ) { fuse_emulation_unpause(); return; } - - rzx_start_recording( recording, 1 ); - - libspectrum_free( recording ); - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_file_recording_recordfromsnapshot ) -{ - char *snap, *recording; - - if( rzx_playback || rzx_recording ) return; - - fuse_emulation_pause(); - - snap = ui_get_open_filename( "Fuse - Load Snapshot " ); - if( !snap ) { fuse_emulation_unpause(); return; } - - recording = ui_get_save_filename( "Fuse - Start Recording" ); - if( !recording ) { - libspectrum_free( snap ); - fuse_emulation_unpause(); - return; - } - - if( snapshot_read( snap ) ) { - libspectrum_free( snap ); - libspectrum_free( recording ); - fuse_emulation_unpause(); - return; - } - - rzx_start_recording( recording, settings_current.embed_snapshot ); - - libspectrum_free( recording ); - - display_refresh_all(); - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_file_recording_continuerecording ) -{ - char *rzx_filename; - int error; - - if( rzx_playback || rzx_recording ) return; - - fuse_emulation_pause(); - - rzx_filename = ui_get_open_filename( "Fuse - Continue Recording" ); - if( !rzx_filename ) { fuse_emulation_unpause(); return; } - - error = rzx_continue_recording( rzx_filename ); - - if( error != LIBSPECTRUM_ERROR_NONE ) { - ui_error( UI_ERROR_WARNING, "RZX file cannot be continued" ); - } - - libspectrum_free( rzx_filename ); - - fuse_emulation_unpause(); -} - -MENU_CALLBACK( menu_file_aylogging_record ) -{ - char *psgfile; - - if( psg_recording ) return; - - fuse_emulation_pause(); - - psgfile = ui_get_save_filename( "Fuse - Start AY Log" ); - if( !psgfile ) { fuse_emulation_unpause(); return; } - - psg_start_recording( psgfile ); - - libspectrum_free( psgfile ); - - display_refresh_all(); - - ui_menu_activate( UI_MENU_ITEM_AY_LOGGING, 1 ); - - fuse_emulation_unpause(); -} - -int -menu_check_media_changed( void ) -{ - int confirm, i; - - confirm = tape_close(); if( confirm ) return 1; - - confirm = ui_media_drive_eject_all(); - if( confirm ) return 1; - - for( i = 0; i < 8; i++ ) { - confirm = if1_mdr_eject( i ); - if( confirm ) return 1; - } - - if( settings_current.simpleide_master_file ) { - confirm = simpleide_eject( LIBSPECTRUM_IDE_MASTER ); - if( confirm ) return 1; - } - - if( settings_current.simpleide_slave_file ) { - confirm = simpleide_eject( LIBSPECTRUM_IDE_SLAVE ); - if( confirm ) return 1; - } - - if( settings_current.zxatasp_master_file ) { - confirm = zxatasp_eject( LIBSPECTRUM_IDE_MASTER ); - if( confirm ) return 1; - } - - if( settings_current.zxatasp_slave_file ) { - confirm = zxatasp_eject( LIBSPECTRUM_IDE_SLAVE ); - if( confirm ) return 1; - } - - if( settings_current.zxcf_pri_file ) { - confirm = zxcf_eject(); if( confirm ) return 1; - } - - if( settings_current.divide_master_file ) { - confirm = divide_eject( LIBSPECTRUM_IDE_MASTER ); - if( confirm ) return 1; - } - - if( settings_current.divide_slave_file ) { - confirm = divide_eject( LIBSPECTRUM_IDE_SLAVE ); - if( confirm ) return 1; - } - - if( settings_current.divmmc_file ) { - confirm = divmmc_eject(); - if( confirm ) return 1; - } - - if( settings_current.zxmmc_file ) { - confirm = zxmmc_eject(); - if( confirm ) return 1; - } - - return 0; -} - -static int -menu_select_machine_roms( libspectrum_machine machine, size_t start, size_t n ) -{ - return menu_select_roms_with_title( libspectrum_machine_name( machine ), - start, n, 0 ); -} - -static int -menu_select_peripheral_roms( const char *peripheral_name, size_t start, size_t n ) -{ - return menu_select_roms_with_title( peripheral_name, - start, n, 1 ); -} - -const char* -menu_machine_detail( void ) -{ - return libspectrum_machine_name( machine_current->machine ); -} - -const char* -menu_filter_detail( void ) -{ - return scaler_name(current_scaler); -} - -const char* -menu_keyboard_joystick_detail( void ) -{ - return joystick_name[ settings_current.joystick_keyboard_output ]; -} - -const char* -menu_joystick_1_detail( void ) -{ - return joystick_name[ settings_current.joystick_1_output ]; -} - -const char* -menu_joystick_2_detail( void ) -{ - return joystick_name[ settings_current.joystick_2_output ]; -} - -const char* -menu_tape_detail( void ) -{ - if( !tape_present() ) return "Not inserted"; - - if( tape_is_playing() ) return "Playing"; - else return "Stopped"; -} - -static const char * const disk_detail_str[] = { - "Inserted", - "Inserted WP", - "Inserted UD", - "Inserted WP,UD", - - "*Inserted", - "*Inserted WP", - "*Inserted UD", - "*Inserted WP,UD", - "Not inserted", -}; - -static const char* -menu_disk_detail( fdd_t *f ) -{ - int i = 0; - - if( !f->loaded ) return disk_detail_str[8]; - if( f->wrprot ) i = 1; - if( f->upsidedown ) i += 2; - if( f->disk.dirty ) i += 4; - return disk_detail_str[i]; -} - -const char* -menu_plus3a_detail( void ) -{ - fdd_t *f = specplus3_get_fdd( SPECPLUS3_DRIVE_A ); - - return menu_disk_detail( f ); -} - -const char* -menu_plus3b_detail( void ) -{ - fdd_t *f = specplus3_get_fdd( SPECPLUS3_DRIVE_B ); - - return menu_disk_detail( f ); -} - -const char* -menu_beta128a_detail( void ) -{ - fdd_t *f = beta_get_fdd( BETA_DRIVE_A ); - - return menu_disk_detail( f ); -} - -const char* -menu_beta128b_detail( void ) -{ - fdd_t *f = beta_get_fdd( BETA_DRIVE_B ); - - return menu_disk_detail( f ); -} - -const char* -menu_beta128c_detail( void ) -{ - fdd_t *f = beta_get_fdd( BETA_DRIVE_C ); - - return menu_disk_detail( f ); -} - -const char* -menu_beta128d_detail( void ) -{ - fdd_t *f = beta_get_fdd( BETA_DRIVE_D ); - - return menu_disk_detail( f ); -} - -const char* -menu_opus1_detail( void ) -{ - fdd_t *f = opus_get_fdd( OPUS_DRIVE_1 ); - - return menu_disk_detail( f ); -} - -const char* -menu_opus2_detail( void ) -{ - fdd_t *f = opus_get_fdd( OPUS_DRIVE_2 ); - - return menu_disk_detail( f ); -} - -const char* -menu_plusd1_detail( void ) -{ - fdd_t *f = plusd_get_fdd( PLUSD_DRIVE_1 ); - - return menu_disk_detail( f ); -} - -const char* -menu_plusd2_detail( void ) -{ - fdd_t *f = plusd_get_fdd( PLUSD_DRIVE_2 ); - - return menu_disk_detail( f ); -} - -const char* -menu_didaktik_a_detail( void ) -{ - fdd_t *f = didaktik80_get_fdd( DIDAKTIK80_DRIVE_A ); - - return menu_disk_detail( f ); -} - -const char* -menu_didaktik_b_detail( void ) -{ - fdd_t *f = didaktik80_get_fdd( DIDAKTIK80_DRIVE_B ); - - return menu_disk_detail( f ); -} - -const char* -menu_disciple1_detail( void ) -{ - fdd_t *f = disciple_get_fdd( DISCIPLE_DRIVE_1 ); - - return menu_disk_detail( f ); -} - -const char* -menu_disciple2_detail( void ) -{ - fdd_t *f = disciple_get_fdd( DISCIPLE_DRIVE_2 ); - - return menu_disk_detail( f ); -} - -MENU_CALLBACK( menu_machine_didaktiksnap ) -{ - ui_widget_finish(); - didaktik80_snap = 1; - event_add( 0, z80_nmi_event ); -} diff --git a/fuse/movie.c b/fuse/movie.c deleted file mode 100644 index 5f2aef6..0000000 --- a/fuse/movie.c +++ /dev/null @@ -1,490 +0,0 @@ -/* movie.c: Routines for creating 'movie' with border - Copyright (c) 2006-2015 Gergely Szasz - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#ifdef HAVE_ZLIB_H -#define ZLIB_CONST -#include -#endif - -#include "display.h" -#include "fuse.h" -#include "machine.h" -#include "movie.h" -#include "movie_tables.h" -#include "options.h" -#include "peripherals/scld.h" -#include "screenshot.h" -#include "settings.h" -#include "sound.h" -#include "ui/ui.h" - -#undef MOVIE_DEBUG_PRINT - -/* - FMF - Fuse Movie File - - Fuse Movie File: - File Header: - off len data description - 0 4 "FMF_" Magic header - 4 2 "V1" Version - 6 1 Endianness (e - little / E- big) - 7 1 Compression ( U - uncompressed / Z - zlib compressed ) - 8 1 # Frame rate ( 1:# ) - 9 1 <$|R|C|X> Screen type - 10 1 timing code - 11 1 Sound encoding - 12 2 Freq Sound freq in Hz - 14 1 Sound stereo / mono - 15 1 "\n" padding () - - e.g. FMF_V1eZ\001$AU\000\175M -> little endian compressed normal screen, 48k timing, u-Law mono 32000Hz sound - Data - Frame data header - off len data description - 0 1 <$|S|N|X> Data chunk type - - $ -> screen area (slice) - off len data description - 0 1 x X coord (0-39) - 1 2 y Y coord (0-239) - 3 1 w width (1-40) - 4 2 h height (1-240) - 6 ? runlength encoded data bytes - bitmap1; attrib1 ZX$/TX$/HiCol ($/X/C) - bitmap1; bitmap2; attrib HiR (R) - runlength encoding: - abcdefghbb#gg# -> two identical byte plus len code a #+2 len - - S -> sound chunk - off len data description - 0 1 sound encoding type P-> 16bit signed PCM, U -> u-Law, A -> A-Law - 1 2 Freq sound freq in Hz - 3 1 channels S-> stereo, M-> mono - 4 2 length-1 length in frames (0-65535) -> 1-65536 sound frame - - N -> New Frame - off len data description - 0 1 # frame rate 1:# (1:1 -> ~50/s, 1:2 -> ~25/a ...) - 1 1 <$|R|C|X> screen type $ - standard screen, - R - HiRes, - C - HiColor, - X - standard screen on Timex (double size) - 2 1 frame timing code A - 16, 48, TC2048, TC2068, Scorpion, SE - B - 128, +2, +2A, +3, +3E - C - TS2068 - D - Pentagon - E - 48 NTSC - In a frame there are no, one or several screen rectangle, changed from - the previouse frame. - - X -> End of recording - off len data description - There is no any data... It mark the end of the last frame. So we can - concat several FMF file without any problem... -*/ - -int movie_recording = 0; -static int movie_paused = 0; - -static int frame_no, slice_no; - -static RFILE *of = NULL; /* out file */ -static int fmf_screen; -static libspectrum_byte head[8]; -static int freq = 0; -static char stereo = 'M'; -static char format = '?'; -static int framesiz = 4; - -static libspectrum_byte sbuff[ 4096 ]; -#ifdef HAVE_ZLIB_H -#define ZBUF_SIZE 8192 -static int fmf_compr = -1; -static z_stream zstream; -static unsigned char zbuf_o[ ZBUF_SIZE ]; -#endif /* HAVE_ZLIB_H */ - -static unsigned char alaw_table[2048 + 1] = { ALAW_ENC_TAB }; - -void movie_start_frame( void ); -void movie_init_sound( int f, int s ); - -static char -get_timing( void ) -{ - switch( machine_current->machine ) { - case LIBSPECTRUM_MACHINE_16: - case LIBSPECTRUM_MACHINE_48: - case LIBSPECTRUM_MACHINE_TC2048: - case LIBSPECTRUM_MACHINE_TC2068: - case LIBSPECTRUM_MACHINE_SCORP: - case LIBSPECTRUM_MACHINE_SE: - return 'A'; - case LIBSPECTRUM_MACHINE_128: - case LIBSPECTRUM_MACHINE_PLUS2: - case LIBSPECTRUM_MACHINE_PLUS2A: - case LIBSPECTRUM_MACHINE_PLUS3: - case LIBSPECTRUM_MACHINE_PLUS3E: - return 'B'; - case LIBSPECTRUM_MACHINE_TS2068: - return 'C'; - case LIBSPECTRUM_MACHINE_PENT: - case LIBSPECTRUM_MACHINE_PENT512: - case LIBSPECTRUM_MACHINE_PENT1024: - return 'D'; - case LIBSPECTRUM_MACHINE_48_NTSC: - return 'E'; - case LIBSPECTRUM_MACHINE_UNKNOWN: - default: - return '?'; - } -} - -static char -get_screentype( void ) -{ - if( machine_current->timex ) { /* ALTDFILE and default */ - if( scld_last_dec.name.hires ) - return 'R'; /* HIRES screen */ - else if( scld_last_dec.name.b1 ) - return 'C'; /* HICOLOR screen */ - else - return 'X'; /* STANDARD screen on timex machine */ - } - return '$'; /* STANDARD screen */ -} - -#ifdef HAVE_ZLIB_H -static void -fwrite_compr( const void *b, size_t n, size_t m, RFILE *f ) -{ - if( fmf_compr == 0 ) { - filestream_write( f, b, (int64_t)( n ) * ( m ) ); - } else { - zstream.avail_in = n * m; - zstream.next_in = b; - zstream.avail_out = ZBUF_SIZE; - zstream.next_out = zbuf_o; - do { - deflate( &zstream, Z_NO_FLUSH ); - while( zstream.avail_out != ZBUF_SIZE ) { - filestream_write( of, zbuf_o, (int64_t)( ZBUF_SIZE - zstream.avail_out ) * ( 1 ) ); - zstream.avail_out = ZBUF_SIZE; - zstream.next_out = zbuf_o; - deflate( &zstream, Z_NO_FLUSH ); - } - } while ( zstream.avail_in != 0 ); - } -} -#else /* HAVE_ZLIB_H */ -#define fwrite_compr fwrite -#endif /* HAVE_ZLIB_H */ - -static void -movie_compress_area( int x, int y, int w, int h, int s ) -{ - libspectrum_dword *dpoint, *dline; - libspectrum_byte d, d1, *b; - libspectrum_byte buff[ 960 ]; - int w0, h0, l; - - dline = &display_last_screen[x + 40 * y]; - b = buff; l = -1; - d1 = ( ( *dline >> s ) & 0xff ) + 1; /* *d1 != dpoint :-) */ - - for( h0 = h; h0 > 0; h0--, dline += 40 ) { - dpoint = dline; - for( w0 = w; w0 > 0; w0--, dpoint++) { - d = ( *dpoint >> s ) & 0xff; /* bitmask1 */ - if( d != d1 ) { - if( l > -1 ) { /* save running length 0-255 */ - *b++ = l; - l = -1; /* reset l */ - } - *b++ = d1 = d; - } else if( l >= 0 ) { - if( l == 255 ) { /* close run, and may start a new? */ - *b++ = l; *b++ = d; l = -1; - } else { - l++; - } - } else { - *b++ = d; - l++; - } -/* d1 = d; */ - } - if( b - buff > 960 - 128 ) { /* worst case 40*1.5 per line */ - fwrite_compr( buff, b - buff, 1, of ); - b = buff; - } - } - if( l > -1 ) { /* save running length 0-255 */ - *b++ = l; - } - if( b != buff ) { /* dump remain */ - fwrite_compr( buff, b - buff, 1, of ); - } -} - -/* Fetch pixel (x, y). On a Timex this will be a point on a 640x480 canvas, - on a Sinclair/Amstrad/Russian clone this will be a point on a 320x240 - canvas */ - -/* x: 0 - 39; y: 0 - 239 */ - -/* abcdefghijkl... cc# where # mean cc + # c char*/ - -void -movie_add_area( int x, int y, int w, int h ) -{ - if( movie_paused ) { - movie_start_frame(); - return; - } - head[0] = '$'; /* RLE compressed data... */ - head[1] = x; - head[2] = y & 0xff; - head[3] = y >> 8; - head[4] = w; - head[5] = h & 0xff; - head[6] = h >> 8; - fwrite_compr( head, 7, 1, of ); - movie_compress_area( x, y, w, h, 0 ); /* Bitmap1 */ - movie_compress_area( x, y, w, h, 8 ); /* Attrib/B2 */ - if( fmf_screen == 'R' ) { - movie_compress_area( x, y, w, h, 16 ); /* HiRes attrib */ - } - slice_no++; -} - -static void -movie_start_fmf( const char *name ) -{ - if( ( of = filestream_open( name, RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE ) ) == NULL ) { /* trunc old file ? or append ? */ - ui_error( UI_ERROR_ERROR, "error opening movie file '%s': %s", name, - strerror( errno ) ); - return; - } -#ifdef WORDS_BIGENDIAN - filestream_write( of, "FMF_V1E", (int64_t)( 7 ) * ( 1 ) ); /* write magic header Fuse Movie File */ -#else /* WORDS_BIGENDIAN */ - filestream_write( of, "FMF_V1e", (int64_t)( 7 ) * ( 1 ) ); /* write magic header Fuse Movie File */ -#endif /* WORDS_BIGENDIAN */ -#ifdef HAVE_ZLIB_H - if( option_enumerate_movie_movie_compr() == 0 ) { - fmf_compr = 0; - filestream_write( of, "U", 1 ); /* not compressed */ - } else { - fmf_compr = Z_DEFAULT_COMPRESSION; - filestream_write( of, "Z", 1 ); /* compressed */ - } - if( fmf_compr != 0 ) { - zstream.zalloc = Z_NULL; - zstream.zfree = Z_NULL; - zstream.opaque = Z_NULL; - zstream.avail_in = 0; - zstream.next_in = Z_NULL; - deflateInit( &zstream, fmf_compr ); - } -#else /* HAVE_ZLIB_H */ - filestream_write( of, "U", 1 ); /* cannot be compressed */ -#endif /* HAVE_ZLIB_H */ - movie_init_sound( settings_current.sound_freq, - sound_stereo_ay != SOUND_STEREO_AY_NONE ); - head[0] = settings_current.frame_rate; - head[1] = get_screentype(); - head[2] = get_timing(); - head[3] = format; /* sound format */ - head[4] = freq & 0xff; - head[5] = freq >> 8; - head[6] = stereo; - head[7] = '\n'; /* padding */ - filestream_write( of, head, (int64_t)( 8 ) * ( 1 ) ); /* write initial params */ - movie_add_area( 0, 0, 40, 240 ); -} - -void -movie_start( const char *name ) /* some init, open file (name)*/ -{ - frame_no = slice_no = 0; - if( name == NULL || *name == '\0' ) - name = "fuse.fmf"; /* fuse movie file */ - - movie_start_fmf( name ); - movie_recording = 1; - ui_menu_activate( UI_MENU_ITEM_FILE_MOVIE_RECORDING, 1 ); - ui_menu_activate( UI_MENU_ITEM_FILE_MOVIE_PAUSE, 1 ); -} - -void -movie_stop( void ) -{ - if( !movie_paused && !movie_recording ) return; - - fwrite_compr( "X", 1, 1, of ); /* End of Recording! */ -#ifdef HAVE_ZLIB_H - { - if( fmf_compr != 0 ) { /* close zlib */ - zstream.avail_in = 0; - do { - zstream.avail_out = ZBUF_SIZE; - zstream.next_out = zbuf_o; - deflate( &zstream, Z_SYNC_FLUSH ); - if( zstream.avail_out != ZBUF_SIZE ) - filestream_write( of, zbuf_o, (int64_t)( ZBUF_SIZE - zstream.avail_out ) * ( 1 ) ); - } while ( zstream.avail_out != ZBUF_SIZE ); - deflateEnd( &zstream ); - fmf_compr = -1; - } - } -#endif /* HAVE_ZLIB_H */ - format = '?'; - if( of ) { - filestream_close( of ); - of = NULL; - } -#ifdef MOVIE_DEBUG_PRINT - filestream_printf( stderr, "Debug movie: saved %d.%d frame(.slice)\n", frame_no, slice_no ); -#endif /* MOVIE_DEBUG_PRINT */ - movie_recording = 0; - movie_paused = 0; - ui_menu_activate( UI_MENU_ITEM_FILE_MOVIE_RECORDING, 0 ); -} - -void -movie_pause( void ) -{ - if( !movie_paused && !movie_recording ) return; - - if( movie_recording ) { - movie_recording = 0; - movie_paused = 1; - ui_menu_activate( UI_MENU_ITEM_FILE_MOVIE_PAUSE, 0 ); - } else { - movie_recording = 1; - movie_paused = 1; - ui_menu_activate( UI_MENU_ITEM_FILE_MOVIE_PAUSE, 1 ); - } -} - -void -movie_init_sound( int f, int s ) -{ - /* initialise sound format */ - format = option_enumerate_movie_movie_compr() == 2 ? 'A' : 'P'; - freq = f; - stereo = ( s ? 'S' : 'M' ); - framesiz = ( stereo == 'S' ? 2 : 1 ) * ( format == 'P' ? 2 : 1 ); -} - -static inline void -write_alaw( libspectrum_signed_word *buff, int len ) -{ - int i = 0; - while( len-- ) { - if( *buff >= 0) - sbuff[i++] = alaw_table[*buff >> 4]; - else - sbuff[i++] = 0x7f & alaw_table [- *buff >> 4]; - buff++; - if( i == 4096 ) { - i = 0; - fwrite_compr( sbuff, 4096, 1, of ); /* write frame */ - } - } - if( i ) - fwrite_compr( sbuff, i, 1, of ); /* write remaind */ -} - -static void -add_sound( libspectrum_signed_word *buff, int len ) -{ - head[0] = 'S'; /* sound frame */ - head[1] = format; /* sound format */ - head[2] = freq & 0xff; - head[3] = freq >> 8; - head[4] = stereo; - len--; /*len - 1*/ - head[5] = len & 0xff; - head[6] = len >> 8; - len++; /* len :-) */ - fwrite_compr( head, 7, 1, of ); /* Sound frame */ - if( format == 'P' ) - fwrite_compr( buff, len * framesiz , 1, of ); /* write frame */ - else if( format == 'A' ) - write_alaw( buff, len * framesiz ); -} - -void -movie_add_sound( libspectrum_signed_word *buff, int len ) -{ - while( len ) { - if( stereo == 'S' ) { - add_sound( buff, len > 131072 ? 65536 : len >> 1 ); - buff += len > 131072 ? 131072 : len; - len -= len > 131072 ? 131072 : len; - } else { - add_sound( buff, len > 65536 ? 65536 : len ); - buff += len > 65536 ? 65536 : len; - len -= len > 65536 ? 65536 : len; - } - } -} - -void -movie_start_frame( void ) -{ - /* $ - ZX$, T - TX$, C - HiCol, R - HiRes */ - head[0] = 'N'; - head[1] = settings_current.frame_rate; - head[2] = get_screentype(); - head[3] = get_timing(); - fwrite_compr( head, 4, 1, of ); /* New frame! */ - frame_no++; - if( movie_paused ) { - movie_paused = 0; - movie_add_area( 0, 0, 40, 240 ); - } -} - -void -movie_init( void ) -{ - /* start movie recording if user requested... */ - if( settings_current.movie_start ) - movie_start( settings_current.movie_start ); -} diff --git a/fuse/movie.h b/fuse/movie.h deleted file mode 100644 index bd60fb3..0000000 --- a/fuse/movie.h +++ /dev/null @@ -1,36 +0,0 @@ -/* movie.h: header for movie.c - Copyright (c) 2006 Gergely Szasz - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -/* - FSMF - Fuse Spectrum Movie File -*/ -extern int movie_recording; - -void movie_init( void ); -void movie_start( const char *name ); -void movie_stop( void ); -void movie_pause( void ); -void movie_add_area( int x, int y, int w, int h ); -void movie_start_frame( void ); -void movie_init_sound( int f, int s ); -void movie_add_sound( libspectrum_signed_word *buf, int len ); diff --git a/fuse/profile.c b/fuse/profile.c deleted file mode 100644 index 4ef99d1..0000000 --- a/fuse/profile.c +++ /dev/null @@ -1,151 +0,0 @@ -/* profile.c: Z80 profiler - Copyright (c) 2005-2016 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: Philip Kendall - -*/ - -#include -#include - -#include -#include - -#include - -#include "event.h" -#include "infrastructure/startup_manager.h" -#include "module.h" -#include "profile.h" -#include "ui/ui.h" -#include "z80/z80.h" - -int profile_active = 0; - -static int total_tstates[ 0x10000 ]; -static libspectrum_word profile_last_pc; -static libspectrum_dword profile_last_tstates; - -static void profile_from_snapshot( libspectrum_snap *snap GCC_UNUSED ); - -static module_info_t profile_module_info = { - - NULL, - NULL, - NULL, - profile_from_snapshot, - NULL, - -}; - -static int -profile_init( void *context ) -{ - module_register( &profile_module_info ); - - return 0; -} - -void -profile_register_startup( void ) -{ - startup_manager_module dependencies[] = { STARTUP_MANAGER_MODULE_SETUID }; - startup_manager_register( STARTUP_MANAGER_MODULE_PROFILE, dependencies, - ARRAY_SIZE( dependencies ), profile_init, NULL, - NULL ); -} - -static void -init_profiling_counters( void ) -{ - profile_last_pc = z80.pc.w; - profile_last_tstates = tstates; -} - -void -profile_start( void ) -{ - memset( total_tstates, 0, sizeof( total_tstates ) ); - - profile_active = 1; - init_profiling_counters(); - - /* Schedule an event to ensure that the main z80 emulation loop recognises - profiling is turned on; otherwise problems occur if we started while - the debugger was active (bug #54) */ - event_add( tstates, event_type_null ); - - ui_menu_activate( UI_MENU_ITEM_MACHINE_PROFILER, 1 ); -} - -void -profile_map( libspectrum_word pc ) -{ - total_tstates[ profile_last_pc ] += tstates - profile_last_tstates; - - profile_last_pc = z80.pc.w; - profile_last_tstates = tstates; -} - -void -profile_frame( libspectrum_dword frame_length ) -{ - profile_last_tstates -= frame_length; -} - -/* On snapshot load, PC and the tstate counter will jump so reset our - current views of these */ -static void -profile_from_snapshot( libspectrum_snap *snap GCC_UNUSED ) -{ - init_profiling_counters(); -} - -void -profile_finish( const char *filename ) -{ - RFILE *f; - size_t i; - - f = filestream_open( filename, RETRO_VFS_FILE_ACCESS_WRITE, - RETRO_VFS_FILE_ACCESS_HINT_NONE ); - if( !f ) { - ui_error( UI_ERROR_ERROR, "unable to open profile map '%s' for writing", - filename ); - return; - } - - for( i = 0; i < 0x10000; i++ ) { - - if( !total_tstates[ i ] ) continue; - - filestream_printf( f, "0x%04lx,%d\n", (unsigned long)i, total_tstates[ i ] ); - - } - - filestream_close( f ); - - profile_active = 0; - - /* Again, schedule an event to ensure this change is picked up by - the main loop */ - event_add( tstates, event_type_null ); - - ui_menu_activate( UI_MENU_ITEM_MACHINE_PROFILER, 0 ); -} diff --git a/fuse/profile.h b/fuse/profile.h deleted file mode 100644 index cc666c1..0000000 --- a/fuse/profile.h +++ /dev/null @@ -1,35 +0,0 @@ -/* profile.h: Z80 profiler - Copyright (c) 2005-2016 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: Philip Kendall - -*/ - -#ifndef FUSE_PROFILE_H -#define FUSE_PROFILE_H - -extern int profile_active; - -void profile_register_startup( void ); -void profile_start( void ); -void profile_map( libspectrum_word pc ); -void profile_frame( libspectrum_dword frame_length ); -void profile_finish( const char *filename ); - -#endif /* #ifndef FUSE_PROFILE_H */ diff --git a/fuse/rzx.c b/fuse/rzx.c index 4fda7a6..4ba61bd 100644 --- a/fuse/rzx.c +++ b/fuse/rzx.c @@ -38,7 +38,6 @@ #include "fuse.h" #include "infrastructure/startup_manager.h" #include "machine.h" -#include "movie.h" #include "peripherals/ula.h" #include "rzx.h" #include "settings.h" @@ -193,7 +192,6 @@ int rzx_stop_recording( void ) /* Stop recording data */ rzx_recording = 0; - if( settings_current.movie_stop_after_rzx ) movie_stop(); /* Embed final snapshot */ if( !rzx_competition_mode ) rzx_add_snap( rzx, 0 ); @@ -392,7 +390,6 @@ int rzx_stop_playback( int add_interrupt ) if( !rzx_playback ) return 0; rzx_playback = 0; - if( settings_current.movie_stop_after_rzx ) movie_stop(); ui_menu_activate( UI_MENU_ITEM_RECORDING, 0 ); ui_menu_activate( UI_MENU_ITEM_RECORDING_ROLLBACK, 0 ); diff --git a/fuse/screenshot.c b/fuse/screenshot.c deleted file mode 100644 index 672e7b0..0000000 --- a/fuse/screenshot.c +++ /dev/null @@ -1,708 +0,0 @@ -/* screenshot.c: Routines for handling .png and .scr screenshots - Copyright (c) 2002-2018 Philip Kendall, Fredrick Meunier - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include -#include - -#include -#include -#include - -#include - -#include "display.h" -#include "infrastructure/startup_manager.h" -#include "machine.h" -#include "peripherals/scld.h" -#include "screenshot.h" -#include "settings.h" -#include "ui/scaler/scaler.h" -#include "ui/ui.h" -#include "utils.h" - -#define MONO_BITMAP_SIZE 6144 -#define HICOLOUR_SCR_SIZE (2 * MONO_BITMAP_SIZE) -#define MLT_SIZE (2 * MONO_BITMAP_SIZE) -#define HIRES_ATTR HICOLOUR_SCR_SIZE -#define HIRES_SCR_SIZE (HICOLOUR_SCR_SIZE + 1) - -#ifdef USE_LIBPNG - -#include -#ifdef HAVE_ZLIB_H -#define ZLIB_CONST -#include -#endif /* #ifdef HAVE_ZLIB_H */ - -static int get_rgb32_data( libspectrum_byte *rgb32_data, size_t stride, - size_t height, size_t width ); -static int rgb32_to_rgb24( libspectrum_byte *rgb24_data, size_t rgb24_stride, - libspectrum_byte *rgb32_data, size_t rgb32_stride, - size_t height, size_t width ); -static void fill_rgb32_margin( libspectrum_byte *rgb32_data, size_t stride, - size_t height, size_t width ); - -/* The biggest size screen (in units of DISPLAY_ASPECT_WIDTH x - DISPLAY_SCREEN_HEIGHT ie a Timex screen is size 2) we will be - creating via the scalers */ -#define MAX_SIZE 4 - -/* Pixels arround the RGB image for scalers that "smear" the screen */ -#define K_MARGIN 2 - -/* The space used for drawing the screen image on */ -static libspectrum_byte *rgb_data = NULL; -static libspectrum_byte *scaled_data; -static libspectrum_byte *png_data = NULL; - -int -screenshot_write( const char *filename, scaler_type scaler ) -{ - RFILE *f; - - png_structp png_ptr; - png_infop info_ptr; - - libspectrum_byte *row_pointers[ MAX_SIZE * DISPLAY_SCREEN_HEIGHT ]; - libspectrum_byte *rgb_data_centered; - size_t rgb_stride = ( DISPLAY_ASPECT_WIDTH + K_MARGIN * 2 ) * 4, - scaled_stride = MAX_SIZE * DISPLAY_ASPECT_WIDTH * 4, - png_stride = MAX_SIZE * DISPLAY_ASPECT_WIDTH * 3; - size_t y, base_height, base_width, height, width; - int error; - - if( machine_current->timex ) { - base_height = 2 * DISPLAY_SCREEN_HEIGHT; - base_width = DISPLAY_SCREEN_WIDTH; - } else { - base_height = DISPLAY_SCREEN_HEIGHT; - base_width = DISPLAY_ASPECT_WIDTH; - } - - /* Allocate buffers on demand */ - if( !rgb_data ) - rgb_data = - libspectrum_new( libspectrum_byte, - ( DISPLAY_SCREEN_HEIGHT + K_MARGIN * 2 ) * rgb_stride ); - - if( !scaled_data ) - scaled_data = libspectrum_new( libspectrum_byte, - MAX_SIZE * DISPLAY_SCREEN_HEIGHT * - scaled_stride ); - - if( !png_data ) - png_data = libspectrum_new( libspectrum_byte, - MAX_SIZE * DISPLAY_SCREEN_HEIGHT * png_stride ); - - /* first pixel of rgb_data (without margin) */ - rgb_data_centered = rgb_data + K_MARGIN * rgb_stride + K_MARGIN * 4; - - /* Change from paletted data to RGB data */ - error = get_rgb32_data( rgb_data_centered, rgb_stride, base_height, - base_width ); - if( error ) return error; - - /* Initialise margin for scalers that "smear" the screen */ - if( scaler_get_flags( scaler ) & SCALER_FLAGS_EXPAND ) - fill_rgb32_margin( rgb_data, rgb_stride, base_height, base_width ); - - /* Actually scale the data here */ - scaler_get_proc32( scaler )( rgb_data_centered, rgb_stride, scaled_data, - scaled_stride, base_width, base_height ); - - height = base_height * scaler_get_scaling_factor( scaler ); - width = base_width * scaler_get_scaling_factor( scaler ); - - /* Reduce from RGB(padding byte) to just RGB */ - error = rgb32_to_rgb24( png_data, png_stride, scaled_data, scaled_stride, - height, width ); - if( error ) return error; - - for( y = 0; y < height; y++ ) - row_pointers[y] = &png_data[ y * png_stride ]; - - f = filestream_open( filename, RETRO_VFS_FILE_ACCESS_WRITE, - RETRO_VFS_FILE_ACCESS_HINT_NONE ); - if( !f ) { - ui_error( UI_ERROR_ERROR, "Couldn't open `%s': %s", filename, - strerror( errno ) ); - return 1; - } - - png_ptr = png_create_write_struct( PNG_LIBPNG_VER_STRING, - NULL, NULL, NULL ); - if( !png_ptr ) { - ui_error( UI_ERROR_ERROR, "Couldn't allocate png_ptr" ); - filestream_close( f ); - return 1; - } - - info_ptr = png_create_info_struct( png_ptr ); - if( !info_ptr ) { - ui_error( UI_ERROR_ERROR, "Couldn't allocate info_ptr" ); - png_destroy_write_struct( &png_ptr, NULL ); - filestream_close( f ); - return 1; - } - - /* Set up the error handling; libpng will return to here if it - encounters an error */ - if( setjmp( png_jmpbuf( png_ptr ) ) ) { - ui_error( UI_ERROR_ERROR, "Error from libpng" ); - png_destroy_write_struct( &png_ptr, &info_ptr ); - filestream_close( f ); - return 1; - } - - png_init_io( png_ptr, f ); - - /* Make files as small as possible */ - png_set_compression_level( png_ptr, Z_BEST_COMPRESSION ); - - png_set_IHDR( png_ptr, info_ptr, - width, height, 8, - PNG_COLOR_TYPE_RGB, - PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT ); - - png_set_rows( png_ptr, info_ptr, row_pointers ); - - png_write_png( png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL ); - - png_destroy_write_struct( &png_ptr, &info_ptr ); - - if( filestream_close( f ) ) { - ui_error( UI_ERROR_ERROR, "Couldn't close `%s': %s", filename, - strerror( errno ) ); - return 1; - } - - return 0; -} - -static int -get_rgb32_data( libspectrum_byte *rgb32_data, size_t stride, - size_t height, size_t width ) -{ - size_t i, x, y; - - static const /* R G B */ - libspectrum_byte palette[16][3] = { { 0, 0, 0 }, - { 0, 0, 192 }, - { 192, 0, 0 }, - { 192, 0, 192 }, - { 0, 192, 0 }, - { 0, 192, 192 }, - { 192, 192, 0 }, - { 192, 192, 192 }, - { 0, 0, 0 }, - { 0, 0, 255 }, - { 255, 0, 0 }, - { 255, 0, 255 }, - { 0, 255, 0 }, - { 0, 255, 255 }, - { 255, 255, 0 }, - { 255, 255, 255 } }; - - libspectrum_byte grey_palette[16]; - - /* Addition of 0.5 is to avoid rounding errors */ - for( i = 0; i < 16; i++ ) - grey_palette[i] = ( 0.299 * palette[i][0] + - 0.587 * palette[i][1] + - 0.114 * palette[i][2] ) + 0.5; - - for( y = 0; y < height; y++ ) { - for( x = 0; x < width; x++ ) { - - size_t colour; - libspectrum_byte red, green, blue; - - colour = display_getpixel( x, y ); - - if( settings_current.bw_tv ) { - - red = green = blue = grey_palette[colour]; - - } else { - - red = palette[colour][0]; - green = palette[colour][1]; - blue = palette[colour][2]; - - } - - rgb32_data[ y * stride + 4 * x ] = red; - rgb32_data[ y * stride + 4 * x + 1 ] = green; - rgb32_data[ y * stride + 4 * x + 2 ] = blue; - rgb32_data[ y * stride + 4 * x + 3 ] = 0; /* padding */ - - } - } - - return 0; -} - -static void -fill_rgb32_margin( libspectrum_byte *rgb32_data, size_t stride, - size_t height, size_t width ) -{ - size_t x_dest, y_dest, x_src, y_src; - libspectrum_byte *dest_data, *src_data; - - /* We need to initialise the extra space available for scalers that "smear" - the screen by copying the nearest neighbour, so we avoid any blending with - black colour or memory garbage at the outer border */ - - /* Fill top margin */ - y_src = K_MARGIN; - for( y_dest = 0; y_dest < K_MARGIN; y_dest++ ) { - for( x_dest = 0; x_dest < width + K_MARGIN * 2; x_dest++ ) { - - if( x_dest < K_MARGIN ) - x_src = K_MARGIN; - else if( x_dest >= K_MARGIN + width ) - x_src = K_MARGIN + width - 1; - else - x_src = x_dest; - - dest_data = rgb32_data + y_dest * stride + 4 * x_dest; - src_data = rgb32_data + y_src * stride + 4 * x_src; - *(libspectrum_dword*) dest_data = *(libspectrum_dword*) src_data; - } - } - - /* Fill left margin */ - x_src = K_MARGIN; - for( y_dest = K_MARGIN; y_dest < K_MARGIN + height; y_dest++ ) { - for( x_dest = 0; x_dest < K_MARGIN; x_dest++ ) { - y_src = y_dest; - - dest_data = rgb32_data + y_dest * stride + 4 * x_dest; - src_data = rgb32_data + y_src * stride + 4 * x_src; - *(libspectrum_dword*) dest_data = *(libspectrum_dword*) src_data; - } - } - - /* Fill right margin */ - x_src = K_MARGIN + width -1; - for( y_dest = K_MARGIN; y_dest < K_MARGIN + height; y_dest++ ) { - for( x_dest = K_MARGIN + width; x_dest < K_MARGIN * 2 + width; x_dest++ ) { - y_src = y_dest; - - dest_data = rgb32_data + y_dest * stride + 4 * x_dest; - src_data = rgb32_data + y_src * stride + 4 * x_src; - *(libspectrum_dword*) dest_data = *(libspectrum_dword*) src_data; - } - } - - /* Fill bottom margin */ - y_src = K_MARGIN + height - 1; - for( y_dest = K_MARGIN + height; y_dest < height + K_MARGIN * 2; y_dest++ ) { - for( x_dest = 0; x_dest < width + K_MARGIN * 2; x_dest++ ) { - - if( x_dest < K_MARGIN ) - x_src = K_MARGIN; - else if( x_dest >= K_MARGIN + width ) - x_src = K_MARGIN + width - 1; - else - x_src = x_dest; - - dest_data = rgb32_data + y_dest * stride + 4 * x_dest; - src_data = rgb32_data + y_src * stride + 4 * x_src; - *(libspectrum_dword*) dest_data = *(libspectrum_dword*) src_data; - } - } -} - -static int -rgb32_to_rgb24( libspectrum_byte *rgb24_data, size_t rgb24_stride, - libspectrum_byte *rgb32_data, size_t rgb32_stride, - size_t height, size_t width ) -{ - size_t x, y; - - for( y = 0; y < height; y++ ) { - for( x = 0; x < width; x++ ) { - rgb24_data[y*rgb24_stride +3*x ] = rgb32_data[y*rgb32_stride +4*x ]; - rgb24_data[y*rgb24_stride +3*x +1] = rgb32_data[y*rgb32_stride +4*x +1]; - rgb24_data[y*rgb24_stride +3*x +2] = rgb32_data[y*rgb32_stride +4*x +2]; - } - } - - return 0; -} - -int -screenshot_available_scalers( scaler_type scaler ) -{ - if( machine_current->timex ) { - - switch( scaler ) { - - case SCALER_HALF: case SCALER_HALFSKIP: case SCALER_NORMAL: - case SCALER_TIMEX1_5X: case SCALER_TIMEX2X: - case SCALER_TIMEXTV: case SCALER_PALTV: - return 1; - default: - return 0; - - } - - } else { - - switch( scaler ) { - - case SCALER_NORMAL: case SCALER_DOUBLESIZE: case SCALER_TRIPLESIZE: case SCALER_QUADSIZE: - case SCALER_2XSAI: case SCALER_SUPER2XSAI: case SCALER_SUPEREAGLE: - case SCALER_ADVMAME2X: case SCALER_ADVMAME3X: - case SCALER_TV2X: case SCALER_TV3X: case SCALER_TV4X: case SCALER_DOTMATRIX: - case SCALER_PALTV: case SCALER_PALTV2X: case SCALER_PALTV3X: case SCALER_PALTV4X: - case SCALER_HQ2X: case SCALER_HQ3X: case SCALER_HQ4X: - return 1; - default: - return 0; - - } - } -} - -#endif /* #ifdef USE_LIBPNG */ - -static void -screenshot_end( void ) -{ -#ifdef USE_LIBPNG - libspectrum_free( rgb_data ); rgb_data = NULL; - libspectrum_free( scaled_data ); scaled_data = NULL; - libspectrum_free( png_data ); png_data = NULL; -#endif -} - -void -screenshot_register_startup( void ) -{ - startup_manager_module dependencies[] = { STARTUP_MANAGER_MODULE_SETUID }; - startup_manager_register( STARTUP_MANAGER_MODULE_SCREENSHOT, dependencies, - ARRAY_SIZE( dependencies ), NULL, NULL, - screenshot_end ); -} - -static int -screenshot_scr_hires_write( const char *filename ) -{ - libspectrum_byte scr_data[ HIRES_SCR_SIZE ]; - - memset( scr_data, 0, HIRES_SCR_SIZE ); - - memcpy( scr_data, - &RAM[ memory_current_screen ][ display_get_addr(0,0) ], - MONO_BITMAP_SIZE ); - memcpy( scr_data + MONO_BITMAP_SIZE, - &RAM[ memory_current_screen ][ display_get_addr(0,0) + - ALTDFILE_OFFSET], MONO_BITMAP_SIZE ); - scr_data[ HIRES_ATTR ] = ( scld_last_dec.byte & HIRESCOLMASK ) | - scld_last_dec.mask.scrnmode; - - return utils_write_file( filename, scr_data, HIRES_SCR_SIZE ); -} - -static int -get_display_last_screen_index( int x, int y ) -{ - int beam_x = x + DISPLAY_BORDER_WIDTH_COLS; - int beam_y = y + DISPLAY_BORDER_HEIGHT; - - return beam_x + beam_y * DISPLAY_SCREEN_WIDTH_COLS; -} - -static void -set_hicolor_pixels_and_attribute( int x, int y, libspectrum_byte* scr_data ) -{ - int index = get_display_last_screen_index( x, y ); - libspectrum_byte pixel_data = display_last_screen[ index ] & 0xff; - libspectrum_byte attribute_data = (display_last_screen[ index ] & 0xff00)>>8; - - libspectrum_word offset = display_get_offset( x, y ); - scr_data[ offset ] = pixel_data; - /* write attribute into bitmap order buffer after bitmap */ - scr_data[ MONO_BITMAP_SIZE + offset ] = attribute_data; -} - -typedef void (*data_write_fn)( int x, int y, libspectrum_byte* scr_data ); - -static int -scr_write( const char *filename, const int data_size, - data_write_fn scr_data_write ) -{ - libspectrum_byte scr_data[ data_size ]; - int x, y; - - memset( scr_data, 0, data_size ); - - for( y = 0; y < DISPLAY_HEIGHT; y++ ) { - for( x = 0; x < DISPLAY_WIDTH_COLS; x++ ) { - scr_data_write( x, y, scr_data ); - } - } - - return utils_write_file( filename, scr_data, data_size ); -} - -static void -set_standard_pixels_and_attribute( int x, int y, libspectrum_byte* scr_data ) -{ - int index = get_display_last_screen_index( x, y ); - libspectrum_byte pixel_data = display_last_screen[ index ] & 0xff; - libspectrum_byte attribute_data = (display_last_screen[ index ] & 0xff00)>>8; - int attribute_offset; - - scr_data[ display_get_offset( x, y ) ] = pixel_data; - - if( y%8 == 0 ) { - /* write attribute into standard attribute order buffer after bitmap */ - attribute_offset = x + (y/8 * DISPLAY_WIDTH_COLS); - scr_data[ MONO_BITMAP_SIZE + attribute_offset ] = attribute_data; - } -} - -int -screenshot_scr_write( const char *filename ) -{ - if( scld_last_dec.name.hires ) { - return screenshot_scr_hires_write( filename ); - } - else if( scld_last_dec.name.b1 ) { - return scr_write( filename, HICOLOUR_SCR_SIZE, - &set_hicolor_pixels_and_attribute ); - } - else { /* ALTDFILE and default */ - return scr_write( filename, STANDARD_SCR_SIZE, - &set_standard_pixels_and_attribute ); - } -} - -static void -set_mlt_pixels_and_attribute( int x, int y, libspectrum_byte* mlt_data ) -{ - int index = get_display_last_screen_index( x, y ); - libspectrum_byte pixel_data = display_last_screen[ index ] & 0xff; - libspectrum_byte attribute_data = (display_last_screen[ index ] & 0xff00)>>8; - - mlt_data[ display_get_offset( x, y ) ] = pixel_data; - /* write attribute into linear buffer following bitmap */ - mlt_data[ MONO_BITMAP_SIZE + x + y * DISPLAY_WIDTH_COLS ] = attribute_data; -} - -int -screenshot_mlt_write( const char *filename ) -{ - if( machine_current->timex && scld_last_dec.name.hires ) { - ui_error( UI_ERROR_ERROR, - "MLT format not supported for Timex hi-res screen mode" ); - return 1; - } - - return scr_write( filename, MLT_SIZE, &set_mlt_pixels_and_attribute ); -} - -#ifdef WORDS_BIGENDIAN - -typedef struct { - unsigned b0 : 1; - unsigned b1 : 1; - unsigned b2 : 1; - unsigned b3 : 1; - unsigned b4 : 1; - unsigned b5 : 1; - unsigned b6 : 1; - unsigned b7 : 1; -} byte_field_type; - -#else /* #ifdef WORDS_BIGENDIAN */ - -typedef struct { - unsigned b7 : 1; - unsigned b6 : 1; - unsigned b5 : 1; - unsigned b4 : 1; - unsigned b3 : 1; - unsigned b2 : 1; - unsigned b1 : 1; - unsigned b0 : 1; -} byte_field_type; - -#endif /* #ifdef WORDS_BIGENDIAN */ - -typedef union { - libspectrum_byte byte; - byte_field_type bit; -} bft_union; - -static libspectrum_byte -convert_hires_to_lores( libspectrum_byte high, libspectrum_byte low ) -{ - bft_union ret, h, l; - - h.byte = high; - l.byte = low; - - ret.bit.b0 = l.bit.b0; - ret.bit.b1 = l.bit.b2; - ret.bit.b2 = l.bit.b4; - ret.bit.b3 = l.bit.b6; - ret.bit.b4 = h.bit.b0; - ret.bit.b5 = h.bit.b2; - ret.bit.b6 = h.bit.b4; - ret.bit.b7 = h.bit.b6; - - return ret.byte; -} - -int -screenshot_scr_read( const char *filename ) -{ - int error = 0; - int i; - utils_file screen; - - error = utils_read_file( filename, &screen ); - if( error ) return error; - - switch( screen.length ) { - case STANDARD_SCR_SIZE: - memcpy( &RAM[ memory_current_screen ][display_get_addr(0,0)], - screen.buffer, screen.length ); - - /* If it is a Timex and it is in hi colour or hires mode, switch out of - hires or hicolour mode */ - if( scld_last_dec.name.b1 || scld_last_dec.name.hires ) - scld_dec_write( 0xff, scld_last_dec.byte & ~HIRES ); - break; - - case HICOLOUR_SCR_SIZE: - /* If it is a Timex and it is not in hi colour mode, copy screen and switch - mode if neccesary */ - /* If it is not a Timex copy the mono bitmap and raise an error */ - if( machine_current->timex ) { - if( !scld_last_dec.name.b1 ) - scld_dec_write( 0xff, ( scld_last_dec.byte & ~HIRESATTR ) | EXTCOLOUR ); - memcpy( &RAM[ memory_current_screen ][display_get_addr(0,0) + - ALTDFILE_OFFSET], screen.buffer + MONO_BITMAP_SIZE, - MONO_BITMAP_SIZE ); - } else - ui_error( UI_ERROR_INFO, - "The file contained a TC2048 high-colour screen, loaded as mono"); - - memcpy( &RAM[ memory_current_screen ][display_get_addr(0,0)], - screen.buffer, MONO_BITMAP_SIZE ); - break; - - case HIRES_SCR_SIZE: - /* If it is a Timex and it is not in hi res mode, copy screen and switch - mode if neccesary */ - /* If it is not a Timex scale the bitmap and raise an error */ - if( machine_current->timex ) { - memcpy( &RAM[ memory_current_screen ][display_get_addr(0,0)], - screen.buffer, MONO_BITMAP_SIZE ); - - memcpy( &RAM[ memory_current_screen ][display_get_addr(0,0)] + - ALTDFILE_OFFSET, screen.buffer + MONO_BITMAP_SIZE, - MONO_BITMAP_SIZE ); - if( !scld_last_dec.name.hires ) - scld_dec_write( 0xff, - ( scld_last_dec.byte & ~( HIRESCOLMASK | HIRES ) ) | - ( *(screen.buffer + HIRES_ATTR) & ( HIRESCOLMASK | HIRES ) ) ); - } else { - libspectrum_byte attr = hires_convert_dec( *(screen.buffer + HIRES_ATTR) ); - - for( i = 0; i < MONO_BITMAP_SIZE; i++ ) - RAM[ memory_current_screen ][display_get_addr(0,0) + i] = - convert_hires_to_lores( *(screen.buffer + MONO_BITMAP_SIZE + i), - *(screen.buffer + i) ); - - /* set attributes based on hires attribute byte */ - for( i = 0; i < 768; i++ ) - RAM[ memory_current_screen ][display_get_addr(0,0) + - MONO_BITMAP_SIZE + i] = attr; - - ui_error( UI_ERROR_INFO, - "The file contained a TC2048 high-res screen, converted to lores"); - } - break; - - default: - ui_error( UI_ERROR_ERROR, "'%s' is not a valid scr file", filename ); - error = 1; - } - - utils_close_file( &screen ); - - display_refresh_all(); - - return error; -} - -int -screenshot_mlt_read( const char *filename ) -{ - int error = 0; - int x, y; - utils_file screen; - - error = utils_read_file( filename, &screen ); - if( error ) return error; - - if( screen.length != MLT_SIZE ) { - ui_error( UI_ERROR_ERROR, "MLT picture ('%s') is not %d bytes long", - filename, MLT_SIZE ); - return 1; - } - - /* If it is a Timex and it is not in hi colour mode, copy screen and switch - mode if neccesary */ - /* If it is not a Timex copy the mono bitmap and raise an error */ - if( machine_current->timex ) { - if( !scld_last_dec.name.b1 ) - scld_dec_write( 0xff, ( scld_last_dec.byte & ~HIRESATTR ) | EXTCOLOUR ); - - for( y = 0; y < DISPLAY_HEIGHT; y++ ) { - for( x = 0; x < DISPLAY_WIDTH_COLS; x++ ) { - RAM[ memory_current_screen ][display_get_addr(x,y) + ALTDFILE_OFFSET] = - *(screen.buffer + MONO_BITMAP_SIZE + x + y * DISPLAY_WIDTH_COLS); - } - } - } else - ui_error( UI_ERROR_INFO, - "The file contained a MLT high-colour screen, loaded as mono"); - - memcpy( &RAM[ memory_current_screen ][display_get_addr(0,0)], - screen.buffer, MONO_BITMAP_SIZE ); - - utils_close_file( &screen ); - - display_refresh_all(); - - return error; -} diff --git a/fuse/screenshot.h b/fuse/screenshot.h deleted file mode 100644 index c8ed319..0000000 --- a/fuse/screenshot.h +++ /dev/null @@ -1,48 +0,0 @@ -/* screenshot.h: Routines for saving .png screenshots - Copyright (c) 2002 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#ifndef FUSE_SCREENSHOT_H -#define FUSE_SCREENSHOT_H - -#ifndef SCALER_H -#include "ui/scaler/scaler.h" -#endif /* #ifndef SCALER_H */ - -void screenshot_register_startup( void ); - -#ifdef USE_LIBPNG - -int screenshot_write( const char *filename, scaler_type scaler ); -int screenshot_available_scalers( scaler_type scaler ); - -#endif /* #ifdef USE_LIBPNG */ - -int screenshot_scr_write( const char *filename ); -int screenshot_scr_read( const char *filename ); - -int screenshot_mlt_write( const char *filename ); -int screenshot_mlt_read( const char *filename ); - -#define STANDARD_SCR_SIZE 6912 - -#endif /* #ifndef FUSE_SCREENSHOT_H */ diff --git a/fuse/sound.c b/fuse/sound.c index b8acd62..5fcac52 100644 --- a/fuse/sound.c +++ b/fuse/sound.c @@ -31,7 +31,6 @@ #include "fuse.h" #include "infrastructure/startup_manager.h" #include "machine.h" -#include "movie.h" #include "options.h" #include "peripherals/sound/sp0256.h" #include "settings.h" @@ -374,8 +373,6 @@ sound_init( const char *device ) sound_framesiz++; samples = libspectrum_new0( blip_sample_t, sound_framesiz * sound_channels ); - /* initialize movie settings... */ - movie_init_sound( settings_current.sound_freq, sound_stereo_ay ); } @@ -811,8 +808,6 @@ sound_frame( void ) if( settings_current.sound ) sound_lowlevel_frame( samples, count ); - if( movie_recording ) - movie_add_sound( samples, count ); ay_change_count[0] = ay_change_count[1] = 0; } diff --git a/fuse/sound/alsasound.c b/fuse/sound/alsasound.c deleted file mode 100644 index fa7ee05..0000000 --- a/fuse/sound/alsasound.c +++ /dev/null @@ -1,390 +0,0 @@ -/* alsasound.c: ALSA (Linux) sound I/O - Copyright (c) 2006 Gergely Szasz - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -*/ - -#include - -/* This is necessary to prevent warnings from the calls to - snd_pcm_[hs]w_params_alloca() */ -#ifndef NDEBUG -#define NDEBUG -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "settings.h" -#include "sfifo.h" -#include "sound.h" -#include "spectrum.h" -#include "ui/ui.h" - -/* Number of Spectrum frames audio latency to use */ -#define NUM_FRAMES 3 - -static snd_pcm_t *pcm_handle; -static snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK; -static int ch, framesize; -static const char *pcm_name = NULL; -static int verb = 0; -static snd_pcm_uframes_t exact_periodsize, exact_bsize; - -static snd_output_t *output = NULL; - -void -sound_lowlevel_end( void ) -{ -/* Stop PCM device and drop pending frames */ - snd_pcm_drop( pcm_handle ); - snd_pcm_close( pcm_handle ); -} - -int -sound_lowlevel_init( const char *device, int *freqptr, int *stereoptr ) -{ - unsigned int exact_rate, periods; - unsigned int val, n; - snd_pcm_hw_params_t *hw_params; - snd_pcm_sw_params_t *sw_params; - snd_pcm_uframes_t avail_min = 0, sound_periodsize, bsize = 0; - static int first_init = 1; - static int init_running = 0; - const char *option; - char tmp; - int err, dir, nperiods = NUM_FRAMES; - - float hz; - - if( init_running ) - return 0; - - init_running = 1; -/* select a default device if we weren't explicitly given one */ - - option = device; - while( option && *option ) { - tmp = '*'; - if( ( err = sscanf( option, " buffer=%i %n%c", &val, &n, &tmp ) > 0 ) && - ( tmp == ',' || strlen( option ) == n ) ) { - if( val < 1 ) { - fprintf( stderr, "Bad value for ALSA buffer size %i, using default\n", - val ); - } else { - bsize = val; - } - } else if( ( err = sscanf( option, " frames=%i %n%c", &val, &n, &tmp ) > 0 ) && - ( tmp == ',' || strlen( option ) == n ) ) { - if( val < 1 ) { - fprintf( stderr, "Bad value for ALSA buffer size %i frames, using default (%d)\n", - val, NUM_FRAMES ); - } else { - nperiods = val; - } - } else if( ( err = sscanf( option, " avail=%i %n%c", &val, &n, &tmp ) > 0 ) && - ( tmp == ',' || strlen( option ) == n ) ) { - if( val < 1 ) { - fprintf( stderr, "Bad value for ALSA avail_min size %i frames, using default\n", - val ); - } else { - avail_min = val; - } - } else if( ( err = sscanf( option, " verbose %n%c", &n, &tmp ) == 1 ) && - ( tmp == ',' || strlen( option ) == n ) ) { - verb = 1; - } else { /* try as device name */ - while( isspace(*option) ) - option++; - if( *option == '\'' ) /* force device... */ - option++; - pcm_name = option; - n = strlen( pcm_name ); - } - option += n + ( tmp == ',' ); - } - -/* Open the sound device - */ - if( pcm_name == NULL || *pcm_name == '\0' ) - pcm_name = "default"; - if( snd_pcm_open( &pcm_handle, pcm_name , stream, 0 ) < 0 ) { - if( strcmp( pcm_name, "default" ) == 0 ) { - /* we try a last one: plughw:0,0 but what a weired ALSA conf.... */ - if( snd_pcm_open( &pcm_handle, "plughw:0,0", stream, 0 ) < 0 ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, - "couldn't open sound device 'default' and 'plughw:0,0' check ALSA configuration." - ); - init_running = 0; - return 1; - } else { - if( first_init ) - fprintf( stderr, - "Couldn't open sound device 'default', using 'plughw:0,0' check ALSA configuration.\n" - ); - } - } - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "couldn't open sound device '%s'.", pcm_name ); - init_running = 0; - return 1; - } - -/* Allocate the snd_pcm_hw_params_t structure on the stack. */ - snd_pcm_hw_params_alloca( &hw_params ); - -/* Init hw_params with full configuration space */ - if( snd_pcm_hw_params_any( pcm_handle, hw_params ) < 0 ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, - "couldn't get configuration space on sound device '%s'.", - pcm_name ); - snd_pcm_close( pcm_handle ); - init_running = 0; - return 1; - } - - if( snd_pcm_hw_params_set_access( pcm_handle, hw_params, - SND_PCM_ACCESS_RW_INTERLEAVED ) < 0) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "couldn't set access interleaved on '%s'.", - pcm_name ); - snd_pcm_close( pcm_handle ); - init_running = 0; - return 1; - } - - /* Set sample format */ - if( snd_pcm_hw_params_set_format( pcm_handle, hw_params, -#if defined WORDS_BIGENDIAN - SND_PCM_FORMAT_S16_BE -#else - SND_PCM_FORMAT_S16_LE -#endif - ) < 0 ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "couldn't set format on '%s'.", pcm_name ); - snd_pcm_close( pcm_handle ); - init_running = 0; - return 1; - } - - ch = *stereoptr ? 2 : 1; - - if( snd_pcm_hw_params_set_channels( pcm_handle, hw_params, ch ) - < 0 ) { - fprintf( stderr, "Couldn't set %s to '%s'.\n", pcm_name, - (*stereoptr ? "stereo" : "mono") ); - ch = *stereoptr ? 1 : 2; /* try with opposite */ - if( snd_pcm_hw_params_set_channels( pcm_handle, hw_params, ch ) - < 0 ) { - ui_error( UI_ERROR_ERROR, "couldn't set %s to '%s'.", pcm_name, - (*stereoptr ? "stereo" : "mono") ); - settings_current.sound = 0; - snd_pcm_close( pcm_handle ); - init_running = 0; - return 1; - } - *stereoptr = *stereoptr ? 0 : 1; /* write back */ - } - - framesize = ch << 1; /* we always use 16 bit sorry :-( */ -/* Set sample rate. If the exact rate is not supported */ -/* by the hardware, use nearest possible rate. */ - exact_rate = *freqptr; - if( snd_pcm_hw_params_set_rate_near( pcm_handle, hw_params, &exact_rate, - NULL ) < 0) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "couldn't set rate %d on '%s'.", - *freqptr, pcm_name ); - snd_pcm_close( pcm_handle ); - init_running = 0; - return 1; - } - if( first_init && *freqptr != exact_rate ) { - fprintf( stderr, - "The rate %d Hz is not supported by your hardware. " - "Using %d Hz instead.\n", *freqptr, exact_rate ); - *freqptr = exact_rate; - } - - if( bsize != 0 ) { - exact_periodsize = sound_periodsize = bsize / nperiods; - if( bsize < 1 ) { - fprintf( stderr, - "bad value for ALSA buffer size %i, using default.\n", - val ); - bsize = 0; - } - } - - if( bsize == 0 ) { - /* Adjust relative processor speed to deal with adjusting sound generation - frequency against emulation speed (more flexible than adjusting generated - sample rate) */ - hz = (float)sound_get_effective_processor_speed() / - machine_current->timings.tstates_per_frame; - /* Amount of audio data we will accumulate before yielding back to the OS. - Not much point having more than 100Hz playback, we probably get - downgraded by the OS as being a hog too (unlimited Hz limits playback - speed to about 2000% on my Mac, 100Hz allows up to 5000% for me) */ - if( hz > 100.0 ) hz = 100.0; - exact_periodsize = sound_periodsize = *freqptr / hz; - } - - dir = -1; - if( snd_pcm_hw_params_set_period_size_near( pcm_handle, hw_params, - &exact_periodsize, &dir ) < 0 ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "couldn't set period size %d on '%s'.", - (int)sound_periodsize, pcm_name ); - snd_pcm_close( pcm_handle ); - init_running = 0; - return 1; - } - - if( first_init && ( exact_periodsize < sound_periodsize / 1.5 || - exact_periodsize > sound_periodsize * 1.5 ) ) { - fprintf( stderr, - "The period size %d is not supported by your hardware. " - "Using %d instead.\n", (int)sound_periodsize, - (int)exact_periodsize ); - } - - periods = nperiods; -/* Set number of periods. Periods used to be called fragments. */ - if( snd_pcm_hw_params_set_periods_near( pcm_handle, hw_params, &periods, - NULL ) < 0 ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "couldn't set periods on '%s'.", pcm_name ); - snd_pcm_close( pcm_handle ); - init_running = 0; - return 1; - } - - if( first_init && periods != nperiods ) { - fprintf( stderr, "%d periods is not supported by your hardware. " - "Using %d instead.\n", nperiods, periods ); - } - - snd_pcm_hw_params_get_buffer_size( hw_params, &exact_bsize ); - - /* Apply HW parameter settings to */ - /* PCM device and prepare device */ - - if( snd_pcm_hw_params( pcm_handle, hw_params ) < 0 ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR,"couldn't set hw_params on %s", pcm_name ); - snd_pcm_close( pcm_handle ); - init_running = 0; - return 1; - } - - snd_pcm_sw_params_alloca( &sw_params ); - if( ( err = snd_pcm_sw_params_current( pcm_handle, sw_params ) ) < 0 ) { - ui_error( UI_ERROR_ERROR,"couldn't get sw_params from %s: %s", pcm_name, - snd_strerror ( err ) ); - snd_pcm_close( pcm_handle ); - init_running = 0; - return 1; - } - - if( ( err = snd_pcm_sw_params_set_start_threshold( pcm_handle, - sw_params, exact_periodsize * ( nperiods - 1 ) ) ) < 0 ) { - ui_error( UI_ERROR_ERROR,"couldn't set start_treshold on %s: %s", pcm_name, - snd_strerror ( err ) ); - snd_pcm_close( pcm_handle ); - init_running = 0; - return 1; - } - - if( !avail_min ) - avail_min = exact_periodsize >> 1; - if( snd_pcm_sw_params_set_avail_min( pcm_handle, - sw_params, avail_min ) < 0 ) { -#if SND_LIB_VERSION < 0x10010 - if( ( err = snd_pcm_sw_params_set_sleep_min( pcm_handle, - sw_params, 1 ) ) < 0 ) { - fprintf( stderr, "Unable to set minimal sleep 1 for %s: %s\n", pcm_name, - snd_strerror ( err ) ); - } -#else - fprintf( stderr, "Unable to set avail min %s: %s\n", pcm_name, - snd_strerror( err ) ); -#endif - } - -#if SND_LIB_VERSION < 0x10010 - if( ( err = snd_pcm_sw_params_set_xfer_align( pcm_handle, sw_params, 1 ) ) < 0 ) { - ui_error( UI_ERROR_ERROR,"couldn't set xfer_allign on %s: %s", pcm_name, - snd_strerror ( err ) ); - init_running = 0; - return 1; - } -#endif - - if( ( err = snd_pcm_sw_params( pcm_handle, sw_params ) ) < 0 ) { - ui_error( UI_ERROR_ERROR,"couldn't set sw_params on %s: %s", pcm_name, - snd_strerror ( err ) ); - init_running = 0; - return 1; - } - - if( first_init ) snd_output_stdio_attach(&output, stdout, 0); - - first_init = 0; - init_running = 0; - return 0; /* success */ -} - - - -void -sound_lowlevel_frame( libspectrum_signed_word *data, int len ) -{ - int ret = 0; - len /= ch; /* now in frames */ - -/* to measure sound lag :-) - snd_pcm_status_t *status; - snd_pcm_sframes_t delay; - - snd_pcm_status_alloca( &status ); - snd_pcm_status( pcm_handle, status ); - delay = snd_pcm_status_get_delay( status ); - fprintf( stderr, "%d ", (int)delay ); -*/ - - while( ( ret = snd_pcm_writei( pcm_handle, data, len ) ) != len ) { - if( ret < 0 ) { - snd_pcm_prepare( pcm_handle ); - if( verb ) - fprintf( stderr, "ALSA: *buffer underrun*!\n" ); - } else { - len -= ret; - } - } -} diff --git a/fuse/sound/aosound.c b/fuse/sound/aosound.c deleted file mode 100644 index e46ebd1..0000000 --- a/fuse/sound/aosound.c +++ /dev/null @@ -1,233 +0,0 @@ -/* aosound.c: libao sound I/O - Copyright (c) 2004,2013 Gergely Szasz, Philip Kendall - Copyright (c) 2015 Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - Philip: philip-fuse@shadowmagic.org.uk - - Gergely: szaszg@hu.inter.net - -*/ - -#include - -#include - -#include - -#include "settings.h" -#include "sound.h" -#include "ui/ui.h" -#include "utils.h" - -static ao_device *dev_for_ao; -static int sixteenbit = 1; -static char *filename = NULL; -static const char * const default_filename = "fuse-sound.ao"; -static int first_init = 1; - -static void -driver_error( void ) -{ - switch( errno ) { - case AO_ENODRIVER: - ui_error( UI_ERROR_ERROR, - "ao: no driver corresponds to driver_id." ); - break; - case AO_ENOTLIVE: - ui_error( UI_ERROR_ERROR, - "ao: driver is not a live output device." ); - break; - case AO_ENOTFILE: - ui_error( UI_ERROR_ERROR, - "ao: driver is not a file output driver." ); - break; - case AO_EBADOPTION: - ui_error( UI_ERROR_ERROR, - "ao: a valid option key has an invalid value." ); - break; - case AO_EOPENDEVICE: - ui_error( UI_ERROR_ERROR, - "ao: cannot open output device." ); - break; - case AO_EOPENFILE: - ui_error( UI_ERROR_ERROR, - "ao: cannot open output file '%s'.", filename ); - break; - case AO_EFILEEXISTS: - ui_error( UI_ERROR_ERROR, "ao: output file '%s' already exists.", - filename ); - break; - case AO_EFAIL: - ui_error( UI_ERROR_ERROR, "ao: unspecified error." ); - } -} - -static int -parse_driver_options( const char *device, int *driver_id, ao_option **options ) -{ - char *mutable, *option, *key, *value; - - /* Get a copy of the device string we can modify */ - if( !device || *device == '\0' ) - return 1; - - mutable = utils_safe_strdup( device ); - - /* First, find the device name */ - option = strchr( mutable, ':' ); - if( option ) *option++ = '\0'; - - if( *mutable ) /* ! \0 */ - *driver_id = ao_driver_id( mutable ); - - /* Now parse any further options */ - while( option ) { - - key = option; - - option = strchr( option, ',' ); - if( option ) *option++ = '\0'; - - value = strchr( key, '=' ); - if( value ) *value++ = '\0'; - - if( strcmp( key, "file" ) == 0 ) { - filename = utils_safe_strdup( value ); - } else if( key && value) { - ao_append_option( options, key, value ); - } else if ( first_init ) { - ui_error( UI_ERROR_ERROR, "ignoring badly formed libao option (%s%s)", - key ? key : "", value ? value : "" ); - } - - } - - libspectrum_free( mutable ); - return 0; -} - -int -sound_lowlevel_init( const char *device, int *freqptr, int *stereoptr ) -{ - ao_option *options = NULL; - ao_info *driver_info = NULL; - int driver_id = -1; - static ao_sample_format format = { .bits = 0 }; - - /* To prevent recursive errors */ - static int sound_lowlevel_init_in_progress = 0; - - int error; - - if( sound_lowlevel_init_in_progress ) return 0; - - sound_lowlevel_init_in_progress = 1; - - ao_initialize(); - - error = parse_driver_options( device, &driver_id, &options ); - if( error ) { - settings_current.sound = 0; - sound_lowlevel_init_in_progress = 0; - return error; - } - - if( driver_id == -1 ) - driver_id = ao_default_driver_id(); - - if( driver_id == -1 ) { - ui_error( UI_ERROR_ERROR, "ao: driver '%s' unknown", - device ); - settings_current.sound = 0; - sound_lowlevel_init_in_progress = 0; - return 1; - } - - driver_info = ao_driver_info( driver_id ); - - if( driver_info->type == AO_TYPE_FILE && - format.bits != 0 ) { /* OK. We not want to trunc the file :-) */ - ui_error( UI_ERROR_WARNING, "ao: must truncate audio file '%s'", - filename ); - } - - format.channels = *stereoptr ? 2 : 1; - format.rate = *freqptr; - format.bits = settings_current.sound_force_8bit ? 8 : 16; - format.byte_format = AO_FMT_LITTLE; - sixteenbit = settings_current.sound_force_8bit ? 0 : 1; - - if( driver_info->type == AO_TYPE_LIVE ) { - - dev_for_ao = ao_open_live( driver_id, &format, options); - - } else { - - if( !filename ) filename = (char *)default_filename; - dev_for_ao = ao_open_file( driver_id, filename, 1, &format, options); - - } - - if( !dev_for_ao ) { - driver_error(); - settings_current.sound = 0; - sound_lowlevel_init_in_progress = 0; - return 1; - } - - ao_free_options( options ); - - sound_lowlevel_init_in_progress = 0; - first_init = 0; - - return 0; -} - -void -sound_lowlevel_end( void ) -{ - if( filename != default_filename ) libspectrum_free( filename ); - ao_close(dev_for_ao); - ao_shutdown(); -} - -void -sound_lowlevel_frame( libspectrum_signed_word *data, int len ) -{ - static signed char buf8[4096]; - void *data8 = data; - - len <<= 1; /* now in bytes */ - - if( !sixteenbit ) { - libspectrum_signed_word *src; - signed char *dst; - int f; - - src = data; - dst = buf8; - len >>= 1; - for( f = 0; f < len; f++) - *dst++ = ( int )( ( *src++ ) / 256 ); - - data8 = buf8; - } - - ao_play( dev_for_ao, data8, len ); -} diff --git a/fuse/sound/coreaudiosound.c b/fuse/sound/coreaudiosound.c deleted file mode 100644 index 0888310..0000000 --- a/fuse/sound/coreaudiosound.c +++ /dev/null @@ -1,317 +0,0 @@ -/* coreaudiosound.c: Mac OS X CoreAudio sound I/O - Copyright (c) 2006 Fredrick Meunier - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -*/ - -#include - -#include -#include - -#include - -#include - -#include "settings.h" -#include "sfifo.h" -#include "sound.h" -#include "ui/ui.h" - -sfifo_t sound_fifo; - -/* Number of Spectrum frames audio latency to use */ -#define NUM_FRAMES 2 - -static -OSStatus coreaudiowrite( void *inRefCon, - AudioUnitRenderActionFlags *ioActionFlags, - const AudioTimeStamp *inTimeStamp, - UInt32 inBusNumber, - UInt32 inNumberFrames, - AudioBufferList *ioData ); - -/* info about the format used for writing to output unit */ -static AudioStreamBasicDescription deviceFormat; - -/* converts from Fuse format (signed 16 bit ints) to CoreAudio format (floats) - */ -static AudioUnit gOutputUnit; - -/* Records sound writer status information */ -static int audio_output_started; - -/* get the default output device for the HAL */ -static int -get_default_output_device(AudioDeviceID* device) -{ - OSStatus err = kAudioHardwareNoError; - UInt32 count; - - AudioObjectPropertyAddress property_address = { - kAudioHardwarePropertyDefaultOutputDevice, - kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster - }; - - /* get the default output device for the HAL */ - count = sizeof( *device ); - err = AudioObjectGetPropertyData( kAudioObjectSystemObject, &property_address, - 0, NULL, &count, device); - if ( err != kAudioHardwareNoError && device != kAudioObjectUnknown ) { - ui_error( UI_ERROR_ERROR, - "get kAudioHardwarePropertyDefaultOutputDevice error %ld", - (long)err ); - return 1; - } - - return 0; -} - -/* get the nominal sample rate used by the supplied device */ -static int -get_default_sample_rate( AudioDeviceID device, Float64 *rate ) -{ - OSStatus err = kAudioHardwareNoError; - UInt32 count; - - AudioObjectPropertyAddress property_address = { - kAudioDevicePropertyNominalSampleRate, - kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster - }; - - /* get the default output device for the HAL */ - count = sizeof( *rate ); - err = AudioObjectGetPropertyData( device, &property_address, 0, NULL, &count, - rate); - if ( err != kAudioHardwareNoError ) { - ui_error( UI_ERROR_ERROR, - "get kAudioDevicePropertyNominalSampleRate error %ld", - (long)err ); - return 1; - } - - return 0; -} - -int -sound_lowlevel_init( const char *dev, int *freqptr, int *stereoptr ) -{ - OSStatus err = kAudioHardwareNoError; - AudioDeviceID device = kAudioObjectUnknown; /* the default device */ - int error; - float hz; - int sound_framesiz; - - if( get_default_output_device(&device) ) return 1; - if( get_default_sample_rate( device, &deviceFormat.mSampleRate ) ) return 1; - - *freqptr = deviceFormat.mSampleRate; - - deviceFormat.mFormatID = kAudioFormatLinearPCM; - deviceFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger -#ifdef WORDS_BIGENDIAN - | kLinearPCMFormatFlagIsBigEndian -#endif /* #ifdef WORDS_BIGENDIAN */ - | kLinearPCMFormatFlagIsPacked; - deviceFormat.mBytesPerPacket = *stereoptr ? 4 : 2; - deviceFormat.mFramesPerPacket = 1; - deviceFormat.mBytesPerFrame = *stereoptr ? 4 : 2; - deviceFormat.mBitsPerChannel = 16; - deviceFormat.mChannelsPerFrame = *stereoptr ? 2 : 1; - - /* Open the default output unit */ - AudioComponentDescription desc; - desc.componentType = kAudioUnitType_Output; - desc.componentSubType = kAudioUnitSubType_DefaultOutput; - desc.componentManufacturer = kAudioUnitManufacturer_Apple; - desc.componentFlags = 0; - desc.componentFlagsMask = 0; - - AudioComponent comp = AudioComponentFindNext( NULL, &desc ); - if( comp == NULL ) { - ui_error( UI_ERROR_ERROR, "AudioComponentFindNext" ); - return 1; - } - - err = AudioComponentInstanceNew( comp, &gOutputUnit ); - if( comp == NULL ) { - ui_error( UI_ERROR_ERROR, "AudioComponentInstanceNew=%ld", (long)err ); - return 1; - } - - /* Set up a callback function to generate output to the output unit */ - AURenderCallbackStruct input; - input.inputProc = coreaudiowrite; - input.inputProcRefCon = NULL; - - err = AudioUnitSetProperty( gOutputUnit, - kAudioUnitProperty_SetRenderCallback, - kAudioUnitScope_Input, - 0, - &input, - sizeof( input ) ); - if( err ) { - ui_error( UI_ERROR_ERROR, "AudioUnitSetProperty-CB=%ld", (long)err ); - return 1; - } - - err = AudioUnitSetProperty( gOutputUnit, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Input, - 0, - &deviceFormat, - sizeof( AudioStreamBasicDescription ) ); - if( err ) { - ui_error( UI_ERROR_ERROR, "AudioUnitSetProperty-SF=%4.4s, %ld", (char*)&err, - (long)err ); - return 1; - } - - err = AudioUnitInitialize( gOutputUnit ); - if( err ) { - ui_error( UI_ERROR_ERROR, "AudioUnitInitialize=%ld", (long)err ); - return 1; - } - - /* Adjust relative processor speed to deal with adjusting sound generation - frequency against emulation speed (more flexible than adjusting generated - sample rate) */ - hz = (float)sound_get_effective_processor_speed() / - machine_current->timings.tstates_per_frame; - /* Amount of audio data we will accumulate before yielding back to the OS. - Not much point having more than 100Hz playback, we probably get - downgraded by the OS as being a hog too (unlimited Hz limits playback - speed to about 2000% on my Mac, 100Hz allows up to 5000% for me) */ - if( hz > 100.0 ) hz = 100.0; - sound_framesiz = deviceFormat.mSampleRate / hz; - - if( ( error = sfifo_init( &sound_fifo, NUM_FRAMES - * deviceFormat.mBytesPerFrame - * deviceFormat.mChannelsPerFrame - * sound_framesiz + 1 ) ) ) { - ui_error( UI_ERROR_ERROR, "Problem initialising sound fifo: %s", - strerror ( error ) ); - return 1; - } - - /* wait to run sound until we have some sound to play */ - audio_output_started = 0; - - return 0; -} - -/* Support pre Xcode 9 SDK */ -#ifndef __Verify_noErr -#define __Verify_noErr((a)) verify_noerr((a)) -#endif - -void -sound_lowlevel_end( void ) -{ - OSStatus err; - - if( audio_output_started ) - __Verify_noErr( AudioOutputUnitStop( gOutputUnit ) ); - - err = AudioUnitUninitialize( gOutputUnit ); - if( err ) { - ui_error( UI_ERROR_ERROR, "AudioUnitUninitialize=%ld", (long)err ); - } - - err = AudioComponentInstanceDispose( gOutputUnit ); - if( err ) { - ui_error( UI_ERROR_ERROR, "AudioComponentInstanceDispose=%ld", (long)err ); - } - - sfifo_flush( &sound_fifo ); - sfifo_close( &sound_fifo ); -} - -/* Copy data to fifo */ -void -sound_lowlevel_frame( libspectrum_signed_word *data, int len ) -{ - int i = 0; - - /* Convert to bytes */ - libspectrum_signed_byte* bytes = (libspectrum_signed_byte*)data; - len <<= 1; - - while( len ) { - if( ( i = sfifo_write( &sound_fifo, bytes, len ) ) < 0 ) { - break; - } else if( !i ) { - usleep( 10000 ); - } - bytes += i; - len -= i; - } - if( i < 0 ) { - ui_error( UI_ERROR_ERROR, "Couldn't write sound fifo: %s", - strerror( i ) ); - } - - if( !audio_output_started ) { - /* Start the rendering - The DefaultOutputUnit will do any format conversions to the format of the - default device */ - OSStatus err = AudioOutputUnitStart( gOutputUnit ); - if( err ) { - ui_error( UI_ERROR_ERROR, "AudioOutputUnitStart=%ld", (long)err ); - return; - } - - audio_output_started = 1; - } -} - -#ifndef MIN -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) -#endif - -/* This is the audio processing callback. */ -OSStatus coreaudiowrite( void *inRefCon, - AudioUnitRenderActionFlags *ioActionFlags, - const AudioTimeStamp *inTimeStamp, - UInt32 inBusNumber, - UInt32 inNumberFrames, - AudioBufferList *ioData ) -{ - int f; - int len = deviceFormat.mBytesPerFrame * inNumberFrames; - uint8_t* out = ioData->mBuffers[0].mData; - - /* Try to only read an even number of bytes so as not to fragment a sample */ - len = MIN( len, sfifo_used( &sound_fifo ) ); - len &= sound_stereo_ay != SOUND_STEREO_AY_NONE ? 0xfffc : 0xfffe; - - /* Read input_size bytes from fifo into sound stream */ - while( ( f = sfifo_read( &sound_fifo, out, len ) ) > 0 ) { - out += f; - len -= f; - } - - /* If we ran out of sound, make do with silence :( */ - if( f < 0 ) { - for( f=0; f - -#include -#include -#include - -#include "settings.h" -#include "sound.h" -#include "ui/ui.h" - -/* same as for SDL Sound */ -#define MAX_AUDIO_BUFFER 8192*5 - -static LPDIRECTSOUND lpDS; /* DirectSound object */ -static LPDIRECTSOUNDBUFFER lpDSBuffer; /* sound buffer */ - -static DWORD nextpos; /* next position in circular buffer */ - -static int sixteenbit; - -int -sound_lowlevel_init( const char *device, int *freqptr, int *stereoptr ) -{ - - WAVEFORMATEX pcmwf; /* waveformat struct */ - DSBUFFERDESC dsbd; /* buffer description */ - - /* Initialize COM */ - CoInitialize(NULL); - - /* create DirectSound object */ - if( CoCreateInstance( &CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER, - &IID_IDirectSound, (void**)&lpDS ) != DS_OK ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "Couldn't create DirectSound object."); - CoUninitialize(); - return 1; - } - - /* initialize it */ - if( IDirectSound_Initialize( lpDS, NULL ) != DS_OK ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "Couldn't initialize DirectSound." ); - CoUninitialize(); - return 1; - } - - /* set normal cooperative level */ - if( IDirectSound_SetCooperativeLevel( lpDS, GetDesktopWindow(), - DSSCL_NORMAL ) != DS_OK ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "Couldn't set DirectSound cooperation level." ); - IDirectSound_Release( lpDS ); - CoUninitialize(); - return 1; - } - - /* create wave format description */ - memset( &pcmwf, 0, sizeof( WAVEFORMATEX ) ); - - pcmwf.cbSize = 0; - if( settings_current.sound_force_8bit ) { - pcmwf.wBitsPerSample = 8; - sixteenbit = 0; - } else { - pcmwf.wBitsPerSample = 16; - sixteenbit = 1; - } - pcmwf.nChannels = *stereoptr ? 2 : 1; - pcmwf.nBlockAlign = pcmwf.nChannels * ( sixteenbit ? 2 : 1 ); - pcmwf.nSamplesPerSec = *freqptr; - - pcmwf.nAvgBytesPerSec = pcmwf.nSamplesPerSec * pcmwf.nBlockAlign; - - pcmwf.wFormatTag = WAVE_FORMAT_PCM; - - /* create sound buffer description */ - memset( &dsbd, 0, sizeof( DSBUFFERDESC ) ); - dsbd.dwBufferBytes = MAX_AUDIO_BUFFER; - - dsbd.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLVOLUME | - DSBCAPS_CTRLFREQUENCY | DSBCAPS_STATIC | DSBCAPS_LOCSOFTWARE; - - dsbd.dwSize = sizeof( DSBUFFERDESC ); - dsbd.lpwfxFormat = &pcmwf; - - /* attempt to create the buffer */ - if( IDirectSound_CreateSoundBuffer( lpDS, &dsbd, &lpDSBuffer, NULL ) - != DS_OK ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "Couldn't create DirectSound buffer." ); - IDirectSound_Release( lpDS ); - CoUninitialize(); - return 1; - } - - /* play buffer */ - if( IDirectSoundBuffer_Play( lpDSBuffer, 0, 0, DSBPLAY_LOOPING ) != DS_OK ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "Couldn't play sound." ); - IDirectSoundBuffer_Release( lpDSBuffer ); - IDirectSound_Release( lpDS ); - CoUninitialize(); - return 1; - } - - nextpos = 0; - - return 0; -} - -void -sound_lowlevel_end( void ) -{ - if( IDirectSoundBuffer_Stop( lpDSBuffer ) != DS_OK ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "Couldn't stop sound." ); - } - - IDirectSoundBuffer_Release( lpDSBuffer ); - IDirectSound_Release( lpDS ); - CoUninitialize(); -} - -/* Copying data to the buffer */ -void -sound_lowlevel_frame( libspectrum_signed_word *data, int len ) -{ - HRESULT hres; - int i1, i2; - int lsb = 1; - - /* two pair because of circular buffer */ - UCHAR *ucbuffer1, *ucbuffer2; - DWORD length1, length2; - DWORD playcursor; - long cursordiff; - - if( sixteenbit ) - len *= 2; - - while( len ) { - while( 1 ) { - IDirectSoundBuffer_GetCurrentPosition( lpDSBuffer, &playcursor, NULL ); - - cursordiff = (long)nextpos - (long)playcursor; - - if( playcursor > nextpos ) - cursordiff += MAX_AUDIO_BUFFER; - - if( cursordiff < len * 6 ) - break; - - Sleep(10); - } - - /* lock the buffer */ - hres = IDirectSoundBuffer_Lock( lpDSBuffer, nextpos, (DWORD)len, - (void **)&ucbuffer1, &length1, - (void **)&ucbuffer2, &length2, - 0 ); - if( hres != DS_OK ) return; /* couldn't get a lock on the buffer */ - - /* write to the first part of buffer */ - for( i1 = 0; i1 < length1 && len > 0; i1++ ) { - if( sixteenbit ) { - if( lsb ) { - ucbuffer1[ i1 ] = *data & 0xff; - } else { - ucbuffer1[ i1 ] = *data >> 8; - data++; - } - lsb = !lsb; - } else { - ucbuffer1[ i1 ] = ( ( *data++ ) >> 8 ) ^ 0x80; - } - nextpos++; - len--; - } - - if( ucbuffer2 ) { - /* write to the second part of buffer */ - for( i2 = 0; i2 < length2 && len > 0; i2++ ) { - if( sixteenbit ) { - if( lsb ) { - ucbuffer2[ i2 ] = *data & 0xff; - } else { - ucbuffer2[ i2 ] = *data >> 8; - data++; - } - lsb = !lsb; - } else { - ucbuffer2[ i2 ] = ( ( *data++ ) >> 8 ) ^ 0x80; - } - nextpos++; - len--; - } - } else { - i2 = 0; - } - - if( nextpos >= MAX_AUDIO_BUFFER ) nextpos -= MAX_AUDIO_BUFFER; - - /* unlock the buffer */ - IDirectSoundBuffer_Unlock( lpDSBuffer, ucbuffer1, i1, ucbuffer2, i2 ); - } -} diff --git a/fuse/sound/hpsound.c b/fuse/sound/hpsound.c deleted file mode 100644 index f8625f5..0000000 --- a/fuse/sound/hpsound.c +++ /dev/null @@ -1,163 +0,0 @@ -/* hpsound.c: HP-UX sound I/O - Copyright (c) 2002-2004 Alexander Yurchenko, Russell Marks, Philip Kendall - Matan Ziv-Av, Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -*/ - -#include - -#include -#include -#include - -#include -#include -#include - -#include "settings.h" -#include "sound.h" -#include "ui/ui.h" - -static int soundfd = -1; -static int sixteenbit = 1; - -int sound_lowlevel_init( const char *device, int *freqptr, int *stereoptr ) -{ - int flags, tmp, frag; - - /* select a default device if we weren't explicitly given one */ - if( device == NULL ) device = "/dev/audio"; - - /* Open the sound device non-blocking to avoid hangs if it is being - * used by something else, but then set it blocking again as that's what - * we actually want */ - if( ( soundfd = open( device, O_WRONLY | O_NONBLOCK ) ) == -1 ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "Couldn't open sound device '%s'", device ); - return 1; - } - - if( ( flags = fcntl( soundfd, F_GETFL ) ) == -1 ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "Couldn't fcntl sound device '%s'", device ); - close( soundfd ); - return 1; - } - - flags &= ~O_NONBLOCK; - - if( fcntl( soundfd, F_SETFL, flags ) == -1 ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "Couldn't set sound device '%s' blocking", - device ); - close( soundfd ); - return 1; - } - - tmp = AUDIO_FORMAT_LINEAR16BIT; - if( settings_current.sound_force_8bit || - ioctl( soundfd, AUDIO_SET_DATA_FORMAT, tmp ) < 0 ) { - - /* try 8-bit - may be an 8-bit only device */ - tmp = AUDIO_FORMAT_LINEAR8BIT; - if( ioctl( soundfd, AUDIO_SET_DATA_FORMAT, tmp ) < 0 ) { - settings_current.sound = 0; - - if( settings_current.sound_force_8bit ) { - ui_error( UI_ERROR_ERROR, - "Couldn't set sound device '%s' into 8-bit mode", device ); - } else { - ui_error( - UI_ERROR_ERROR, - "Couldn't set sound device '%s' in either 16-bit or 8-bit mode", - device - ); - } - - close( soundfd ); - return 1; - } - - sixteenbit = 0; - } - - tmp = ( *stereoptr ) ? 2 : 1; - if( ioctl( soundfd, AUDIO_SET_CHANNELS, tmp ) < 0 ) { - tmp = ( *stereoptr ) ? 1 : 2; - if( ioctl( soundfd, AUDIO_SET_CHANNELS, tmp ) < 0 ) { - settings_current.sound = 0; - ui_error( - UI_ERROR_ERROR, - "Couldn't set sound device '%s' into either mono or stereo mode", - device - ); - close( soundfd ); - return 1; - } - *stereoptr = tmp; - } - - if( ioctl( soundfd, AUDIO_SET_SAMPLE_RATE, *freqptr ) < 0 ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR,"Couldn't set sound device '%s' speed to %d", - device, *freqptr ); - close( soundfd ); - return 1; - } - - frag = 16384; - ioctl( soundfd, AUDIO_SET_FRAGMENT, frag ); - - return 0; -} - -void -sound_lowlevel_end( void ) -{ - if( soundfd != -1 ) close( soundfd ); -} - -void -sound_lowlevel_frame( libspectrum_signed_word *data, int len ) -{ - static unsigned char buf8[4096]; - unsigned char *data8=(unsigned char *)data; - int ret=0, ofs=0; - - len <<= 1; /* now in bytes */ - if( !sixteenbit ) { - libspectrum_signed_word *src; - unsigned char *dst; - int f; - - src = data; dst = buf8; - len >>= 1; - /* TODO: confirm byteorder on IA64 */ - for( f = 0; f < len; f++ ) - *dst++ = 128 + (int)( (*src++) / 256 ); - - data8 = buf8; - } - - while( len ) { - ret = write( soundfd, data8 + ofs, len ); - if( ret > 0 ) { - ofs += ret; - len -= ret; - } - } -} diff --git a/fuse/sound/nullsound.c b/fuse/sound/nullsound.c deleted file mode 100644 index a7e4e80..0000000 --- a/fuse/sound/nullsound.c +++ /dev/null @@ -1,44 +0,0 @@ -/* nullsound.c: dummy sound routines - Copyright (c) 2003-2004 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -*/ - -#include - -/* Dummy functions for when we don't have a sound device; should never be - called, so just abort if they are */ - -#include "fuse.h" - -int -sound_lowlevel_init( const char *device, int *freqptr, int *stereoptr ) -{ - /* Audio driver not initialised */ - return 1; -} - -void -sound_lowlevel_end( void ) -{ - fuse_abort(); -} - -void -sound_lowlevel_frame( unsigned char *data, int len ) -{ - fuse_abort(); -} diff --git a/fuse/sound/osssound.c b/fuse/sound/osssound.c deleted file mode 100644 index 0f1c6e1..0000000 --- a/fuse/sound/osssound.c +++ /dev/null @@ -1,179 +0,0 @@ -/* osssound.c: OSS (e.g. Linux) sound I/O - Copyright (c) 2000-2004 Russell Marks, Matan Ziv-Av, Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -*/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "settings.h" -#include "sound.h" -#include "spectrum.h" -#include "ui/ui.h" - -/* using (8) 64 byte frags for 8kHz, scale up for higher */ -#define BASE_SOUND_FRAG_PWR 6 - - -static int soundfd=-1; -static int sixteenbit=1; - - -/* returns 0 on *success*, and adjusts freq/stereo args to reflect - * what we've actually got. - */ -int sound_lowlevel_init(const char *device,int *freqptr,int *stereoptr) -{ -int frag,tmp,flags; - -/* select a default device if we weren't explicitly given one */ -if(device==NULL) device = "/dev/dsp"; - -/* Open the sound device non-blocking to avoid hangs if it is being - * used by something else, but then set it blocking again as that's what - * we actually want - */ -if((soundfd=open(device,O_WRONLY|O_NONBLOCK))==-1) - { - settings_current.sound = 0; - ui_error(UI_ERROR_ERROR,"couldn't open sound device '%s': %s",device,strerror(errno)); - return 1; - } -if((flags=fcntl(soundfd,F_GETFL))==-1) - { - settings_current.sound = 0; - ui_error(UI_ERROR_ERROR,"couldn't get flags from sound device: %s",strerror(errno)); - close(soundfd); - return 1; - } -flags &= ~O_NONBLOCK; -if(fcntl(soundfd,F_SETFL,flags)==-1) - { - settings_current.sound = 0; - ui_error(UI_ERROR_ERROR,"couldn't set sound device non-blocking: %s",strerror(errno)); - close(soundfd); - return 1; - } - -tmp=AFMT_S16_NE; -sixteenbit=1; -if(settings_current.sound_force_8bit || ioctl(soundfd,SNDCTL_DSP_SETFMT,&tmp)==-1) - { - /* try 8-bit - may be an 8-bit-only device */ - tmp=AFMT_U8; - if((ioctl(soundfd,SNDCTL_DSP_SETFMT,&tmp))==-1) - { - settings_current.sound = 0; - ui_error(UI_ERROR_ERROR,"couldn't set sound device into 8-bit mode: %s",strerror(errno)); - close(soundfd); - return 1; - } - - sixteenbit=0; - } - -/* XXX should it warn if it didn't get the stereoness it wanted? */ -tmp=(*stereoptr)?1:0; -if(ioctl(soundfd,SNDCTL_DSP_STEREO,&tmp)<0) - { - /* if it failed, make sure the opposite is ok */ - tmp=(*stereoptr)?0:1; - if(ioctl(soundfd,SNDCTL_DSP_STEREO,&tmp)<0) - { - settings_current.sound = 0; - ui_error(UI_ERROR_ERROR,"couldn't set sound device into either mono or stereo mode: %s",strerror(errno)); - close(soundfd); - return 1; - } - *stereoptr=tmp; - } - -frag=(0x80000|BASE_SOUND_FRAG_PWR); - -if(ioctl(soundfd,SNDCTL_DSP_SPEED,freqptr)<0) - { - settings_current.sound = 0; - ui_error(UI_ERROR_ERROR,"couldn't set sound device speed to %d: %s",*freqptr, strerror(errno)); - close(soundfd); - return 1; - } - -if(*freqptr>8250) frag++; -if(*freqptr>16500) frag++; -if(*freqptr>33000) frag++; -if(*stereoptr) frag++; -if(sixteenbit) frag++; - -/* FIXME: OSS API docs say you should write to the soundcard in frag size - blocks */ -if(ioctl(soundfd,SNDCTL_DSP_SETFRAGMENT,&frag)<0) - { - settings_current.sound = 0; - ui_error(UI_ERROR_ERROR,"couldn't set sound device fragment size to %d: %s",frag,strerror(errno)); - close(soundfd); - return 1; - } - -return 0; /* success */ -} - - -void sound_lowlevel_end(void) -{ -if(soundfd!=-1) - close(soundfd); -} - - -void sound_lowlevel_frame(libspectrum_signed_word *data,int len) -{ -static unsigned char buf8[4096]; -unsigned char *data8=(unsigned char *)data; -int ret=0,ofs=0; - -len<<=1; /* now in bytes */ - -if(!sixteenbit) - { - libspectrum_signed_word *src; - unsigned char *dst; - int f; - - src=data; dst=buf8; - len>>=1; - for(f=0;f0) - ofs+=ret,len-=ret; - } -} diff --git a/fuse/sound/pulsesound.c b/fuse/sound/pulsesound.c deleted file mode 100644 index b5230fc..0000000 --- a/fuse/sound/pulsesound.c +++ /dev/null @@ -1,144 +0,0 @@ -/* pulsesound.c: pulseaudio (Linux) sound I/O - Copyright (c) 2010-2019 Grzegorz Jablonski, Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -*/ - -#include - -#include -#include - -#include -#include -#include -#include - -#include "sound.h" - -#define PULSEAUDIO_DEBUG 0 - -static pa_simple *pulse_s; -static int verbose = 0; - -void -sound_lowlevel_end( void ) -{ - pa_simple_free( pulse_s ); -} - -int -sound_lowlevel_init( const char *device, int *freqptr, int *stereoptr ) -{ - pa_sample_spec ss; - pa_buffer_attr buf; - unsigned int n; - unsigned int val; - const char *option; - char tmp; - int err; - int bsize = 0; - int bdelay = 30; /* default to 30ms */ - - /* scan explicitly given parameters */ - option = device; - while( option && *option ) { - tmp = '*'; - if( ( err = sscanf( option, " tlength=%ims %n%c", &val, &n, &tmp ) > 0 ) && - ( tmp == ',' || strlen( option ) == n ) ) { - if( val < 1 ) { - fprintf( stderr, "Bad value for PULSEAUDIO tlength, using default\n" ); - } else { - bdelay = val; - } - } else if( ( err = sscanf( option, " tlength=%i %n%c", &val, &n, &tmp ) > 0 ) && - ( tmp == ',' || strlen( option ) == n ) ) { - if( val < 1 ) { - fprintf( stderr, "Bad value for PULSEAUDIO tlength, using default\n" ); - } else { - bsize = val; - } - } else if( ( err = sscanf( option, " verbose %n%c", &n, &tmp ) == 1 ) && - ( tmp == ',' || ( strlen( option ) == n ) ) ) { - verbose = 1; - } - - option += n + ( tmp == ',' ); - } - -#if defined WORDS_BIGENDIAN - ss.format = PA_SAMPLE_S16BE; -#else - ss.format = PA_SAMPLE_S16LE; -#endif - - ss.channels = ( *stereoptr )? 2 : 1; - ss.rate = *freqptr; - - /* Reduce latency to 30ms or the user-defined value. pulseaudio does - not guarantee that */ - buf.tlength = (bsize)? bsize : - pa_usec_to_bytes( bdelay * PA_USEC_PER_MSEC, &ss ); - - buf.maxlength = buf.tlength * 4; - buf.minreq = buf.tlength / 4; - buf.prebuf = (uint32_t) -1; - buf.fragsize = (uint32_t) -1; - - if( verbose ) { - fprintf( stdout, "buffer requested: maxlength=%lu, tlength=%lu, prebuf=%lu," - " minreq=%lu\n", - (unsigned long) buf.maxlength, - (unsigned long) buf.tlength, - (unsigned long) buf.prebuf, - (unsigned long) buf.minreq ); - } - - pulse_s = pa_simple_new( NULL, PACKAGE, PA_STREAM_PLAYBACK, NULL, - "Spectrum", &ss, NULL, &buf, &err ); - if( pulse_s == NULL ) { - fprintf( stderr, "pulseaudio: pa_simple_new() failed: %s\n", - pa_strerror( err ) ); - return 1; - } - - return 0; -} - -void -sound_lowlevel_frame( libspectrum_signed_word *data, int len ) -{ - int retval, error; - - /* Measure sound lag */ - if( PULSEAUDIO_DEBUG ) { - pa_usec_t latency; - latency = pa_simple_get_latency( pulse_s, &error ); - if( latency == (pa_usec_t) - 1 ) { - fprintf( stderr, "pulseaudio: pa_simple_get_latency() failed: %s\n", - pa_strerror( error ) ); - } else { - fprintf( stderr, "%0.0f ", (float)latency / PA_USEC_PER_MSEC ); - } - } - - retval = pa_simple_write( pulse_s, data, 2 * len, &error ); - - if( verbose && retval < 0 ) { - fprintf( stderr, "pulseaudio: pa_simple_write() failed: %s\n", - pa_strerror( error ) ); - } -} diff --git a/fuse/sound/sdlsound.c b/fuse/sound/sdlsound.c deleted file mode 100644 index 5e34c8f..0000000 --- a/fuse/sound/sdlsound.c +++ /dev/null @@ -1,210 +0,0 @@ -/* sdlsound.c: SDL sound I/O - Copyright (c) 2002-2015 Alexander Yurchenko, Russell Marks, Philip Kendall, - Fredrick Meunier - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -*/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "settings.h" -#include "sfifo.h" -#include "sound.h" -#include "ui/ui.h" - -static void sdlwrite( void *userdata, Uint8 *stream, int len ); - -sfifo_t sound_fifo; - -/* Number of Spectrum frames audio latency to use */ -#define NUM_FRAMES 2 - -/* Records sound writer status information */ -static int audio_output_started; - -int -sound_lowlevel_init( const char *device, int *freqptr, int *stereoptr ) -{ - SDL_AudioSpec requested, received; - int error; - float hz; - int sound_framesiz; - -#ifndef __MORPHOS__ - /* I'd rather just use setenv, but Windows doesn't have it */ - if( device ) { - const char *environment = "SDL_AUDIODRIVER="; - char *command = libspectrum_new( char, strlen( environment ) + - strlen( device ) + 1 ); - strcpy( command, environment ); - strcat( command, device ); - error = putenv( command ); - libspectrum_free( command ); - if( error ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "Couldn't set SDL_AUDIODRIVER: %s", - strerror ( error ) ); - return 1; - } - } -#endif /* #ifndef __MORPHOS__ */ - - SDL_InitSubSystem( SDL_INIT_AUDIO ); - - memset( &requested, 0, sizeof( SDL_AudioSpec ) ); - - requested.freq = *freqptr; - requested.channels = *stereoptr ? 2 : 1; - requested.format = AUDIO_S16SYS; - requested.callback = sdlwrite; - - /* Adjust relative processor speed to deal with adjusting sound generation - frequency against emulation speed (more flexible than adjusting generated - sample rate) */ - hz = (float)sound_get_effective_processor_speed() / - machine_current->timings.tstates_per_frame; - /* Amount of audio data we will accumulate before yielding back to the OS. - Not much point having more than 100Hz playback, we probably get - downgraded by the OS as being a hog too (unlimited Hz limits playback - speed to about 2000% on my Mac, 100Hz allows up to 5000% for me) */ - if( hz > 100.0 ) hz = 100.0; - sound_framesiz = *freqptr / hz; -#ifdef __FreeBSD__ - requested.samples = pow( 2.0, floor( log2( sound_framesiz ) ) ); -#else /* #ifdef __FreeBSD__ */ - requested.samples = sound_framesiz; -#endif /* #ifdef __FreeBSD__ */ - - if ( SDL_OpenAudio( &requested, &received ) < 0 ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "Couldn't open sound device: %s", - SDL_GetError() ); - return 1; - } - - *freqptr = received.freq; - - if( received.format != AUDIO_S16SYS ) { - /* close audio and then just let SDL convert to this wacky format at a - supported sample rate */ - SDL_CloseAudio(); - - requested.freq = *freqptr; - sound_framesiz = *freqptr / hz; - requested.samples = sound_framesiz; - - if( SDL_OpenAudio( &requested, NULL ) < 0 ) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "Couldn't open sound device: %s", - SDL_GetError() ); - return 1; - } - } else { - *stereoptr = received.channels == 1 ? 0 : 1; - } - - sound_framesiz = *freqptr / hz; - sound_framesiz <<= 1; - - if( ( error = sfifo_init( &sound_fifo, NUM_FRAMES - * received.channels - * sound_framesiz + 1 ) ) ) { - ui_error( UI_ERROR_ERROR, "Problem initialising sound fifo: %s", - strerror ( error ) ); - return 1; - } - - /* wait to run sound until we have some sound to play */ - audio_output_started = 0; - - return 0; -} - -void -sound_lowlevel_end( void ) -{ - SDL_PauseAudio( 1 ); - SDL_LockAudio(); - SDL_CloseAudio(); - SDL_QuitSubSystem( SDL_INIT_AUDIO ); - sfifo_flush( &sound_fifo ); - sfifo_close( &sound_fifo ); -} - -/* Copy data to fifo */ -void -sound_lowlevel_frame( libspectrum_signed_word *data, int len ) -{ - int i = 0; - - /* Convert to bytes */ - libspectrum_signed_byte* bytes = (libspectrum_signed_byte*)data; - len <<= 1; - - while( len ) { - if( ( i = sfifo_write( &sound_fifo, bytes, len ) ) < 0 ) { - break; - } else if (!i) { - SDL_Delay(10); - } - bytes += i; - len -= i; - } - if( i < 0 ) { - ui_error( UI_ERROR_ERROR, "Couldn't write sound fifo: %s", - strerror( i ) ); - } - - if( !audio_output_started ) { - SDL_PauseAudio( 0 ); - audio_output_started = 1; - } -} - -#ifndef MIN -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) -#endif - -/* Write len samples from fifo into stream */ -void -sdlwrite( void *userdata, Uint8 *stream, int len ) -{ - int f; - - /* Try to only read an even number of bytes so as not to fragment a sample */ - len = MIN( len, sfifo_used( &sound_fifo ) ); - len &= sound_stereo_ay ? 0xfffc : 0xfffe; - - /* Read input_size bytes from fifo into sound stream */ - while( ( f = sfifo_read( &sound_fifo, stream, len ) ) > 0 ) { - stream += f; - len -= f; - } - - /* If we ran out of sound, do nothing else as SDL has prefilled - the output buffer with silence :( */ -} diff --git a/fuse/sound/sfifo.c b/fuse/sound/sfifo.c deleted file mode 100644 index abde430..0000000 --- a/fuse/sound/sfifo.c +++ /dev/null @@ -1,330 +0,0 @@ -/* ------------------------------------------------------------- - SFIFO 1.3 ------------------------------------------------------------- - * Simple portable lock-free FIFO - * (c) 2000-2002, David Olofson - * Released under the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 - - * Modifications by Philip Kendall (c) 2007 - * This modified version is released under the GNU GENERAL PUBLIC LICENSE - * version 2, or any later version ------------------------------------------------------------ -TODO: - * Is there a way to avoid losing one byte of buffer - space to avoid extra variables or locking? - - * Test more compilers and environments. ------------------------------------------------------------ - */ - -#include - -#ifdef __KERNEL__ -# include -# include -# include -# define malloc(x) kmalloc(x, GFP_KERNEL) -# define free(x, y) kfree_s(x, y) -#else -# include -# include -# define free(x, y) free(x) -#endif - -#include "sfifo.h" - -#ifdef _SFIFO_TEST_ -#include -#include -#include -#define DBG(x) /*(x)*/ -#define TEST_BUFSIZE 10 -#else -#define DBG(x) -#endif - - -/* - * Alloc buffer, init FIFO etc... - */ -int sfifo_init(sfifo_t *f, int size) -{ - memset(f, 0, sizeof(sfifo_t)); - - if(size > SFIFO_MAX_BUFFER_SIZE) - return -EINVAL; - - /* - * Set sufficient power-of-2 size. - * - * No, there's no bug. If you need - * room for N bytes, the buffer must - * be at least N+1 bytes. (The fifo - * can't tell 'empty' from 'full' - * without unsafe index manipulations - * otherwise.) - */ - f->size = 1; - for(; f->size <= size; f->size <<= 1) - ; - - /* Get buffer */ - if( 0 == (f->buffer = malloc(f->size)) ) - return -ENOMEM; - - return 0; -} - -/* - * Dealloc buffer etc... - */ -void sfifo_close(sfifo_t *f) -{ - if(f->buffer) - free(f->buffer, f->size); -} - -/* - * Empty FIFO buffer - */ -void sfifo_flush(sfifo_t *f) -{ - /* Reset positions */ - f->readpos = 0; - f->writepos = 0; -} - -/* - * Write bytes to a FIFO - * Return number of bytes written, or an error code - */ -int sfifo_write(sfifo_t *f, const void *_buf, int len) -{ - int total; - int i; - const char *buf = (const char *)_buf; - - if(!f->buffer) - return -ENODEV; /* No buffer! */ - - /* total = len = min(space, len) */ - total = sfifo_space(f); - DBG(printf("sfifo_space() = %d\n",total)); - if(len > total) - len = total; - else - total = len; - - i = f->writepos; - if(i + len > f->size) - { - memcpy(f->buffer + i, buf, f->size - i); - buf += f->size - i; - len -= f->size - i; - i = 0; - } - memcpy(f->buffer + i, buf, len); - f->writepos = i + len; - - return total; -} - -#ifdef __KERNEL__ -/* - * Write bytes to a FIFO from a user space buffer - * Return number of bytes written, or an error code - */ -int sfifo_write_user(sfifo_t *f, const void *buf, int len) -{ - int total; - int i; - - if(!f->buffer) - return -ENODEV; /* No buffer! */ - - /* total = len = min(space, len) */ - total = sfifo_space(f); - if(len > total) - len = total; - else - total = len; - - i = f->writepos; - if(i + len > f->size) - { - if(f->size - i) - { - if(copy_from_user(f->buffer + i, buf, f->size - i)) - return -EFAULT; - buf += f->size - i; - len -= f->size - i; - } - i = 0; - } - if(copy_from_user(f->buffer + i, buf, len)) - return -EFAULT; - f->writepos = i + len; - - return total; -} -#endif - -/* - * Read bytes from a FIFO - * Return number of bytes read, or an error code - */ -int sfifo_read(sfifo_t *f, void *_buf, int len) -{ - int total; - int i; - char *buf = (char *)_buf; - - if(!f->buffer) - return -ENODEV; /* No buffer! */ - - /* total = len = min(used, len) */ - total = sfifo_used(f); - DBG(printf("sfifo_used() = %d\n",total)); - if(len > total) - len = total; - else - total = len; - - i = f->readpos; - if(i + len > f->size) - { - memcpy(buf, f->buffer + i, f->size - i); - buf += f->size - i; - len -= f->size - i; - i = 0; - } - memcpy(buf, f->buffer + i, len); - f->readpos = i + len; - - return total; -} - -#ifdef __KERNEL__ -/* - * Read bytes from a FIFO into a user space buffer - * Return number of bytes read, or an error code - */ -int sfifo_read_user(sfifo_t *f, void *buf, int len) -{ - int total; - int i; - - if(!f->buffer) - return -ENODEV; /* No buffer! */ - - /* total = len = min(used, len) */ - total = sfifo_used(f); - if(len > total) - len = total; - else - total = len; - - i = f->readpos; - if(i + len > f->size) - { - if(f->size - i) - { - if(copy_to_user(buf, f->buffer + i, f->size - i)) - return -EFAULT; - buf += f->size - i; - len -= f->size - i; - } - i = 0; - } - if(copy_to_user(buf, f->buffer + i, len)) - return -EFAULT; - f->readpos = i + len; - - return total; -} -#endif - -#ifdef _SFIFO_TEST_ -void *sender(void *arg) -{ - char buf[TEST_BUFSIZE*2]; - int i,j; - int cnt = 0; - int res; - sfifo_t *sf = (sfifo_t *)arg; - while(1) - { - j = sfifo_space(sf); - for(i = 0; i < j; ++i) - { - ++cnt; - buf[i] = cnt; - } - res = sfifo_write(sf, &buf, j); - if(res != j) - { - printf("Write failed!\n"); - sleep(1); - } else if(res) - printf("Wrote %d\n", res); - } -} -int main() -{ - sfifo_t sf; - char last = 0; - pthread_t thread; - char buf[100] = "---------------------------------------"; - - printf("sfifo_init(&sf, %d) = %d\n", - TEST_BUFSIZE, sfifo_init(&sf, TEST_BUFSIZE) - ); - -#if 0 - printf("sfifo_write(&sf,\"0123456789\",7) = %d\n", - sfifo_write(&sf,"0123456789",7) ); - - printf("sfifo_write(&sf,\"abcdefghij\",7) = %d\n", - sfifo_write(&sf,"abcdefghij",7) ); - - printf("sfifo_read(&sf,buf,8) = %d\n", - sfifo_read(&sf,buf,8) ); - - buf[20] = 0; - printf("buf =\"%s\"\n",buf); - - printf("sfifo_write(&sf,\"0123456789\",7) = %d\n", - sfifo_write(&sf,"0123456789",7) ); - - printf("sfifo_read(&sf,buf,10) = %d\n", - sfifo_read(&sf,buf,10) ); - - buf[20] = 0; - printf("buf =\"%s\"\n",buf); -#else - pthread_create(&thread, NULL, sender, &sf); - - while(1) - { - static int c = 0; - ++last; - while( sfifo_read(&sf,buf,1) != 1 ) - /*sleep(1)*/; - if(last != buf[0]) - { - printf("Error %d!\n", buf[0]-last); - last = buf[0]; - } - else - printf("Ok. (%d)\n",++c); - } -#endif - - sfifo_close(&sf); - printf("sfifo_close(&sf)\n"); - - return 0; -} - -#endif diff --git a/fuse/sound/sfifo.h b/fuse/sound/sfifo.h deleted file mode 100644 index fb12741..0000000 --- a/fuse/sound/sfifo.h +++ /dev/null @@ -1,98 +0,0 @@ -/* ------------------------------------------------------------- - SFIFO 1.3 ------------------------------------------------------------- - * Simple portable lock-free FIFO - * (c) 2000-2002, David Olofson - * Released under the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 - * - * Platform support: - * gcc / Linux / x86: Works - * gcc / Linux / x86 kernel: Works - * gcc / FreeBSD / x86: Works - * gcc / NetBSD / x86: Works - * gcc / Mac OS X / PPC: Works - * gcc / Win32 / x86: Works - * Borland C++ / DOS / x86RM: Works - * Borland C++ / Win32 / x86PM16: Untested - * ? / Various Un*ces / ?: Untested - * ? / Mac OS / PPC: Untested - * gcc / BeOS / x86: Untested - * gcc / BeOS / PPC: Untested - * ? / ? / Alpha: Untested - * - * 1.2: Max buffer size halved, to avoid problems with - * the sign bit... - * - * 1.3: Critical buffer allocation bug fixed! For certain - * requested buffer sizes, older version would - * allocate a buffer of insufficient size, which - * would result in memory thrashing. (Amazing that - * I've manage to use this to the extent I have - * without running into this... *heh*) - */ - -#ifndef _SFIFO_H_ -#define _SFIFO_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/*------------------------------------------------ - "Private" stuff -------------------------------------------------*/ -/* - * Porting note: - * Reads and writes of a variable of this type in memory - * must be *atomic*! 'int' is *not* atomic on all platforms. - * A safe type should be used, and sfifo should limit the - * maximum buffer size accordingly. - */ -typedef int sfifo_atomic_t; -#ifdef __TURBOC__ -# define SFIFO_MAX_BUFFER_SIZE 0x7fff -#else /* Kludge: Assume 32 bit platform */ -# define SFIFO_MAX_BUFFER_SIZE 0x7fffffff -#endif - -typedef struct sfifo_t -{ - char *buffer; - int size; /* Number of bytes */ - sfifo_atomic_t readpos; /* Read position */ - sfifo_atomic_t writepos; /* Write position */ -} sfifo_t; - -#define SFIFO_SIZEMASK(x) ((x)->size - 1) - - -/*------------------------------------------------ - API -------------------------------------------------*/ -int sfifo_init(sfifo_t *f, int size); -void sfifo_close(sfifo_t *f); -void sfifo_flush(sfifo_t *f); -int sfifo_write(sfifo_t *f, const void *buf, int len); -int sfifo_read(sfifo_t *f, void *buf, int len); -#define sfifo_used(x) (((x)->writepos - (x)->readpos) & SFIFO_SIZEMASK(x)) -#define sfifo_space(x) ((x)->size - 1 - sfifo_used(x)) - - -/*------------------------------------------------ - Linux kernel space interface -------------------------------------------------*/ -#ifdef __KERNEL__ -int sfifo_write_user(sfifo_t *f, const void *buf, int len); -int sfifo_read_user(sfifo_t *f, void *buf, int len); -#else -# define sfifo_write_user sfifo_write -# define sfifo_read_user sfifo_read -#endif - -#ifdef __cplusplus -}; -#endif -#endif diff --git a/fuse/sound/sunsound.c b/fuse/sound/sunsound.c deleted file mode 100644 index c7c5e6e..0000000 --- a/fuse/sound/sunsound.c +++ /dev/null @@ -1,203 +0,0 @@ -/* sunsound.c: OpenBSD sound I/O - Copyright (c) 2002-2004 Alexander Yurchenko, Russell Marks, Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -*/ - -#include - -#if defined(__SVR4) && defined(__sun) -#define solaris -#else -#undef solaris -#endif - -#include -#include -#include - -#include -#include -#ifdef solaris -#include -#endif -#include - -#include "settings.h" -#include "sound.h" -#include "ui/ui.h" - -/* using (8) 64 byte frags for 8kHz, scale up for higher */ -#define BASE_SOUND_FRAG_PWR 6 - -static int soundfd = -1; -static int sixteenbit = 0; - -int -sound_lowlevel_init( const char *device, int *freqptr, int *stereoptr ) -{ -#ifndef solaris - int frag; -#endif - int flags; - struct audio_info ai; - - if (device == NULL) - device = "/dev/audio"; - - /* Open the sound device non-blocking to avoid hangs if it is - being used by something else, but then set it blocking - again as that's what we actually want */ - if ((soundfd = open(device, O_WRONLY | O_NONBLOCK )) == -1) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "Couldn't open sound device '%s'", - device ); - return 1; - } - if ((flags = fcntl(soundfd, F_GETFL)) == -1) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, "Couldn't fcntl sound device '%s'", - device ); - close(soundfd); - return 1; - } - flags &= ~O_NONBLOCK; - if (fcntl(soundfd, F_SETFL, flags) == -1) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, - "Couldn't set sound device '%s' blocking", - device ); - close(soundfd); - return 1; - } - - AUDIO_INITINFO(&ai); - - ai.play.encoding = AUDIO_ENCODING_LINEAR; - ai.play.precision = 16; - sixteenbit = 1; - if (settings_current.sound_force_8bit || - ioctl(soundfd, AUDIO_SETINFO, &ai) == -1) { - /* try 8-bit */ - ai.play.encoding = AUDIO_ENCODING_LINEAR8; - ai.play.precision = 8; - sixteenbit = 0; - if (ioctl(soundfd, AUDIO_SETINFO, &ai) == -1) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, - "Couldn't set bit size of sound device '%s'", - device ); - close(soundfd); - return 1; - } - } - - ai.play.channels = *stereoptr ? 2 : 1; - if (ioctl(soundfd, AUDIO_SETINFO, &ai) == -1) { - /* if it failed make sure the opposite is ok */ - ai.play.channels = *stereoptr ? 1 : 2; - if (ioctl(soundfd, AUDIO_SETINFO, &ai) == -1) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, - "Couldn't set channels of sound device '%s'", - device ); - close(soundfd); - return 1; - } - /* FIXME: is this line correct? */ - *stereoptr = *stereoptr ? 1 : 2; - } - - ai.play.sample_rate = *freqptr; - if (ioctl(soundfd, AUDIO_SETINFO, &ai) == -1) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, - "Couldn't set sample rate of sound device '%s'", - device ); - close(soundfd); - return 1; - } - -#ifndef solaris - frag = 0x80000 | BASE_SOUND_FRAG_PWR; - if (*freqptr > 8250) - frag++; - if (*freqptr > 16500) - frag++; - if (*freqptr > 33000) - frag++; - if (*stereoptr) - frag++; - if (sixteenbit) - frag++; - ai.blocksize = 1 << (frag & 0xffff); - ai.hiwat = ((unsigned)frag >> 16) & 0x7fff; - if (ai.hiwat == 0) - ai.hiwat = 65536; - if (ioctl(soundfd, AUDIO_SETINFO, &ai) == -1) { - settings_current.sound = 0; - ui_error( UI_ERROR_ERROR, - "Couldn't set block size of sound device '%s'", - device ); - close(soundfd); - return 1; - } -#endif - - return 0; -} - -void -sound_lowlevel_end( void ) -{ -#ifdef solaris - ioctl(soundfd, I_FLUSH, FLUSHW); -#else - ioctl(soundfd, AUDIO_FLUSH); -#endif - close(soundfd); -} - -void -sound_lowlevel_frame( libspectrum_signed_word *data, int len ) -{ - static unsigned char buf8[4096]; - unsigned char *data8=(unsigned char *)data; - int ret=0, ofs=0; - - len <<= 1; /* now in bytes */ - - if (!sixteenbit) { - libspectrum_signed_word *src; - unsigned char *dst; - int f; - - src = data; dst = buf8; - len >>= 1; - for (f=0; f < len; f++) - *dst++ = 128 + (int)((*src++)/256); - - data8 = buf8; - } - - while (len) { - ret = write (soundfd, data8 + ofs, len); - if (ret > 0) { - ofs += ret; - len -= ret; - } - } -} diff --git a/fuse/sound/wiisound.c b/fuse/sound/wiisound.c deleted file mode 100644 index 503f36e..0000000 --- a/fuse/sound/wiisound.c +++ /dev/null @@ -1,111 +0,0 @@ -/* wiisound.c: Wii sound routines - Copyright (c) 2008-2009 Bjoern Giesler, Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -*/ - -#include - -#include -#include - -#include "fuse.h" -#include "sfifo.h" - -#include -#include - -#ifndef MIN -#define MIN(x,y) ((x) < (y) ? (x) : (y)) -#endif - -int samplerate; -int streamstate; -sfifo_t sound_fifo; - -#define BUFSIZE 16384 -u8 dmabuf[BUFSIZE<<1] ATTRIBUTE_ALIGN(32); -int dmalen = BUFSIZE; - -static void -sound_dmacallback( void ) -{ - if( sfifo_used( &sound_fifo ) < 128) return; - - dmalen = MIN( BUFSIZE, sfifo_used( &sound_fifo ) ); - sfifo_read( &sound_fifo, dmabuf, dmalen ); - DCFlushRange( dmabuf, dmalen ); - AUDIO_InitDMA( (u32)dmabuf, dmalen ); - AUDIO_StartDMA(); -} - -int -sound_lowlevel_init( const char *device, int *freqptr, int *stereoptr ) -{ - switch(*freqptr) { - case 32000: - samplerate = AI_SAMPLERATE_32KHZ; - break; - case 48000: - samplerate = AI_SAMPLERATE_48KHZ; - break; - default: - printf("Sample rate %d not supported on Wii\n", *freqptr); - return 1; - } - - sfifo_init( &sound_fifo, BUFSIZE ); - *stereoptr = 1; - - AUDIO_Init( NULL ); - AUDIO_SetDSPSampleRate( samplerate ); - -#ifndef DISPLAY_AUDIO - AUDIO_RegisterDMACallback( sound_dmacallback ); - memset( dmabuf, 0, BUFSIZE ); - AUDIO_InitDMA( (u32)dmabuf, BUFSIZE ); - DCFlushRange( dmabuf, dmalen ); - AUDIO_StartDMA(); -#endif - - return 0; -} - -void -sound_lowlevel_end( void ) -{ - sfifo_flush( &sound_fifo ); - sfifo_close( &sound_fifo ); - AUDIO_StopDMA(); -} - -void -sound_lowlevel_frame(libspectrum_signed_word *data, int len) -{ - int i; - - libspectrum_signed_byte *bytes = (libspectrum_signed_byte*)data; - len <<= 1; - - while(len) { - if( ( i = sfifo_write( &sound_fifo, bytes, len ) ) < 0 ) - break; - else if( !i ) - usleep(10000); - bytes += i; - len -= i; - } -} diff --git a/fuse/sound/win32sound.c b/fuse/sound/win32sound.c deleted file mode 100644 index 015564b..0000000 --- a/fuse/sound/win32sound.c +++ /dev/null @@ -1,229 +0,0 @@ -/* win32sound.c: Win32 sound using MS Windows Multimedia API - Copyright (c) 2007 Marek Januszewski - Copyright (c) 2015 Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include "settings.h" -#include "sound.h" -#include "ui/ui.h" - -static HWAVEOUT hwaveout; -static WAVEHDR wavehdr[2]; -static HANDLE sem_sound_done; -static CRITICAL_SECTION sound_lock; - -#define BUFFER_SIZE 4096 - -static void *buffers[2]; -static int buffer_used[2]; -static int current_buffer; -static char buffer1[ BUFFER_SIZE ]; -static char buffer2[ BUFFER_SIZE ]; - -static int sixteenbit; - -static void -sound_display_mmresult( const char * const func, MMRESULT result ); - -static void CALLBACK -sound_callback( HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, - DWORD_PTR dwParam1, DWORD_PTR dwParam2 ); - -int -sound_lowlevel_init( const char *device, int *freqptr, int *stereoptr ) -{ - WAVEFORMATEX pcmwf; /* waveformat struct */ - MMRESULT result; - - /* create wave format description */ - memset( &pcmwf, 0, sizeof( WAVEFORMATEX ) ); - - pcmwf.cbSize = 0; - if( settings_current.sound_force_8bit ) { - pcmwf.wBitsPerSample = 8; - sixteenbit = 0; - } else { - pcmwf.wBitsPerSample = 16; - sixteenbit = 1; - } - pcmwf.nChannels = *stereoptr ? 2 : 1; - pcmwf.nBlockAlign = pcmwf.nChannels * ( sixteenbit ? 2 : 1 ); - pcmwf.nSamplesPerSec = *freqptr; - pcmwf.nAvgBytesPerSec = pcmwf.nSamplesPerSec * pcmwf.nBlockAlign; - pcmwf.wFormatTag = WAVE_FORMAT_PCM; - - /* Open sound device for output */ - result = waveOutOpen( &hwaveout, WAVE_MAPPER, - &pcmwf, ( DWORD_PTR ) sound_callback, 0, - CALLBACK_FUNCTION ); - if( result != MMSYSERR_NOERROR ) - sound_display_mmresult( "waveOutOpen", result ); - - buffers[0] = buffer1; - buffers[1] = buffer2; - buffer_used[0] = 0; - buffer_used[1] = 0; - current_buffer = 0; - memset( &wavehdr[0], 0, sizeof( WAVEHDR ) ); - memset( &wavehdr[1], 0, sizeof( WAVEHDR ) ); - - sem_sound_done = CreateSemaphore( NULL, 0, 2, NULL ); - InitializeCriticalSection( &sound_lock ); - - return 0; -} - -void -sound_lowlevel_end( void ) -{ - MMRESULT result; - - /* reset the sound */ - result = waveOutReset( hwaveout ); - if( result != MMSYSERR_NOERROR ) { - settings_current.sound = 0; - sound_display_mmresult( "Couldn't stop sound (waveOutReset)", result ); - return; - } - - /* unprepare wave headers */ - if( wavehdr[ 0 ].dwFlags & WHDR_PREPARED ) { - result = waveOutUnprepareHeader( hwaveout, &wavehdr[ 0 ], sizeof( WAVEHDR ) ); - if( result != MMSYSERR_NOERROR ) - sound_display_mmresult( "waveOutUnprepareHeader", result ); - } - - if( wavehdr[ 1 ].dwFlags & WHDR_PREPARED ) { - result = waveOutUnprepareHeader( hwaveout, &wavehdr[ 1 ], sizeof( WAVEHDR ) ); - if( result != MMSYSERR_NOERROR ) - sound_display_mmresult( "waveOutUnprepareHeader", result ); - } - - /* close the device */ - result = waveOutClose( hwaveout ); - if( result != MMSYSERR_NOERROR ) { - settings_current.sound = 0; - sound_display_mmresult( "Couldn't stop sound (waveOutClose)", result ); - } - - CloseHandle( sem_sound_done ); - DeleteCriticalSection( &sound_lock ); -} - -void -sound_lowlevel_frame( libspectrum_signed_word *data, int len ) -{ - static unsigned char buf8[4096]; - MMRESULT result; - - /* Convert to bytes */ - unsigned char *bytes = (unsigned char *) data; - len <<= 1; - if( !sixteenbit ) { - libspectrum_signed_word *src; - unsigned char *dst; - int f; - - src = data; dst = buf8; - len >>= 1; - /* TODO: confirm byteorder on IA64 */ - for( f = 0; f < len; f++ ) - *dst++ = 128 + (int)( (*src++) / 256 ); - - bytes = buf8; - } - - if( len > BUFFER_SIZE ) { - ui_error( UI_ERROR_WARNING, "%s: requested wave size exceeds the buffer size", __func__ ); - return; - } - - /* wait for the buffer to finish playing */ - if( buffer_used[ current_buffer ] > 0 ) - WaitForSingleObject( sem_sound_done, INFINITE ); - - /* unprepare the header if it's prepared */ - if( wavehdr[ current_buffer ].dwFlags & WHDR_PREPARED ) { - result = waveOutUnprepareHeader( hwaveout, &wavehdr[ current_buffer ], sizeof( WAVEHDR ) ); - if( result != MMSYSERR_NOERROR ) - sound_display_mmresult( "waveOutUnprepareHeader", result ); - } - - /* copy the new wave into the buffer */ - memcpy( buffers[ current_buffer ], bytes, len ); - buffer_used[ current_buffer ] = len; - - /* prepare the header */ - wavehdr[ current_buffer ].lpData = ( LPSTR ) bytes; - wavehdr[ current_buffer ].dwBufferLength = len; - wavehdr[ current_buffer ].dwLoops |= WHDR_BEGINLOOP | WHDR_ENDLOOP; - - result = waveOutPrepareHeader( hwaveout, &wavehdr[ current_buffer ], sizeof( WAVEHDR ) ); - if( result != MMSYSERR_NOERROR ) - sound_display_mmresult( "waveOutPrepareHeader", result ); - - /* play */ - result = waveOutWrite( hwaveout, &wavehdr[ current_buffer ], sizeof( WAVEHDR ) ); - if( result != MMSYSERR_NOERROR ) - sound_display_mmresult( "waveOutWrite", result ); - - /* FIXME this could be done way easier */ - current_buffer++; - if( current_buffer == 2 ) - current_buffer = 0; -} - -static void -sound_display_mmresult( const char * const func, MMRESULT result ) -{ - const char *mmresult; - - switch ( result ) { - case WAVERR_BADFORMAT: mmresult = "WAVERR_BADFORMAT"; break; - case WAVERR_SYNC: mmresult = "WAVERR_SYNC"; break; - case WAVERR_STILLPLAYING: mmresult = "WAVERR_STILLPLAYING"; break; - case MMSYSERR_NOERROR: mmresult = "MMSYSERR_NOERROR"; break; - case MMSYSERR_BADDEVICEID: mmresult = "MMSYSERR_BADDEVICEID"; break; - case MMSYSERR_NODRIVER: mmresult = "MMSYSERR_NODRIVER"; break; - case MMSYSERR_INVALHANDLE: mmresult = "MMSYSERR_INVALHANDLE"; break; - case MMSYSERR_NOMEM: mmresult = "MMSYSERR_NOMEM"; break; - case MMSYSERR_ALLOCATED: mmresult = "MMSYSERR_ALLOCATED"; break; - default: mmresult = "UNKNOWN"; break; - } - - ui_error( UI_ERROR_ERROR, "%s error: %s(error no: %d)", func, mmresult, result ); -} - -static void CALLBACK -sound_callback( HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2 ) -{ - if( uMsg == WOM_DONE ) { - EnterCriticalSection( &sound_lock ); - ReleaseSemaphore( sem_sound_done, 1, NULL ); - LeaveCriticalSection( &sound_lock ); - } -} diff --git a/fuse/spectrum.c b/fuse/spectrum.c index 6eeb582..8e7bd34 100644 --- a/fuse/spectrum.c +++ b/fuse/spectrum.c @@ -39,7 +39,6 @@ #include "peripherals/ula.h" #include "phantom_typist.h" #include "psg.h" -#include "profile.h" #include "rzx.h" #include "settings.h" #include "sound.h" @@ -157,7 +156,6 @@ spectrum_frame( void ) if( sound_enabled ) sound_frame(); if( display_frame() ) return 1; - if( profile_active ) profile_frame( frame_length ); printer_frame(); /* Add an interrupt unless they're being generated by .rzx playback */ diff --git a/fuse/timer/sdl.c b/fuse/timer/sdl.c deleted file mode 100644 index e91565f..0000000 --- a/fuse/timer/sdl.c +++ /dev/null @@ -1,40 +0,0 @@ -/* sdl.c: SDL speed routines for Fuse - Copyright (c) 1999-2008 Philip Kendall, Marek Januszewski, Fredrick Meunier - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include - -#include "timer.h" - -double -timer_get_time( void ) -{ - return SDL_GetTicks() / 1000.0; -} - -void -timer_sleep( int ms ) -{ - SDL_Delay( ms ); -} diff --git a/fuse/timer/timer.c b/fuse/timer/timer.c index 53e1070..d3cd8f7 100644 --- a/fuse/timer/timer.c +++ b/fuse/timer/timer.c @@ -25,7 +25,6 @@ #include "event.h" #include "infrastructure/startup_manager.h" -#include "movie.h" #include "phantom_typist.h" #include "settings.h" #include "sound.h" @@ -138,32 +137,6 @@ timer_register_startup( void ) timer_end ); } -#ifdef SOUND_FIFO - -/* Callback-style sound based timer */ -#include "sound/sfifo.h" - -extern sfifo_t sound_fifo; - -static void -timer_frame_callback_sound( libspectrum_dword last_tstates ) -{ - for(;;) { - - /* Sleep while fifo is full */ - if( sfifo_space( &sound_fifo ) < sound_framesiz ) { - timer_sleep( TEN_MS ); - } else { - break; - } - - } - - event_add( last_tstates + machine_current->timings.tstates_per_frame, - timer_event ); -} - -#else /* #ifdef SOUND_FIFO */ /* Blocking socket-style sound based timer */ static void @@ -173,7 +146,6 @@ timer_frame_callback_sound( libspectrum_dword last_tstates ) timer_event ); } -#endif /* #ifdef SOUND_FIFO */ void timer_start_fastloading( void ) diff --git a/fuse/ui.c b/fuse/ui.c index 282e0cc..8dba135 100644 --- a/fuse/ui.c +++ b/fuse/ui.c @@ -38,13 +38,9 @@ #include "tape.h" #include "ui/ui.h" #include "ui/uimedia.h" -#include "ui/widget/widget.h" #define MESSAGE_MAX_LENGTH 256 -/* We don't start in a widget */ -int ui_widget_level = -1; - static char last_message[ MESSAGE_MAX_LENGTH ] = ""; static size_t frames_since_last_message = 0; @@ -775,19 +771,6 @@ ui_mdr_write( int which, int saveas ) return err; } -#ifdef USE_WIDGET -int -ui_widget_init( void ) -{ - return widget_init(); -} - -int -ui_widget_end( void ) -{ - return widget_end(); -} -#else int ui_widget_init( void ) { @@ -809,4 +792,3 @@ void ui_widget_keyhandler( int native_key ) { } -#endif /* #ifndef USE_WIDGET */ diff --git a/fuse/ui/fb/Makefile.am b/fuse/ui/fb/Makefile.am deleted file mode 100644 index 05c0832..0000000 --- a/fuse/ui/fb/Makefile.am +++ /dev/null @@ -1,49 +0,0 @@ -## Process this file with automake to produce Makefile.in -## Copyright (c) 2001-2004 Philip Kendall -## Copyright (c) 2015 Sergio Baldoví - -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -## -## Author contact information: -## -## E-mail: philip-fuse@shadowmagic.org.uk - -if UI_FB - -fuse_SOURCES += $(ui_fb_files) - -BUILT_SOURCES += $(ui_fb_built) - -endif - - -CLEANFILES += $(ui_fb_built) - -ui_fb_files = \ - ui/fb/fbdisplay.c \ - ui/fb/fbdisplay.h \ - ui/fb/fbjoystick.c \ - ui/fb/fbkeyboard.c \ - ui/fb/fbkeyboard.h \ - ui/fb/fbmouse.c \ - ui/fb/fbmouse.h \ - ui/fb/fbui.c \ - ui/fb/keysyms.c - -ui_fb_built = ui/fb/keysyms.c - -ui/fb/keysyms.c: $(srcdir)/keysyms.pl $(srcdir)/keysyms.dat - @$(MKDIR_P) ui/fb - $(AM_V_GEN)$(PERL) -I$(srcdir)/perl $(srcdir)/keysyms.pl fb $(srcdir)/keysyms.dat > $@.tmp && mv $@.tmp $@ diff --git a/fuse/ui/fb/fbdisplay.c b/fuse/ui/fb/fbdisplay.c deleted file mode 100644 index e51515b..0000000 --- a/fuse/ui/fb/fbdisplay.c +++ /dev/null @@ -1,549 +0,0 @@ -/* fbdisplay.c: Routines for dealing with the linux fbdev display - Copyright (c) 2000-2003 Philip Kendall, Matan Ziv-Av, Darren Salt, - Witold Filipczyk - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "fbdisplay.h" -#include "fuse.h" -#include "display.h" -#include "screenshot.h" -#include "ui/ui.h" -#include "ui/uidisplay.h" -#include "settings.h" - -/* A copy of every pixel on the screen */ -libspectrum_word - fbdisplay_image[ 2 * DISPLAY_SCREEN_HEIGHT ][ DISPLAY_SCREEN_WIDTH ]; -ptrdiff_t fbdisplay_pitch = DISPLAY_SCREEN_WIDTH * sizeof( libspectrum_word ); - -/* The environment variable specifying which device to use */ -static const char * const DEVICE_VARIABLE = "FRAMEBUFFER"; - -/* The device we will use if device_env_variable is not specified */ -static const char * const DEFAULT_DEVICE = "/dev/fb0"; - -/* The size of a 1x1 image in units of - DISPLAY_ASPECT WIDTH x DISPLAY_SCREEN_HEIGHT */ -int image_scale; - -/* The height and width of a 1x1 image in pixels */ -int image_width, image_height; - -/* Are we in a Timex display mode? */ -static int hires; - -static void register_scalers( void ); - -/* probably 0rrrrrgggggbbbbb */ -static short rgbs[16], greys[16]; - -static int fb_fd = -1; /* The framebuffer's file descriptor */ -static libspectrum_word *gm = 0; - -static struct fb_fix_screeninfo fixed; -static struct fb_var_screeninfo orig_display, display; -static int got_orig_display = 0; -static int changed_palette = 0; - -unsigned long fb_resolution; /* == xres << 16 | yres */ -#define FB_RES(X,Y) ((X) << 16 | (Y)) -#define FB_WIDTH (fb_resolution >> 16) -#define IF_FB_WIDTH(X) ((fb_resolution >> 16) == (X)) -#define IF_FB_HEIGHT(Y) ((fb_resolution & 0xFFFF) == (Y)) -#define IF_FB_RES(X, Y) (fb_resolution == FB_RES ((X), (Y))) - -typedef struct { - int xres, yres, pixclock; - int left_margin, right_margin, upper_margin, lower_margin; - int hsync_len, vsync_len; - int sync, doublescan; -} fuse_fb_mode_t; - -/* Test monitor is a Compaq V50, default settings - * A = working on ATI RV100 (Radeon 7000) (2.6.x, old radeonfb) - * M = working on Matrox MGA2064W (Millennium I) (2.6.x, matroxfb) - * Large/tall/wide = size indication (overscan) - * The 640x480 modes are from /etc/fb.modes and should work anywhere. - * - * x y clock lm rm tm bm hl vl s d - */ -static const fuse_fb_mode_t fb_modes_singlescan[] = { - { 640, 480, 32052, 96, 56, 28, 9, 40, 3, 0, 0 }, /* 640x480-72 72.114 */ - { 640, 480, 39722, 48, 16, 33, 10, 96, 2, 0, 0 }, /* 640x480-60 59.940 std */ - { 0 } /* end of list */ -}; -static const fuse_fb_mode_t fb_modes_doublescan[] = { - { 640, 240, 32052, 92, 56, 14, 4, 40, 3, 0, 1 }, /* 640x240-72 72.185 */ - { 640, 480, 32052, 96, 56, 28, 9, 40, 3, 0, 0 }, /* 640x480-72 72.114 */ - { 640, 480, 39722, 48, 16, 33, 10, 96, 2, 0, 0 }, /* 640x480-60 59.940 std */ - { 320, 240, 64104, 46, 28, 14, 4, 20, 3, 3, 1 }, /* 320x240-72 72.185 M wide */ - { 0 } /* end of list */ -}; -static const fuse_fb_mode_t fb_modes_doublescan_alt[] = { - { 640, 240, 39722, 36, 12, 18, 7, 96, 2, 1, 1 }, /* 640x240-60 60.133 AM large */ - { 640, 480, 32052, 96, 56, 28, 9, 40, 3, 0, 0 }, /* 640x480-72 72.114 */ - { 640, 480, 39722, 48, 16, 33, 10, 96, 2, 0, 0 }, /* 640x480-60 59.940 std */ - { 320, 240, 79444, 18, 6, 18, 7, 48, 2, 1, 1 }, /* 320x240-60 60.133 AM large */ - { 0 } /* end of list */ -}; -/* Modes not used but which may work are listed here. - * x y clock lm rm tm bm hl vl s d - { 640, 480, 22272, 48, 32, 17, 22, 128, 12, 0, 0 }, ** 640x480-100 99.713 - { 640, 480, 25057, 120, 32, 14, 25, 40, 14, 0, 0 }, ** 640x480-90 89.995 - { 640, 480, 31747, 120, 16, 16, 1, 64, 3, 0, 0 }, ** 640x480-75 74.998 - { 320, 240, 80000, 40, 28, 9, 2, 20, 3, 0, 1 }, ** 320x240-60 60.310 M tall - { 320, 240, 55555, 52, 16, 12, 0, 28, 2, 0, 1 }, ** 320x240-85 85.177 M - */ - -static unsigned short red16[256], green16[256], blue16[256], transp16[256]; -static struct fb_cmap orig_cmap = {0, 256, red16, green16, blue16, transp16}; - -static int fb_set_mode( void ); - -int uidisplay_init( int width, int height ) -{ - hires = ( width == 640 ? 1 : 0 ); - - image_width = width; image_height = height; - image_scale = width / DISPLAY_ASPECT_WIDTH; - - register_scalers(); - - display_ui_initialised = 1; - - display_refresh_all(); - - return 0; -} - -static void -register_scalers( void ) -{ - scaler_register_clear(); - scaler_select_bitformat( 565 ); /* 16bit always */ - scaler_register( SCALER_NORMAL ); -} - -static void -linear_palette(struct fb_cmap *p_cmap) -{ - int i; - int rcols = 1 << display.red.length; - int gcols = 1 << display.green.length; - int bcols = 1 << display.blue.length; - - for (i = 0; i < rcols; i++) - p_cmap->red[i] = (65535 / (rcols - 1)) * i; - - for (i = 0; i < gcols; i++) - p_cmap->green[i] = (65535 / (gcols - 1)) * i; - - for (i = 0; i < bcols; i++) - p_cmap->blue[i] = (65535 / (bcols - 1)) * i; -} - -int fbdisplay_init(void) -{ - int i; - const char *dev; - - static libspectrum_word r16[256], g16[256], b16[256]; - static struct fb_cmap fb_cmap = { - 0, 256, r16, g16, b16, NULL - }; - - dev = getenv( DEVICE_VARIABLE ); - if( !dev || !*dev ) dev = DEFAULT_DEVICE; - - fb_fd = open( dev, O_RDWR | O_EXCL ); - if( fb_fd == -1 ) { - fprintf( stderr, "%s: couldn't open framebuffer device '%s'\n", - fuse_progname, dev ); - return 1; - } - if( ioctl( fb_fd, FBIOGET_FSCREENINFO, &fixed ) || - ioctl( fb_fd, FBIOGET_VSCREENINFO, &orig_display ) ) { - fprintf( stderr, "%s: couldn't read info from framebuffer device '%s'\n", - fuse_progname, dev ); - return 1; - } - got_orig_display = 1; - - if( fb_set_mode() ) return 1; - - fputs( "\x1B[H\x1B[J", stdout ); /* clear tty */ - memset( gm, 0, display.xres_virtual * display.yres_virtual * 2 ); - - - display.activate = FB_ACTIVATE_NOW; - if( ioctl( fb_fd, FBIOPUT_VSCREENINFO, &display ) ) { - fprintf( stderr, "%s: couldn't set mode for framebuffer device '%s'\n", - fuse_progname, dev ); - return 1; - } - - ioctl( fb_fd, FBIOGET_VSCREENINFO, &display); - for( i = 0; i < 16; i++ ) { - int v = ( i & 8 ) ? 0xff : 0xbf; - int c; - rgbs[i] = ( ( i & 1 ) ? (v >> (8 - display.blue.length)) << display.blue.offset : 0 ) - | ( ( i & 2 ) ? (v >> (8 - display.red.length)) << display.red.offset : 0 ) - | ( ( i & 4 ) ? (v >> (8 - display.green.length)) << display.green.offset : 0 ); - - c = (( i & 1 ) ? (v * 0.114) : 0.0) + - (( i & 2) ? (v * 0.299) : 0.0) + - (( i & 4) ? (v * 0.587) : 0.0) + 0.5; - greys[i] = (c >> (8 - display.red.length) << display.red.offset) - | (c >> (8 - display.green.length) << display.green.offset) - | (c >> (8 - display.blue.length) << display.blue.offset); - } - linear_palette(&fb_cmap); - - if (orig_display.bits_per_pixel == 8 || fixed.visual == FB_VISUAL_DIRECTCOLOR) { - ioctl( fb_fd, FBIOGETCMAP, &orig_cmap); - changed_palette = 1; - } - ioctl( fb_fd, FBIOGET_FSCREENINFO, &fixed); - if ( fixed.visual == FB_VISUAL_DIRECTCOLOR) { - ioctl( fb_fd, FBIOPUTCMAP, &fb_cmap ); - } - sleep( 1 ); /* give the monitor time to sync before we start emulating */ - - fputs( "\x1B[?25l", stdout ); /* hide cursor */ - fflush( stdout ); - - return 0; -} - -static int -fb_select_mode( const fuse_fb_mode_t *fb_mode ) -{ - memset (&display, 0, sizeof (struct fb_var_screeninfo)); - display.xres_virtual = display.xres = fb_mode->xres; - display.yres_virtual = display.yres = fb_mode->yres; - display.xoffset = display.yoffset = 0; - display.grayscale = 0; - display.nonstd = 0; - display.accel_flags = 0; - display.pixclock = fb_mode->pixclock; - display.left_margin = fb_mode->left_margin; - display.right_margin = fb_mode->right_margin; - display.upper_margin = fb_mode->upper_margin; - display.lower_margin = fb_mode->lower_margin; - display.hsync_len = fb_mode->hsync_len; - display.vsync_len = fb_mode->vsync_len; - display.sync = fb_mode->sync; - display.vmode &= ~FB_VMODE_MASK; - if( fb_mode->doublescan ) display.vmode |= FB_VMODE_DOUBLE; - display.vmode |= FB_VMODE_CONUPDATE; - - display.bits_per_pixel = 16; - display.red.length = display.green.length = display.blue.length = 5; - - display.red.offset = 0; - display.green.offset = 5; - display.blue.offset = 10; - - gm = mmap( 0, fixed.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb_fd, 0 ); - if( gm == (void*)-1 ) { - fprintf (stderr, "%s: couldn't mmap for framebuffer: %s\n", - fuse_progname, strerror( errno ) ); - return 1; - } - - display.activate = FB_ACTIVATE_TEST; - if( ioctl( fb_fd, FBIOPUT_VSCREENINFO, &display ) ) { - munmap( gm, fixed.smem_len ); - return 1; - } - - fb_resolution = FB_RES( display.xres, display.yres ); - return 0; /* success */ -} - -static int -fb_set_mode( void ) -{ - size_t i; - - const fuse_fb_mode_t *fb_modes = - (settings_current.doublescan_mode == 0) ? fb_modes_singlescan : - (settings_current.doublescan_mode == 1) ? fb_modes_doublescan : - fb_modes_doublescan_alt; - - /* First, try to use our preferred mode */ - for( i=0; fb_modes[i].xres; i++ ) - if( fb_modes[i].xres == settings_current.fb_mode ) - if( !fb_select_mode( fb_modes + i ) ) - return 0; - - /* If that failed, try to use the first available mode */ - for( i=0; fb_modes[i].xres; i++ ) - if( !fb_select_mode( fb_modes + i ) ) - return 0; - - /* If that failed, we can't continue :-( */ - fprintf( stderr, "%s: couldn't find a framebuffer mode to start in\n", - fuse_progname ); - return 1; -} - -int -uidisplay_hotswap_gfx_mode( void ) -{ - return 0; -} - -void -uidisplay_frame_end( void ) -{ - return; -} - -void -uidisplay_area( int x, int start, int width, int height) -{ - int y; - const short *colours = settings_current.bw_tv ? greys : rgbs; - - switch( fb_resolution ) { - case FB_RES( 640, 480 ): - for( y = start; y < start + height; y++ ) - { - int i; - libspectrum_word *point; - - if( hires ) { - - for( i = 0, point = gm + y * display.xres_virtual + x; - i < width; - i++, point++ ) - *point = colours[fbdisplay_image[y][x+i]]; - - } else { - - for( i = 0, point = gm + 2 * y * display.xres_virtual + x * 2; - i < width; - i++, point += 2 ) - * point = *( point + display.xres_virtual ) = - *( point + 1 ) = *( point + 1 + display.xres_virtual ) = - colours[fbdisplay_image[y][x+i]]; - - } - } - break; - - case FB_RES( 640, 240 ): - if( hires ) { start >>= 1; height >>= 1; } - for( y = start; y < start + height; y++ ) - { - int i; - libspectrum_word *point; - - if( hires ) { - - for ( i = 0, point = gm + y * display.xres_virtual + x; - i < width; - i++, point++ ) - *point = colours[fbdisplay_image[y*2][x+i]]; - - } else { - - for( i = 0, point = gm + y * display.xres_virtual + x * 2; - i < width; - i++, point+=2 ) - *point = *(point+1) = colours[fbdisplay_image[y][x+i]]; - - } - } - break; - - case FB_RES( 320, 240 ): - if( hires ) { start >>= 1; height >>= 1; x >>= 1; width >>= 1; } - for( y = start; y < start + height; y++ ) - { - int i; - libspectrum_word *point; - - if( hires ) { - - /* Drop every second pixel */ - for ( i = 0, point = gm + y * display.xres_virtual + x; - i < width; - i++, point++ ) - *point = colours[fbdisplay_image[y*2][(x+i)*2]]; - - } else { - - for( i = 0, point = gm + y * display.xres_virtual + x; - i < width; - i++, point++ ) - *point = colours[fbdisplay_image[y][x+i]]; - - } - - } - break; - - default:; /* Shut gcc up */ - } -} - -int -uidisplay_end( void ) -{ - return 0; -} - -int -fbdisplay_end( void ) -{ - if( fb_fd != -1 ) { - if( got_orig_display ) { - ioctl( fb_fd, FBIOPUT_VSCREENINFO, &orig_display ); - if (changed_palette) { - ioctl( fb_fd, FBIOPUTCMAP, &orig_cmap); - changed_palette = 0; - } - } - close( fb_fd ); - fb_fd = -1; - fputs( "\x1B[H\x1B[J\x1B[?25h", stdout ); /* clear screen, show cursor */ - } - - return 0; -} - -/* Set one pixel in the display */ -void -uidisplay_putpixel( int x, int y, int colour ) -{ - if( machine_current->timex ) { - x <<= 1; y <<= 1; - fbdisplay_image[y ][x ] = colour; - fbdisplay_image[y ][x+1] = colour; - fbdisplay_image[y+1][x ] = colour; - fbdisplay_image[y+1][x+1] = colour; - } else { - fbdisplay_image[y][x] = colour; - } -} - -/* Print the 8 pixels in `data' using ink colour `ink' and paper - colour `paper' to the screen at ( (8*x) , y ) */ -void -uidisplay_plot8( int x, int y, libspectrum_byte data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - x <<= 3; - - if( machine_current->timex ) { - int i; - - x <<= 1; y <<= 1; - for( i=0; i<2; i++,y++ ) { - fbdisplay_image[y][x+ 0] = ( data & 0x80 ) ? ink : paper; - fbdisplay_image[y][x+ 1] = ( data & 0x80 ) ? ink : paper; - fbdisplay_image[y][x+ 2] = ( data & 0x40 ) ? ink : paper; - fbdisplay_image[y][x+ 3] = ( data & 0x40 ) ? ink : paper; - fbdisplay_image[y][x+ 4] = ( data & 0x20 ) ? ink : paper; - fbdisplay_image[y][x+ 5] = ( data & 0x20 ) ? ink : paper; - fbdisplay_image[y][x+ 6] = ( data & 0x10 ) ? ink : paper; - fbdisplay_image[y][x+ 7] = ( data & 0x10 ) ? ink : paper; - fbdisplay_image[y][x+ 8] = ( data & 0x08 ) ? ink : paper; - fbdisplay_image[y][x+ 9] = ( data & 0x08 ) ? ink : paper; - fbdisplay_image[y][x+10] = ( data & 0x04 ) ? ink : paper; - fbdisplay_image[y][x+11] = ( data & 0x04 ) ? ink : paper; - fbdisplay_image[y][x+12] = ( data & 0x02 ) ? ink : paper; - fbdisplay_image[y][x+13] = ( data & 0x02 ) ? ink : paper; - fbdisplay_image[y][x+14] = ( data & 0x01 ) ? ink : paper; - fbdisplay_image[y][x+15] = ( data & 0x01 ) ? ink : paper; - } - } else { - fbdisplay_image[y][x+ 0] = ( data & 0x80 ) ? ink : paper; - fbdisplay_image[y][x+ 1] = ( data & 0x40 ) ? ink : paper; - fbdisplay_image[y][x+ 2] = ( data & 0x20 ) ? ink : paper; - fbdisplay_image[y][x+ 3] = ( data & 0x10 ) ? ink : paper; - fbdisplay_image[y][x+ 4] = ( data & 0x08 ) ? ink : paper; - fbdisplay_image[y][x+ 5] = ( data & 0x04 ) ? ink : paper; - fbdisplay_image[y][x+ 6] = ( data & 0x02 ) ? ink : paper; - fbdisplay_image[y][x+ 7] = ( data & 0x01 ) ? ink : paper; - } -} - -/* Print the 16 pixels in `data' using ink colour `ink' and paper - colour `paper' to the screen at ( (16*x) , y ) */ -void -uidisplay_plot16( int x, int y, libspectrum_word data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - int i; - x <<= 4; y <<= 1; - - for( i=0; i<2; i++,y++ ) { - fbdisplay_image[y][x+ 0] = ( data & 0x8000 ) ? ink : paper; - fbdisplay_image[y][x+ 1] = ( data & 0x4000 ) ? ink : paper; - fbdisplay_image[y][x+ 2] = ( data & 0x2000 ) ? ink : paper; - fbdisplay_image[y][x+ 3] = ( data & 0x1000 ) ? ink : paper; - fbdisplay_image[y][x+ 4] = ( data & 0x0800 ) ? ink : paper; - fbdisplay_image[y][x+ 5] = ( data & 0x0400 ) ? ink : paper; - fbdisplay_image[y][x+ 6] = ( data & 0x0200 ) ? ink : paper; - fbdisplay_image[y][x+ 7] = ( data & 0x0100 ) ? ink : paper; - fbdisplay_image[y][x+ 8] = ( data & 0x0080 ) ? ink : paper; - fbdisplay_image[y][x+ 9] = ( data & 0x0040 ) ? ink : paper; - fbdisplay_image[y][x+10] = ( data & 0x0020 ) ? ink : paper; - fbdisplay_image[y][x+11] = ( data & 0x0010 ) ? ink : paper; - fbdisplay_image[y][x+12] = ( data & 0x0008 ) ? ink : paper; - fbdisplay_image[y][x+13] = ( data & 0x0004 ) ? ink : paper; - fbdisplay_image[y][x+14] = ( data & 0x0002 ) ? ink : paper; - fbdisplay_image[y][x+15] = ( data & 0x0001 ) ? ink : paper; - } -} - -void -uidisplay_frame_save( void ) -{ - /* FIXME: Save current framebuffer state as the widget UI wants to scribble - in here */ -} - -void -uidisplay_frame_restore( void ) -{ - /* FIXME: Restore saved framebuffer state as the widget UI wants to draw a - new menu */ -} diff --git a/fuse/ui/fb/fbdisplay.h b/fuse/ui/fb/fbdisplay.h deleted file mode 100644 index 277ce59..0000000 --- a/fuse/ui/fb/fbdisplay.h +++ /dev/null @@ -1,30 +0,0 @@ -/* fbdisplay.h: Routines for dealing with the framebuffer display - Copyright (c) 2003 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#ifndef FUSE_FBDISPLAY_H -#define FUSE_FBDISPLAY_H - -int fbdisplay_init( void ); -int fbdisplay_end( void ); - -#endif /* #ifndef FUSE_FBDISPLAY_H */ diff --git a/fuse/ui/fb/fbjoystick.c b/fuse/ui/fb/fbjoystick.c deleted file mode 100644 index 867c871..0000000 --- a/fuse/ui/fb/fbjoystick.c +++ /dev/null @@ -1,29 +0,0 @@ -/* fbjoystick.c: Joystick emulation - Copyright (c) 2003 Darren Salt - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - - Darren: linux@youmustbejoking.demon.co.uk - -*/ - -#include - -#include "peripherals/joystick.h" -#include "../uijoystick.c" diff --git a/fuse/ui/fb/fbkeyboard.c b/fuse/ui/fb/fbkeyboard.c deleted file mode 100644 index d2d7aa0..0000000 --- a/fuse/ui/fb/fbkeyboard.c +++ /dev/null @@ -1,147 +0,0 @@ -/* fbkeyboard.c: routines for dealing with the linux fbdev display - Copyright (c) 2000-2004 Philip Kendall, Matan Ziv-Av, Darren Salt - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "display.h" -#include "fuse.h" -#include "keyboard.h" -#include "machine.h" -#include "settings.h" -#include "snapshot.h" -#include "spectrum.h" -#include "tape.h" -#include "ui/ui.h" - -#include "input.h" - -static struct termios old_ts; -static int old_kbmode = K_XLATE; -static int got_old_ts = 0; - -int fbkeyboard_init(void) -{ - struct termios ts; - struct stat st; - int i = 1; - - /* First, set up the keyboard */ - if( fstat( STDIN_FILENO, &st ) ) { - fprintf( stderr, "%s: couldn't stat stdin: %s\n", fuse_progname, - strerror( errno ) ); - return 1; - } - - /* check for character special, major 4, minor 0..63 */ - if( !isatty(STDIN_FILENO) || !S_ISCHR(st.st_mode) || - ( st.st_rdev & ~63 ) != 0x0400 ) { - fprintf( stderr, "%s: stdin isn't a local tty\n", fuse_progname ); - return 1; - } - - tcgetattr( STDIN_FILENO, &old_ts ); - ioctl( STDIN_FILENO, KDGKBMODE, &old_kbmode ); - got_old_ts = 1; - - /* We need non-blocking semi-cooked keyboard input */ - if( ioctl( STDIN_FILENO, FIONBIO, &i ) ) { - fprintf( stderr, "%s: can't set stdin nonblocking: %s\n", fuse_progname, - strerror( errno ) ); - return 1; - } - if( ioctl( STDIN_FILENO, KDSKBMODE, K_MEDIUMRAW ) ) { - fprintf( stderr, "%s: can't set keyboard into medium-raw mode: %s\n", - fuse_progname, strerror( errno ) ); - return 1; - } - - /* Add in a bit of voodoo... */ - ts = old_ts; - ts.c_cc[VTIME] = 0; - ts.c_cc[VMIN] = 1; - ts.c_lflag &= ~(ICANON | ECHO | ISIG); - ts.c_iflag = 0; - tcsetattr( STDIN_FILENO, TCSAFLUSH, &ts ); - tcsetpgrp( STDIN_FILENO, getpgrp() ); - - return 0; -} - -int fbkeyboard_end(void) -{ - int i = 0; - - ioctl( STDIN_FILENO, FIONBIO, &i ); - if( got_old_ts ) { - tcsetattr( STDIN_FILENO, TCSAFLUSH, &old_ts ); - ioctl( STDIN_FILENO, KDSKBMODE, old_kbmode ); - } - - return 0; -} - -void -keyboard_update( void ) -{ - unsigned char keybuf[64]; - static int ignore = 0; - - while( 1 ) { - ssize_t available, i; - - available = read( STDIN_FILENO, &keybuf, sizeof( keybuf ) ); - if( available <= 0 ) return; - - for( i = 0; i < available; i++ ) - if( ignore ) { - ignore--; - } else if( ( keybuf[i] & 0x7f ) == 0 ) { - ignore = 2; /* ignore extended keysyms */ - } else { - input_key fuse_keysym; - input_event_t fuse_event; - - fuse_keysym = keysyms_remap( keybuf[i] & 0x7f ); - - if( fuse_keysym == INPUT_KEY_NONE ) continue; - - fuse_event.type = ( keybuf[i] & 0x80 ) ? - INPUT_EVENT_KEYRELEASE : - INPUT_EVENT_KEYPRESS; - fuse_event.types.key.native_key = fuse_keysym; - fuse_event.types.key.spectrum_key = fuse_keysym; - - input_event( &fuse_event ); - } - } -} diff --git a/fuse/ui/fb/fbkeyboard.h b/fuse/ui/fb/fbkeyboard.h deleted file mode 100644 index 2bdaa68..0000000 --- a/fuse/ui/fb/fbkeyboard.h +++ /dev/null @@ -1,36 +0,0 @@ -/* fbkeyboard.h: routines for dealing with the buttons interface - Copyright (c) 2000-2001 Philip Kendall, Matan Ziv-Av - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#ifndef FUSE_FBKEYBOARD_H -#define FUSE_FBKEYBOARD_H - -int fbkeyboard_init(void); - -int fbkeyboard_keypress(int keysym); -void fbkeyboard_keyrelease(int keysym); - -int fbkeyboard_end(void); - -void keyboard_update(void); - -#endif /* #ifndef FUSE_FBKEYBOARD_H */ diff --git a/fuse/ui/fb/fbmouse.c b/fuse/ui/fb/fbmouse.c deleted file mode 100644 index 6535d86..0000000 --- a/fuse/ui/fb/fbmouse.c +++ /dev/null @@ -1,264 +0,0 @@ -/* fbmouse.c: Linux mouse handling code (requires kernel input layer) - Copyright (c) 2004 Darren Salt - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: linux@youmustbejoking.demon.co.uk - -*/ - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "fuse.h" -#include "fbmouse.h" -#include "ui/ui.h" - -#include - -#ifdef HAVE_GPM_H -#include -static void *libgpm = NULL; -static typeof (Gpm_GetEvent) *gpm_getevent = 0; -static typeof (gpm_fd) gpmfd = 0; -static const typeof (gpm_flag) zero = 0; -static typeof (&zero) gpmflag = &zero; -#endif - -static int mouse_fd = -1; -static enum { PS2, ImPS2, ExPS2 } mouse_mode = PS2; -static int packet_size = 3; - -static int try_open( const char * ); -static int try_mouse_mode( unsigned char, unsigned char ); - -int -fbmouse_init(void) -{ - int i; -#ifdef HAVE_GPM_H - static Gpm_Connect conn = { ~0/*GPM_MOVE | GPM_DOWN | GPM_UP*/, 0, 0, ~0 }; - - libgpm = dlopen( "libgpm.so", RTLD_LAZY ); - - if( libgpm ) { - typeof (Gpm_Open) *gpm_open = dlsym( libgpm, "Gpm_Open" ); - i = 1; - if( gpm_open( &conn, 0 ) != -1 ) { - gpmfd = *( typeof( &gpm_fd ) ) dlsym( libgpm, "gpm_fd" ); - gpmflag = ( typeof( &gpm_flag ) ) dlsym( libgpm, "gpm_flag" ); - gpm_getevent = dlsym( libgpm, "Gpm_GetEvent" ); - ui_mouse_present = 1; - return 0; - } - } else - fprintf( stderr, "%s: couldn't init libgpm: %s\n", fuse_progname, - dlerror() ); -#endif - - /* No libgpm support, no libgpm or gpm is not running - use our own code */ - if( try_open ("/dev/input/mice") && - try_open ("/dev/mouse") && - try_open ("/dev/psaux") ) { - if( errno == ENOENT || errno == ENODEV || errno == EACCES ) { - fprintf( stderr, "%s: warning: no mouse, or not accessible\n", - fuse_progname ); - return 0; - } - fprintf( stderr, "%s: couldn't open mouse device: %s\n", - fuse_progname, strerror( errno ) ); - return 1; - } - - /* Try to select plain PS/2 (just in case it's not already selected). - * Ignore any error. - */ - i = -1; /* account for big-endian */ - write( mouse_fd, &i, 1 ); - - /* Try to set the mouse mode. We prefer ExPS/2 but will accept ImPS/2. - * The main reason is so that the side buttons don't appear as duplicate - * buttons 2 and 3, and so that the wheel is available should it be wanted - * somewhere. - */ - if( !try_mouse_mode( 100, 3 ) ) { - packet_size = 4; - mouse_mode = try_mouse_mode( 200, 4 ) ? ImPS2 : ExPS2; - } - - /* *Now* we want non-blocking I/O... */ - i = 1; - if( ioctl( mouse_fd, FIONBIO, &i ) ) - return fbmouse_end(); /* couldn't get it */ - - ui_mouse_present = 1; - return 0; -} - -int -fbmouse_end(void) -{ -#ifdef HAVE_GPM_H - if( *gpmflag ) { - typeof (Gpm_Close) *gpm_close = dlsym( libgpm, "Gpm_Close" ); - gpm_close(); - } -#endif - if( mouse_fd != -1 ) { - close( mouse_fd ); - mouse_fd = -1; - } - return 0; -} - -#ifdef HAVE_GPM_H -static void mouse_update_gpm( void ); -static void mouse_update_ps2( void ); - -void -mouse_update( void ) -{ - if( *gpmflag ) - mouse_update_gpm(); - else - mouse_update_ps2(); -} - -static void -mouse_update_gpm( void ) -{ - Gpm_Event event; - int db; - static int oldbuttons = 0; - - if( gpmfd < 0 ) { - static int t = 0; - if (!t) fprintf (stderr, "gpm not there?\n"); - t = 1; - return; - } - - for (;;) { - struct pollfd ufd = { gpmfd, POLLIN | POLLPRI }; - if( poll( &ufd, 1, 0 ) < 1 ) break; - - gpm_getevent( &event ); - - if( !ui_mouse_grabbed ) continue; - - if( event.dx | event.dy ) ui_mouse_motion( event.dx, event.dy ); - - db = event.buttons ^ oldbuttons; - if( db ) { - oldbuttons = event.buttons; - if( db & GPM_B_LEFT ) ui_mouse_button( 1, event.buttons & GPM_B_LEFT ); - if( db & GPM_B_RIGHT ) ui_mouse_button( 3, event.buttons & GPM_B_RIGHT ); - } - } -} -#endif - -/* Simple PS/2 mouse handler. - * Should cope with any similar 3- and 4-byte protocol which is a superset of - * plain PS/2: e.g. ImPS/2, ExPS/2 but not PS2++. - */ -#ifdef HAVE_GPM_H -static void -mouse_update_ps2( void ) -#else -void -mouse_update( void ) -#endif -{ - static int btn_state = 0; - unsigned char mousebuf[60]; /* max. events: 20 (PS/2) or 15 (other) */ - ssize_t xoff = 0, yoff = 0; - int btn_changed = 0, btn_new = btn_state, btn_mod = btn_state; - - if( mouse_fd == -1 ) return; - - while( 1 ) { - ssize_t available; - const unsigned char *i; - - available = read( mouse_fd, &mousebuf, sizeof( mousebuf ) ); - if( available <= 0 ) break; - - if( !ui_mouse_grabbed ) continue; - - for( i = mousebuf; i < mousebuf + available; i += packet_size ) { - btn_changed |= btn_mod ^= btn_new = i[0] & 7; - btn_changed |= btn_mod ^= btn_new = i[0] & 7; - xoff += i[1]; if( i[0] & 16 ) xoff -= 256; - yoff += i[2]; if( i[0] & 32 ) yoff -= 256; - } - } - - btn_state = btn_new; - if( btn_changed & 1 ) ui_mouse_button( 1, btn_new & 1 ); - if( btn_changed & 2 ) ui_mouse_button( 3, btn_new & 2 ); - - if( xoff || yoff ) ui_mouse_motion( xoff, -yoff ); -} - -/* Try to open the specified device. Return 0 on success. */ -static int -try_open( const char *dev ) -{ - mouse_fd = open( dev, O_RDWR ); - if( mouse_fd == -1 && errno == EACCES ) - mouse_fd = open( dev, O_RDONLY ); - return mouse_fd == -1; -} - -/* Try to set the mouse to the requested mode (100 = ImPS/2, 200 = ExPS/2). - * Return 0 on success. - */ -static int -try_mouse_mode( unsigned char mode, unsigned char response ) -{ - struct pollfd ufd = { mouse_fd, POLLIN | POLLPRI }; - int ret = 0; - unsigned char buf[] = { 0xF3, 200, 0xF3, mode, 0xF3, 80, 0xF2 }; - if( write( mouse_fd, buf, sizeof( buf ) ) < sizeof( buf ) ) - return 1; - while( poll( &ufd, 1, 10 ) == 1) - ret = read( mouse_fd, buf, sizeof( buf ) ); - return ret < 1 || buf[ret - 1] != response; -} - -int -ui_mouse_grab( int startup GCC_UNUSED ) -{ - return 1; -} - -int -ui_mouse_release( int suspend ) -{ - return !suspend; -} diff --git a/fuse/ui/fb/fbmouse.h b/fuse/ui/fb/fbmouse.h deleted file mode 100644 index 24d23ba..0000000 --- a/fuse/ui/fb/fbmouse.h +++ /dev/null @@ -1,31 +0,0 @@ -/* fbmouse.h: Linux mouse handling code (requires kernel input layer) - Copyright (c) 2004 Darren Salt - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: linux@youmustbejoking.demon.co.uk - -*/ - -#ifndef FUSE_FBMOUSE_H -#define FUSE_FBMOUSE_H - -int fbmouse_init(void); -int fbmouse_end(void); -void mouse_update(void); - -#endif /* #ifndef FUSE_FBMOUSE_H */ diff --git a/fuse/ui/fb/fbui.c b/fuse/ui/fb/fbui.c deleted file mode 100644 index cebca7e..0000000 --- a/fuse/ui/fb/fbui.c +++ /dev/null @@ -1,114 +0,0 @@ -/* fbui.c: Routines for dealing with the linux fbdev user interface - Copyright (c) 2000-2004 Philip Kendall, Matan Ziv-Av, Witold Filipczyk - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include -#include - -#include "fbdisplay.h" -#include "fbkeyboard.h" -#include "fbmouse.h" -#include "ui/ui.h" -#include "ui/uidisplay.h" - -static void end_handler( int signo ); -static void fb_end( void ); - -int -ui_init( int *argc, char ***argv ) -{ - struct sigaction handler; - int error; - - if( ui_widget_init() ) return 1; - - error = atexit( fb_end ); - if( error ) { - ui_error( UI_ERROR_ERROR, "ui_init: couldn't set atexit function" ); - return 1; - } - - handler.sa_handler = end_handler; - - error = sigaction( SIGTERM, &handler, NULL ); - if( error ) { - ui_error( UI_ERROR_ERROR, "ui_init: couldn't set SIGTERM handler: %s", - strerror( errno ) ); - return 1; - } - - error = sigaction( SIGHUP, &handler, NULL ); - if( error ) { - ui_error( UI_ERROR_ERROR, "ui_init: couldn't set SIGHUP handler: %s", - strerror( errno ) ); - return 1; - } - - error = fbkeyboard_init(); - if( error ) return error; - - error = fbmouse_init(); - if( error ) return error; - - error = fbdisplay_init(); - if( error ) return error; - - return 0; -} - -int ui_event( void ) -{ - keyboard_update(); - mouse_update(); - return 0; -} - -int ui_end( void ) -{ - /* Cleanup handled by atexit function */ - int error; - - error = fbkeyboard_end(); if( error ) return error; - error = fbdisplay_end(); if( error ) return error; - - ui_widget_end(); - - return 0; -} - -static void -end_handler( int signo ) -{ - fb_end(); -} - -static void -fb_end( void ) -{ - fbkeyboard_end(); - uidisplay_end(); -} diff --git a/fuse/ui/gtk/Makefile.am b/fuse/ui/gtk/Makefile.am deleted file mode 100644 index ef5f389..0000000 --- a/fuse/ui/gtk/Makefile.am +++ /dev/null @@ -1,101 +0,0 @@ -## Process this file with automake to produce Makefile.in -## Copyright (c) 2001-2004 Philip Kendall -## Copyright (c) 2015 Sergio Baldoví - -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -## -## Author contact information: -## -## E-mail: philip-fuse@shadowmagic.org.uk - -if UI_GTK - -fuse_SOURCES += $(ui_gtk_files) - -BUILT_SOURCES += $(ui_gtk_built) - -pkgdata_DATA += ui/gtk/menu_data.ui - -endif - - -CLEANFILES += $(ui_gtk_built) - -ui_gtk_files = \ - ui/gtk/binary.c \ - ui/gtk/browse.c \ - ui/gtk/confirm.c \ - ui/gtk/debugger.c \ - ui/gtk/fileselector.c \ - ui/gtk/gtkcompat.h \ - ui/gtk/gtkdisplay.c \ - ui/gtk/gtkinternals.h \ - ui/gtk/gtkjoystick.c \ - ui/gtk/gtkkeyboard.c \ - ui/gtk/gtkmouse.c \ - ui/gtk/gtkui.c \ - ui/gtk/keysyms.c \ - ui/gtk/menu_data.c \ - ui/gtk/options.c \ - ui/gtk/picture.c \ - ui/gtk/pixmaps.c \ - ui/gtk/pokefinder.c \ - ui/gtk/pokemem.c \ - ui/gtk/rollback.c \ - ui/gtk/roms.c \ - ui/gtk/statusbar.c \ - ui/gtk/stock.c - -if HAVE_GTK2 - -ui_gtk_files += ui/gtk/gtkcompat.c \ - ui/gtk/memory_gtk2.c - -else - -ui_gtk_files += ui/gtk/memory.c - -endif - -ui_gtk_built = \ - ui/gtk/keysyms.c \ - ui/gtk/menu_data.c \ - ui/gtk/menu_data.ui \ - ui/gtk/options.c \ - ui/gtk/options_internals.h - -EXTRA_DIST += \ - ui/gtk/options.pl \ - ui/gtk/options-header.pl - -ui/gtk/keysyms.c: $(srcdir)/keysyms.pl $(srcdir)/keysyms.dat - @$(MKDIR_P) ui/gtk - $(AM_V_GEN)$(PERL) -I$(srcdir)/perl $(srcdir)/keysyms.pl gtk $(srcdir)/keysyms.dat > $@.tmp && mv $@.tmp $@ - -ui/gtk/menu_data.c: $(srcdir)/perl/cpp-perl.pl $(srcdir)/menu_data.pl $(srcdir)/menu_data.dat config.h - @$(MKDIR_P) ui/gtk - $(AM_V_GEN)$(PERL) $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/menu_data.dat | $(PERL) -I$(srcdir)/perl $(srcdir)/menu_data.pl gtk c > $@.tmp && mv $@.tmp $@ - -ui/gtk/menu_data.ui: $(srcdir)/perl/cpp-perl.pl $(srcdir)/menu_data.pl $(srcdir)/menu_data.dat config.h - @$(MKDIR_P) ui/gtk - $(AM_V_GEN)$(PERL) $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/menu_data.dat | $(PERL) -I$(srcdir)/perl $(srcdir)/menu_data.pl gtk ui > $@.tmp && mv $@.tmp $@ - -ui/gtk/options.c: $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/ui/gtk/options.pl $(srcdir)/ui/options.dat $(srcdir)/perl/Fuse.pm $(srcdir)/perl/Fuse/Dialog.pm - @$(MKDIR_P) ui/gtk - $(AM_V_GEN)$(PERL) $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/ui/options.dat | $(PERL) -I$(srcdir)/perl $(srcdir)/ui/gtk/options.pl - > $@.tmp && mv $@.tmp $@ - -ui/gtk/options_internals.h: $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/ui/gtk/options-header.pl $(srcdir)/ui/options.dat $(srcdir)/perl/Fuse.pm $(srcdir)/perl/Fuse/Dialog.pm - @$(MKDIR_P) ui/gtk - $(AM_V_GEN)$(PERL) $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/ui/options.dat | $(PERL) -I$(srcdir)/perl $(srcdir)/ui/gtk/options-header.pl - > $@.tmp && mv $@.tmp $@ diff --git a/fuse/ui/gtk/binary.c b/fuse/ui/gtk/binary.c deleted file mode 100644 index d79946e..0000000 --- a/fuse/ui/gtk/binary.c +++ /dev/null @@ -1,447 +0,0 @@ -/* binary.c: GTK routines to load/save chunks of binary data - Copyright (c) 2003-2013 Philip Kendall - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include -#include - -#include "fuse.h" -#include "gtkinternals.h" -#include "memory_pages.h" -#include "menu.h" -#include "ui/ui.h" -#include "utils.h" - -struct binary_info { - - char *filename; - utils_file file; - - GCallback activate_data; - GCallback change_filename; - - GtkWidget *dialog; - GtkWidget *filename_widget, *start_widget, *length_widget; - - long start; - long length; -}; - -static struct binary_info save_info = { 0 }; -static struct binary_info load_info = { 0 }; - -static void change_load_filename( GtkButton *button, gpointer user_data ); -static void load_data( GtkEntry *entry, gpointer user_data ); - -static void change_save_filename( GtkButton *button, gpointer user_data ); -static void save_data( GtkEntry *entry, gpointer user_data ); - - -/* - * This is the main dialog for the load/save binary data interface. It's - * shared between the 2 functions. - * - * It's passed the binary_info structure, which contains the start address - * and length values of the block to either load or save. These are populated - * into the GUI. - */ - -typedef enum -{ - BINARY_DIALOG_MODE_LOAD, - BINARY_DIALOG_MODE_SAVE -} BINARY_DIALOG_MODE; - -static void -create_shared_binary_dialog( struct binary_info *info, const char *title, - BINARY_DIALOG_MODE mode ) -{ - GtkWidget *table, *button, *content_area; - GtkWidget *label_filename, *label_start, *label_length; - - char buffer[80]; - - info->dialog = gtkstock_dialog_new( title, NULL ); - - content_area = gtk_dialog_get_content_area( GTK_DIALOG( info->dialog ) ); - - label_filename = gtk_label_new( "Filename" ); - - info->filename_widget = gtk_label_new( info->filename ); -#if GTK_CHECK_VERSION( 3, 16, 0 ) - gtk_label_set_xalign( GTK_LABEL(info->filename_widget), 0.0); -#else - gtk_misc_set_alignment( GTK_MISC(info->filename_widget), 0.0, 0.5 ); -#endif - - button = gtk_button_new_with_label( "Browse..." ); - g_signal_connect( G_OBJECT( button ), "clicked", info->change_filename, - info ); - - label_start = gtk_label_new( "Start" ); - - info->start_widget = gtk_entry_new(); - snprintf( buffer, 80, "%lu", info->start ); - gtk_entry_set_text( GTK_ENTRY( info->start_widget ), buffer ); - g_signal_connect( G_OBJECT( info->start_widget ), "activate", - info->activate_data, info ); - - label_length = gtk_label_new( "Length" ); - - info->length_widget = gtk_entry_new(); - if( mode == BINARY_DIALOG_MODE_LOAD ) { - snprintf( buffer, 80, "%lu", (unsigned long)info->file.length ); - } else { - snprintf( buffer, 80, "%lu", info->length ); - } - gtk_entry_set_text( GTK_ENTRY( info->length_widget ), buffer ); - - g_signal_connect( G_OBJECT( info->length_widget ), "activate", - info->activate_data, info ); - -#if GTK_CHECK_VERSION( 3, 0, 0 ) - - table = gtk_grid_new(); - gtk_grid_set_column_homogeneous( GTK_GRID( table ), FALSE ); - gtk_grid_set_column_spacing( GTK_GRID( table ), 6 ); - gtk_grid_set_row_spacing( GTK_GRID( table ), 6 ); - gtk_container_set_border_width( GTK_CONTAINER( table ), 6 ); - gtk_container_add( GTK_CONTAINER( content_area ), table ); - - gtk_grid_attach( GTK_GRID( table ), label_filename, 0, 0, 1, 1 ); - gtk_widget_set_hexpand( info->filename_widget, TRUE ); - gtk_grid_attach( GTK_GRID( table ), info->filename_widget, - 1, 0, 1, 1 ); - gtk_grid_attach( GTK_GRID( table ), button, 2, 0, 1, 1 ); - gtk_grid_attach( GTK_GRID( table ), label_start, 0, 1, 1, 1 ); - gtk_grid_attach( GTK_GRID( table ), info->start_widget, 1, 1, 2, 1 ); - gtk_grid_attach( GTK_GRID( table ), label_length, 0, 2, 1, 1 ); - gtk_grid_attach( GTK_GRID( table ), info->length_widget, 1, 2, 2, 1 ); - -#else /* #if GTK_CHECK_VERSION( 3, 0, 0 ) */ - - table = gtk_table_new( 3, 3, FALSE ); - gtk_box_pack_start( GTK_BOX( content_area ), table, TRUE, TRUE, 0 ); - - gtk_table_attach( GTK_TABLE( table ), label_filename, 0, 1, 0, 1, - GTK_FILL, GTK_FILL, 3, 3 ); - - gtk_table_attach( GTK_TABLE( table ), info->filename_widget, 1, 2, 0, 1, - GTK_FILL, GTK_FILL, 3, 3 ); - - gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 0, 1, - GTK_FILL, GTK_FILL, 3, 3 ); - - gtk_table_attach( GTK_TABLE( table ), label_start, 0, 1, 1, 2, 0, 0, 3, 3 ); - - gtk_table_attach( GTK_TABLE( table ), info->start_widget, 1, 3, 1, 2, - GTK_FILL, GTK_FILL, 3, 3 ); - - gtk_table_attach( GTK_TABLE( table ), label_length, 0, 1, 2, 3, - GTK_FILL, GTK_FILL, 3, 3 ); - - gtk_table_attach( GTK_TABLE( table ), info->length_widget, 1, 3, 2, 3, - GTK_FILL, GTK_FILL, 3, 3 ); - -#endif - - GtkAccelGroup *accel_group; - accel_group = gtk_accel_group_new(); - gtk_window_add_accel_group( GTK_WINDOW( info->dialog ), accel_group ); - - /* Command buttons */ - gtkstock_create_ok_cancel( info->dialog, NULL, info->activate_data, info, - DEFAULT_DESTROY, DEFAULT_DESTROY ); - - gtk_widget_grab_focus( info->start_widget ); -} - - -/* - * This is the entry point for the load binary data command. It's called from - * the GUI menu. It pops the file name selector dialog if the user hasn't - * already specified a filename, then pops the dialog requesting start address - * and length. - */ -void -menu_file_loadbinarydata( GtkAction *gtk_action GCC_UNUSED, - gpointer data GCC_UNUSED ) -{ - int error; - - fuse_emulation_pause(); - - /* - * If the filename is blank it's not been selected previously. - * Pop up the file selector. - */ - if( !load_info.filename ) - { - load_info.filename = ui_get_open_filename( "Fuse - Load Binary Data" ); - if( !load_info.filename ) - { - fuse_emulation_unpause(); - return; - } - } - - error = utils_read_file( load_info.filename, &load_info.file ); - if( error ) - { - fuse_emulation_unpause(); - return; - } - - /* Information display */ - load_info.activate_data = G_CALLBACK( load_data ); - load_info.change_filename = G_CALLBACK( change_load_filename ); - - create_shared_binary_dialog( &load_info, "Fuse - Load Binary Data", - BINARY_DIALOG_MODE_LOAD ); - - /* Process the dialog */ - gtk_widget_show_all( load_info.dialog ); - gtk_main(); - - utils_close_file( &load_info.file ); - - fuse_emulation_unpause(); -} - - -/* - * Change the name of the file the user is going to load into the Spectrum's - * memory. This pops a file selector dialog and stores the name of the file - * chosen (releasing the memory of the previously chosen name). - */ -static void -change_load_filename( GtkButton *button GCC_UNUSED, gpointer user_data ) -{ - struct binary_info *info = user_data; - - char *new_filename; - utils_file new_file; - - char buffer[80]; - int error; - - new_filename = ui_get_open_filename( "Fuse - Load Binary Data" ); - if( !new_filename ) return; - - error = utils_read_file( new_filename, &new_file ); - if( error ) { free( new_filename ); return; } - - /* Remove the data for the old file */ - utils_close_file( &info->file ); - - free( info->filename ); - - /* Put the new data in */ - info->filename = new_filename; info->file = new_file; - - /* And update the displayed information */ - gtk_label_set_text( GTK_LABEL( info->filename_widget ), new_filename ); - - snprintf( buffer, 80, "%lu", (unsigned long)info->file.length ); - gtk_entry_set_text( GTK_ENTRY( info->length_widget ), buffer ); -} - - -/* - * Load a chunk of binary data into the Spectrum's memory. It's called as a - * callback from the GUI when the user hits the OK button. - * - * The given user_data is a binary_info structure which contains the user's - * selected filename, plus the start/length widgets the user will have filled - * in. - * - * This is called in a separate GTK loop, so it returns to code which tidies - * up and unpauses the Spectrum. - */ -static void -load_data( GtkEntry *entry GCC_UNUSED, gpointer user_data ) -{ - struct binary_info *info = user_data; - - long start, length; size_t i; - const gchar *nptr; - char *endptr; - int base; - - errno = 0; - nptr = gtk_entry_get_text( GTK_ENTRY( info->length_widget ) ); - base = ( g_str_has_prefix( nptr, "0x" ) )? 16 : 10; - length = strtol( nptr, &endptr, base ); - - if( errno || length < 1 || length > 0x10000 || endptr == nptr ) { - ui_error( UI_ERROR_ERROR, "Length must be between 1 and 65536" ); - return; - } - - if( length > info->file.length ) { - ui_error( UI_ERROR_ERROR, - "'%s' contains only %lu bytes", - info->filename, (unsigned long)info->file.length ); - return; - } - - errno = 0; - nptr = gtk_entry_get_text( GTK_ENTRY( info->start_widget ) ); - base = ( g_str_has_prefix( nptr, "0x" ) )? 16 : 10; - start = strtol( nptr, &endptr, base ); - - if( errno || start < 0 || start > 0xffff || endptr == nptr ) { - ui_error( UI_ERROR_ERROR, "Start must be between 0 and 65535" ); - return; - } - - if( start + length > 0x10000 ) { - ui_error( UI_ERROR_ERROR, "Block ends after address 65535" ); - return; - } - - for( i = 0; i < length; i++ ) - writebyte_internal( start + i, info->file.buffer[ i ] ); - - gtkui_destroy_widget_and_quit( info->dialog, NULL ); -} - - -/* - * This is the start point for the save binary data GUI command. It pops up - * the file selector if a selected file isn't already in the static structure, - * then pops up the filename/start/length dialog. - */ -void -menu_file_savebinarydata( GtkAction *gtk_action GCC_UNUSED, - gpointer data GCC_UNUSED ) -{ - fuse_emulation_pause(); - - /* - * If the filename is blank it's not been selected previously. - * Pop up the file selector. - */ - if( !save_info.filename ) - { - save_info.filename = ui_get_save_filename( "Fuse - Save Binary Data" ); - if( !save_info.filename ) - { - fuse_emulation_unpause(); - return; - } - } - - save_info.activate_data = G_CALLBACK( save_data ); - save_info.change_filename = G_CALLBACK( change_save_filename ); - - create_shared_binary_dialog( &save_info, "Fuse - Save Binary Data", - BINARY_DIALOG_MODE_SAVE ); - - /* Process the dialog */ - gtk_widget_show_all( save_info.dialog ); - gtk_main(); - - fuse_emulation_unpause(); -} - - -/* - * Change the name of the file the save binary command will write - * out to. The previously specified filename is removed (and the memory - * for it reclaimed) and a new filename is stored in its place. The - * GUI entry field is updated. - * - * This is only called after the user has already specified a filename, - * so it's safe to free the old name. - */ -static void -change_save_filename( GtkButton *button GCC_UNUSED, gpointer user_data ) -{ - struct binary_info *info = user_data; - char *new_filename; - - new_filename = ui_get_save_filename( "Fuse - Save Binary Data" ); - if( !new_filename ) return; - - free( info->filename ); - - info->filename = new_filename; - - gtk_label_set_text( GTK_LABEL( info->filename_widget ), new_filename ); -} - - -/* - * Write out a chunk of binary data, as described by the given binary_info - * structure passed in. - * - * This writes the given number of data bytes from the given start point in - * the Spectrum's memory out to the given file. - */ -static void -save_data( GtkEntry *entry GCC_UNUSED, gpointer user_data ) -{ - struct binary_info *info = user_data; - - const gchar *nptr; - char *endptr; - int base; - - int error; - - errno = 0; - nptr = gtk_entry_get_text( GTK_ENTRY( info->length_widget ) ); - base = ( g_str_has_prefix( nptr, "0x" ) )? 16 : 10; - info->length = strtol( nptr, &endptr, base ); - - if( errno || info->length < 1 || info->length > 0x10000 || endptr == nptr ) { - ui_error( UI_ERROR_ERROR, "Length must be between 1 and 65536" ); - return; - } - - errno = 0; - nptr = gtk_entry_get_text( GTK_ENTRY( info->start_widget ) ); - base = ( g_str_has_prefix( nptr, "0x" ) )? 16 : 10; - info->start = strtol( nptr, &endptr, base ); - - if( errno || info->start < 0 || info->start > 0xffff || endptr == nptr ) { - ui_error( UI_ERROR_ERROR, "Start must be between 0 and 65535" ); - return; - } - - if( info->start + info->length > 0x10000 ) { - ui_error( UI_ERROR_ERROR, "Block ends after address 65535" ); - return; - } - - error = utils_save_binary( info->start, info->length, info->filename ); - if( error ) return; - - gtkui_destroy_widget_and_quit( info->dialog, NULL ); -} diff --git a/fuse/ui/gtk/browse.c b/fuse/ui/gtk/browse.c deleted file mode 100644 index 2663b48..0000000 --- a/fuse/ui/gtk/browse.c +++ /dev/null @@ -1,321 +0,0 @@ -/* browse.c: tape browser dialog box - Copyright (c) 2002-2004 Philip Kendall - Copyright (c) 2015 Sergio Baldoví - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include -#include - -#include "compat.h" -#include "fuse.h" -#include "gtkinternals.h" -#include "menu.h" -#include "tape.h" -#include "ui/ui.h" - -static int create_dialog( void ); -static void add_block_details( libspectrum_tape_block *block, - void *user_data ); -static void select_row( GtkTreeView *treeview, GtkTreePath *path, - GtkTreeViewColumn *col, gpointer user_data ); -void mark_row( GtkTreeModel *model, int row ); -static void browse_done( GtkWidget *widget, gpointer data ); -static gboolean delete_dialog( GtkWidget *widget, GdkEvent *event, - gpointer user_data ); - -static GdkPixbuf *tape_marker_pixbuf; - -static GtkWidget - *dialog, /* The dialog box itself */ - *blocks, /* The list of blocks */ - *modified_label; /* The label saying if the tape has been - modified */ - -static int dialog_created; /* Have we created the dialog box yet? */ - -/* List columns */ -enum -{ - COL_PIX = 0, /* Pixmap */ - COL_BLOCK, /* Block type */ - COL_DATA, /* Data detail */ - NUM_COLS -}; - -void -menu_media_tape_browse( GtkAction *gtk_action GCC_UNUSED, - gpointer data GCC_UNUSED ) -{ - /* Firstly, stop emulation */ - fuse_emulation_pause(); - - if( !dialog_created ) - if( create_dialog() ) { fuse_emulation_unpause(); return; } - - if( ui_tape_browser_update( UI_TAPE_BROWSER_NEW_TAPE, NULL ) ) { - fuse_emulation_unpause(); - return; - } - - gtk_widget_show_all( dialog ); - - /* Carry on with emulation */ - fuse_emulation_unpause(); -} - -static GtkWidget * -create_block_list( void ) -{ - GtkWidget *view; - GtkCellRenderer *renderer; - GtkTreeModel *model; - GtkListStore *store; - - view = gtk_tree_view_new(); - - /* Add columns */ - renderer = gtk_cell_renderer_pixbuf_new(); - gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( view ), - -1, - NULL, - renderer, - "pixbuf", COL_PIX, - NULL ); - - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( view ), - -1, - "Block type", - renderer, - "text", COL_BLOCK, - NULL ); - - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( view ), - -1, - "Data", - renderer, - "text", COL_DATA, - NULL ); - - /* Create data model */ - store = gtk_list_store_new( NUM_COLS, GDK_TYPE_PIXBUF, G_TYPE_STRING, - G_TYPE_STRING ); - - model = GTK_TREE_MODEL( store ); - gtk_tree_view_set_model( GTK_TREE_VIEW( view ), model ); - g_object_unref( model ); - - /* Fast move tape */ - g_signal_connect( G_OBJECT( view ), "row-activated", - G_CALLBACK( select_row ), model ); - - return view; -} - -static int -create_dialog( void ) -{ - GtkWidget *scrolled_window, *content_area; - - /* Give me a new dialog box */ - dialog = gtkstock_dialog_new( "Fuse - Browse Tape", - G_CALLBACK( delete_dialog ) ); - content_area = gtk_dialog_get_content_area( GTK_DIALOG( dialog ) ); - - /* And a scrolled window to pack the list into */ - scrolled_window = gtk_scrolled_window_new( NULL, NULL ); - gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled_window ), - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC ); - gtk_box_pack_start( GTK_BOX( content_area ), scrolled_window, TRUE, TRUE, 0 ); - - /* The tape marker pixbuf */ - tape_marker_pixbuf = gdk_pixbuf_new_from_xpm_data( gtkpixmap_tape_marker ); - /* FIXME: unref this at exit */ - - /* And the list itself */ - blocks = create_block_list(); - gtk_container_add( GTK_CONTAINER( scrolled_window ), GTK_WIDGET( blocks ) ); - - /* And the "tape modified" label */ - modified_label = gtk_label_new( "" ); - gtk_box_pack_start( GTK_BOX( content_area ), modified_label, FALSE, FALSE, 0 ); - - /* Create the OK button */ - gtkstock_create_close( dialog, NULL, G_CALLBACK( browse_done ), FALSE ); - - /* Make the window big enough to show at least some data */ - gtk_window_set_default_size( GTK_WINDOW( dialog ), -1, 250 ); - - dialog_created = 1; - - return 0; -} - -int -ui_tape_browser_update( ui_tape_browser_update_type change GCC_UNUSED, - libspectrum_tape_block *block GCC_UNUSED ) -{ - int error, current_block; - GtkTreeModel *model; - - if( !dialog_created ) return 0; - - fuse_emulation_pause(); - - model = gtk_tree_view_get_model( GTK_TREE_VIEW( blocks ) ); - gtk_list_store_clear( GTK_LIST_STORE( model ) ); - - error = tape_foreach( add_block_details, model ); - if( error ) { - fuse_emulation_unpause(); - return 1; - } - - current_block = tape_get_current_block(); - - if( current_block != -1 ) - mark_row( model, current_block ); - - if( tape_modified ) { - gtk_label_set_text( GTK_LABEL( modified_label ), "Tape modified" ); - } else { - gtk_label_set_text( GTK_LABEL( modified_label ), "Tape not modified" ); - } - - fuse_emulation_unpause(); - - return 0; -} - -static void -add_block_details( libspectrum_tape_block *block, void *user_data ) -{ - gchar block_type[80]; - gchar data_detail[80]; - GtkTreeIter iter; - GtkTreeModel *model = user_data; - - libspectrum_tape_block_description( block_type, 80, block ); - tape_block_details( data_detail, 80, block ); - - /* Append a new row and fill data */ - gtk_list_store_append( GTK_LIST_STORE( model ), &iter ); - gtk_list_store_set( GTK_LIST_STORE( model ), &iter, - COL_PIX, NULL, - COL_BLOCK, block_type, - COL_DATA, data_detail, - -1 ); -} - -/* Called when a row is selected */ -static void -select_row( GtkTreeView *treeview GCC_UNUSED, GtkTreePath *path, - GtkTreeViewColumn *col GCC_UNUSED, gpointer user_data ) -{ - int current_block; - int *indices; - int row; - GtkTreeIter iter; - GtkTreeModel *model = user_data; - - /* Get selected row */ - row = -1; - indices = gtk_tree_path_get_indices( path ); - if( indices ) row = indices[0]; - - /* Don't do anything if the current block was clicked on */ - current_block = tape_get_current_block(); - if( row == current_block ) return; - - /* Otherwise, select the new block */ - tape_select_block_no_update( row ); - - /* Mark selected block */ - if( current_block != -1 ) { - gtk_tree_model_get_iter( GTK_TREE_MODEL( model ), &iter, path ); - - gtk_list_store_set( GTK_LIST_STORE( model ), &iter, - COL_PIX, tape_marker_pixbuf, - -1 ); - } - - /* Unmark former block */ - if( current_block != -1 ) { - path = gtk_tree_path_new_from_indices( current_block, -1 ); - - if( !gtk_tree_model_get_iter( GTK_TREE_MODEL( model ), &iter, path ) ) { - gtk_tree_path_free( path ); - return; - } - - gtk_tree_path_free( path ); - - gtk_list_store_set( GTK_LIST_STORE( model ), &iter, - COL_PIX, NULL, - -1 ); - } -} - -void -mark_row( GtkTreeModel *model, int row ) -{ - GtkTreeIter iter; - GtkTreePath *path; - - path = gtk_tree_path_new_from_indices( row, -1 ); - - if( !gtk_tree_model_get_iter( model, &iter, path ) ) { - gtk_tree_path_free( path ); - return; - } - - gtk_tree_path_free( path ); - - gtk_list_store_set( GTK_LIST_STORE( model ), &iter, - COL_PIX, tape_marker_pixbuf, - -1 ); -} - -/* Called if the OK button is clicked */ -static void -browse_done( GtkWidget *widget GCC_UNUSED, gpointer data GCC_UNUSED ) -{ - dialog_created = 0; - gtk_widget_destroy( dialog ); -} - -/* Catch attempts to delete the window and just hide it instead */ -static gboolean -delete_dialog( GtkWidget *widget, GdkEvent *event GCC_UNUSED, - gpointer user_data GCC_UNUSED ) -{ - dialog_created = 0; - gtk_widget_destroy( dialog ); - return TRUE; -} diff --git a/fuse/ui/gtk/confirm.c b/fuse/ui/gtk/confirm.c deleted file mode 100644 index b8fa1e3..0000000 --- a/fuse/ui/gtk/confirm.c +++ /dev/null @@ -1,139 +0,0 @@ -/* confirm.c: Confirmation dialog box - Copyright (c) 2000-2015 Philip Kendall, Russell Marks - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include "compat.h" -#include "fuse.h" -#include "gtkcompat.h" -#include "gtkinternals.h" -#include "settings.h" -#include "ui/ui.h" - -static void set_confirmed( GtkButton *button, gpointer user_data ); -static void set_save( GtkButton *button, gpointer user_data ); -static void set_dont_save( GtkButton *button, gpointer user_data ); - -int -gtkui_confirm( const char *string ) -{ - GtkWidget *dialog, *label, *content_area; - int confirm; - - /* Return value isn't an error code, but signifies whether to undertake - the action */ - if( !settings_current.confirm_actions ) return 1; - - fuse_emulation_pause(); - - confirm = 0; - - dialog = gtkstock_dialog_new( "Fuse - Confirm", NULL ); - - label = gtk_label_new( string ); - content_area = gtk_dialog_get_content_area( GTK_DIALOG( dialog ) ); - gtk_box_pack_start( GTK_BOX( content_area ), label, TRUE, TRUE, 5 ); - - gtkstock_create_ok_cancel( dialog, NULL, G_CALLBACK( set_confirmed ), - &confirm, DEFAULT_DESTROY, DEFAULT_DESTROY ); - - gtk_dialog_set_default_response( GTK_DIALOG( dialog ), GTK_RESPONSE_CANCEL ); - - gtk_widget_show_all( dialog ); - gtk_main(); - - fuse_emulation_unpause(); - - return confirm; -} - -static void -set_confirmed( GtkButton *button GCC_UNUSED, gpointer user_data ) -{ - int *ptr = user_data; - - *ptr = 1; -} - -ui_confirm_save_t -ui_confirm_save_specific( const char *message ) -{ - GtkWidget *dialog, *label, *content_area; - ui_confirm_save_t confirm; - - if( !settings_current.confirm_actions ) return UI_CONFIRM_SAVE_DONTSAVE; - - fuse_emulation_pause(); - - confirm = UI_CONFIRM_SAVE_CANCEL; - - dialog = gtkstock_dialog_new( "Fuse - Confirm", NULL ); - content_area = gtk_dialog_get_content_area( GTK_DIALOG( dialog ) ); - - label = gtk_label_new( message ); - gtk_box_pack_start( GTK_BOX( content_area ), label, TRUE, TRUE, 5 ); - - { - static gtkstock_button btn[] = { - { "_No", G_CALLBACK( set_dont_save ), NULL, DEFAULT_DESTROY, 0, 0, 0, 0, GTK_RESPONSE_NO }, - { "_Cancel", NULL, NULL, DEFAULT_DESTROY, GDK_KEY_Escape, 0, 0, 0, GTK_RESPONSE_CANCEL }, - { "_Save", G_CALLBACK( set_save ), NULL, DEFAULT_DESTROY, 0, 0, 0, 0, GTK_RESPONSE_YES } - }; - btn[0].actiondata = btn[2].actiondata = &confirm; - gtkstock_create_buttons( dialog, NULL, btn, ARRAY_SIZE( btn ) ); - } - - gtk_dialog_set_default_response( GTK_DIALOG( dialog ), GTK_RESPONSE_CANCEL ); - - gtk_widget_show_all( dialog ); - gtk_main(); - - fuse_emulation_unpause(); - - return confirm; -} - -int -ui_query( const char *message ) -{ - return gtkui_confirm( message ); -} - -static void -set_save( GtkButton *button GCC_UNUSED, gpointer user_data ) -{ - ui_confirm_save_t *ptr = user_data; - - *ptr = UI_CONFIRM_SAVE_SAVE; -} - -static void -set_dont_save( GtkButton *button GCC_UNUSED, gpointer user_data ) -{ - ui_confirm_save_t *ptr = user_data; - - *ptr = UI_CONFIRM_SAVE_DONTSAVE; -} diff --git a/fuse/ui/gtk/debugger.c b/fuse/ui/gtk/debugger.c deleted file mode 100644 index 5875fbb..0000000 --- a/fuse/ui/gtk/debugger.c +++ /dev/null @@ -1,1393 +0,0 @@ -/* debugger.c: the GTK debugger - Copyright (c) 2002-2015 Philip Kendall - Copyright (c) 2013 Sergio Baldoví - Copyright (c) 2015 Stuart Brady - Copyright (c) 2016 BogDan Vatra - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include - -#include -#include - -#include - -#include "debugger/debugger.h" -#include "event.h" -#include "fuse.h" -#include "gtkcompat.h" -#include "gtkinternals.h" -#include "machine.h" -#include "memory_pages.h" -#include "peripherals/ide/zxcf.h" -#include "peripherals/scld.h" -#include "peripherals/ula.h" -#include "settings.h" -#include "ui/ui.h" -#include "z80/z80.h" -#include "z80/z80_macros.h" - -/* The various debugger panes */ -typedef enum debugger_pane { - - DEBUGGER_PANE_BEGIN = 1, /* Start marker */ - - DEBUGGER_PANE_REGISTERS = DEBUGGER_PANE_BEGIN, - DEBUGGER_PANE_MEMORYMAP, - DEBUGGER_PANE_BREAKPOINTS, - DEBUGGER_PANE_DISASSEMBLY, - DEBUGGER_PANE_STACK, - DEBUGGER_PANE_EVENTS, - - DEBUGGER_PANE_END /* End marker */ - -} debugger_pane; - -/* The columns used in the breakpoints pane */ - -enum { - BREAKPOINTS_COLUMN_ID, - BREAKPOINTS_COLUMN_TYPE, - BREAKPOINTS_COLUMN_VALUE, - BREAKPOINTS_COLUMN_IGNORE, - BREAKPOINTS_COLUMN_LIFE, - BREAKPOINTS_COLUMN_CONDITION, - - BREAKPOINTS_COLUMN_COUNT -}; - -/* The columns used in the disassembly pane */ - -enum { - DISASSEMBLY_COLUMN_ADDRESS, - DISASSEMBLY_COLUMN_INSTRUCTION, - - DISASSEMBLY_COLUMN_COUNT -}; - -/* The columns used in the stack pane */ - -enum { - STACK_COLUMN_ADDRESS, - STACK_COLUMN_VALUE_TEXT, - STACK_COLUMN_VALUE_INT, - - STACK_COLUMN_COUNT -}; - -/* The columns used in the events pane */ - -enum { - EVENTS_COLUMN_TIME, - EVENTS_COLUMN_TYPE, - - EVENTS_COLUMN_COUNT -}; - -static int create_dialog( void ); -static int hide_hidden_panes( void ); -static GtkCheckMenuItem* get_pane_menu_item( debugger_pane pane ); -static GtkWidget* get_pane( debugger_pane pane ); -static int create_menu_bar( GtkBox *parent, GtkAccelGroup **accel_group ); -static void toggle_display( GtkToggleAction* action, debugger_pane pane ); -static void toggle_display_registers( GtkToggleAction* action, gpointer data ); -static void toggle_display_memory_map( GtkToggleAction* action, gpointer data ); -static void toggle_display_breakpoints( GtkToggleAction* action, - gpointer data ); -static void toggle_display_disassembly( GtkToggleAction* action, - gpointer data ); -static void toggle_display_stack( GtkToggleAction* action, gpointer data ); -static void toggle_display_events( GtkToggleAction* action, gpointer data ); -static int create_register_display( GtkBox *parent, PangoFontDescription *font ); -static int create_memory_map( GtkBox *parent ); -static void create_breakpoints( GtkBox *parent ); -static void create_disassembly( GtkBox *parent, PangoFontDescription *font ); -static void create_stack_display( GtkBox *parent, PangoFontDescription *font ); -static void stack_activate( GtkTreeView *tree_view, GtkTreePath *path, - GtkTreeViewColumn *column, gpointer user_data ); -static void create_events( GtkBox *parent ); -static void events_activate( GtkTreeView *tree_view, GtkTreePath *path, - GtkTreeViewColumn *column, gpointer user_data ); -static int create_command_entry( GtkBox *parent, GtkAccelGroup *accel_group ); -static int create_buttons( GtkDialog *parent, GtkAccelGroup *accel_group ); - -static int activate_debugger( void ); -static void update_memory_map( void ); -static void update_breakpoints( void ); -static void update_disassembly( void ); -static void update_events( void ); -static void add_event( gpointer data, gpointer user_data ); -static int deactivate_debugger( void ); - -static gboolean -disassembly_key_press( GtkTreeView *list, GdkEventKey *event, - gpointer user_data ); -static gboolean -disassembly_wheel_scroll( GtkTreeView *list GCC_UNUSED, GdkEvent *event, - gpointer user_data ); - -static void move_disassembly( GtkAdjustment *adjustment, gpointer user_data ); - -static void evaluate_command( GtkWidget *widget, gpointer user_data ); -static void gtkui_debugger_done_step( GtkWidget *widget, gpointer user_data ); -static void gtkui_debugger_done_continue( GtkWidget *widget, - gpointer user_data ); -static void gtkui_debugger_break( GtkWidget *widget, gpointer user_data ); -static gboolean delete_dialog( GtkWidget *widget, GdkEvent *event, - gpointer user_data ); -static void gtkui_debugger_done_close( GtkWidget *widget, gpointer user_data ); - -static GtkWidget *dialog, /* The debugger dialog box */ - *continue_button, *break_button, /* Two of its buttons */ - *register_display, /* The register display */ - *registers[18], /* Individual registers */ - *memory_map, /* The memory map display */ - *memory_map_table, /* The table for the memory map */ - *map_label[MEMORY_PAGES_IN_64K][4], /* Labels in the memory map */ - *breakpoints, /* The breakpoint display */ - *disassembly_box, /* A box to hold the disassembly */ - *disassembly, /* The actual disassembly widget */ - *stack, /* The stack display */ - *events; /* The events display */ - -static GtkListStore *breakpoints_model, *disassembly_model, *stack_model, - *events_model; - -static GtkAdjustment *disassembly_scrollbar_adjustment; - -/* The top line of the current disassembly */ -static libspectrum_word disassembly_top; - -/* The next line below the current disassembly */ -static libspectrum_word disassembly_bottom; - -/* Have we created the above yet? */ -static int dialog_created = 0; - -/* Is the debugger window active (as opposed to the debugger itself)? */ -static int debugger_active; - -/* The UIManager used to create the menu bar */ -static GtkUIManager *ui_manager_debugger = NULL; - -/* The debugger's menu bar */ -const gchar debugger_menu[] = -"" -" " -" " -" " -" " -" " -" " -" " -" " -""; - -/* The debugger's menu actions */ -static GtkActionEntry menu_data[] = { - - { "VIEW", NULL, "_View", NULL, NULL, NULL }, - -}; - -static GtkToggleActionEntry menu_toggles[] = { - - { "VIEW_REGISTERS", NULL, "_Registers", NULL, NULL, G_CALLBACK( toggle_display_registers ), TRUE }, - { "VIEW_MEMORY_MAP", NULL, "_Memory Map", NULL, NULL, G_CALLBACK( toggle_display_memory_map ), TRUE }, - { "VIEW_BREAKPOINTS", NULL, "_Breakpoints", NULL, NULL, G_CALLBACK( toggle_display_breakpoints ), TRUE }, - { "VIEW_DISASSEMBLY", NULL, "_Disassembly", NULL, NULL, G_CALLBACK( toggle_display_disassembly ), TRUE }, - { "VIEW_STACK", NULL, "_Stack", NULL, NULL, G_CALLBACK( toggle_display_stack ), TRUE }, - { "VIEW_EVENTS", NULL, "_Events", NULL, NULL, G_CALLBACK( toggle_display_events ), TRUE }, - -}; - -static const char* -format_8_bit( void ) -{ - return debugger_output_base == 10 ? "%3d" : "0x%02X"; -} - -static const char* -format_16_bit( void ) -{ - return debugger_output_base == 10 ? "%5d" : "0x%04X"; -} - -int -ui_debugger_activate( void ) -{ - int error; - - fuse_emulation_pause(); - - /* Create the dialog box if it doesn't already exist */ - if( !dialog_created ) if( create_dialog() ) return 1; - - gtk_widget_show_all( dialog ); - error = hide_hidden_panes(); if( error ) return error; - - gtk_widget_set_sensitive( continue_button, 1 ); - gtk_widget_set_sensitive( break_button, 0 ); - if( !debugger_active ) activate_debugger(); - - return 0; -} - -void -ui_breakpoints_updated( void ) -{ - /* TODO: Refresh debugger list here */ -} - -static int -hide_hidden_panes( void ) -{ - debugger_pane i; - GtkCheckMenuItem *checkitem; GtkWidget *pane; - - for( i = DEBUGGER_PANE_BEGIN; i < DEBUGGER_PANE_END; i++ ) { - - checkitem = get_pane_menu_item( i ); if( !checkitem ) return 1; - - if( gtk_check_menu_item_get_active( checkitem ) ) continue; - - pane = get_pane( i ); if( !pane ) return 1; - - gtk_widget_hide( pane ); - } - - return 0; -} - -static GtkCheckMenuItem* -get_pane_menu_item( debugger_pane pane ) -{ - const gchar *path; - GtkWidget *menu_item; - - path = NULL; - - switch( pane ) { - case DEBUGGER_PANE_REGISTERS: path = "/View/Registers"; break; - case DEBUGGER_PANE_MEMORYMAP: path = "/View/Memory Map"; break; - case DEBUGGER_PANE_BREAKPOINTS: path = "/View/Breakpoints"; break; - case DEBUGGER_PANE_DISASSEMBLY: path = "/View/Disassembly"; break; - case DEBUGGER_PANE_STACK: path = "/View/Stack"; break; - case DEBUGGER_PANE_EVENTS: path = "/View/Events"; break; - - case DEBUGGER_PANE_END: break; - } - - if( !path ) { - ui_error( UI_ERROR_ERROR, "unknown debugger pane %u", pane ); - return NULL; - } - - gchar *full_path = g_strdup_printf( "/DebuggerMenu%s", path ); - menu_item = gtk_ui_manager_get_widget( ui_manager_debugger, full_path ); - g_free( full_path ); - - if( !menu_item ) { - ui_error( UI_ERROR_ERROR, "couldn't get menu item '%s'", - path ); - return NULL; - } - - return GTK_CHECK_MENU_ITEM( menu_item ); -} - -static GtkWidget* -get_pane( debugger_pane pane ) -{ - switch( pane ) { - case DEBUGGER_PANE_REGISTERS: return register_display; - case DEBUGGER_PANE_MEMORYMAP: return memory_map; - case DEBUGGER_PANE_BREAKPOINTS: return breakpoints; - case DEBUGGER_PANE_DISASSEMBLY: return disassembly_box; - case DEBUGGER_PANE_STACK: return stack; - case DEBUGGER_PANE_EVENTS: return events; - - case DEBUGGER_PANE_END: break; - } - - ui_error( UI_ERROR_ERROR, "unknown debugger pane %u", pane ); - return NULL; -} - -int -ui_debugger_deactivate( int interruptable ) -{ - if( debugger_active ) deactivate_debugger(); - - if( dialog_created ) { - gtk_widget_set_sensitive( continue_button, !interruptable ); - gtk_widget_set_sensitive( break_button, interruptable ); - } - - return 0; -} - -static int -create_dialog( void ) -{ - int error; - GtkWidget *hbox, *vbox, *hbox2, *content_area; - GtkAccelGroup *accel_group; - - PangoFontDescription *font; - - error = gtkui_get_monospaced_font( &font ); if( error ) return error; - - dialog = gtkstock_dialog_new( "Fuse - Debugger", - G_CALLBACK( delete_dialog ) ); - content_area = gtk_dialog_get_content_area( GTK_DIALOG( dialog ) ); - - /* The menu bar */ - error = create_menu_bar( GTK_BOX( content_area ), &accel_group ); - if( error ) return error; - - /* Keyboard shortcuts */ - gtk_window_add_accel_group( GTK_WINDOW( dialog ), accel_group ); - - /* Some boxes to contain the things we want to display */ - hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ); - gtk_box_pack_start( GTK_BOX( content_area ), hbox, TRUE, TRUE, 5 ); - - vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 5 ); - gtk_box_pack_start( GTK_BOX( hbox ), vbox, TRUE, TRUE, 5 ); - - hbox2 = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 5 ); - gtk_box_pack_start( GTK_BOX( vbox ), hbox2, TRUE, TRUE, 0 ); - - /* The main display areas */ - error = create_register_display( GTK_BOX( hbox2 ), font ); - if( error ) return error; - - error = create_memory_map( GTK_BOX( hbox2 ) ); if( error ) return error; - - create_breakpoints( GTK_BOX( vbox ) ); - create_disassembly( GTK_BOX( hbox ), font ); - create_stack_display( GTK_BOX( hbox ), font ); - create_events( GTK_BOX( hbox ) ); - - error = create_command_entry( GTK_BOX( content_area ), accel_group ); - if( error ) return error; - - /* The action buttons */ - - error = create_buttons( GTK_DIALOG( dialog ), accel_group ); - if( error ) return error; - - gtkui_free_font( font ); - - dialog_created = 1; - - return 0; -} - -static int -create_menu_bar( GtkBox *parent, GtkAccelGroup **accel_group ) -{ - GError *error = NULL; - GtkActionGroup *menu_action_group; - GtkWidget *menu_bar; - guint ui_menu_id; - - /* FIXME: we should unref this at some point */ - ui_manager_debugger = gtk_ui_manager_new(); - - /* Load actions */ - menu_action_group = gtk_action_group_new( "DebuggerActionGroup" ); - gtk_action_group_add_actions( menu_action_group, menu_data, - ARRAY_SIZE( menu_data ), NULL ); - gtk_action_group_add_toggle_actions( menu_action_group, menu_toggles, - ARRAY_SIZE( menu_toggles ), NULL ); - gtk_ui_manager_insert_action_group( ui_manager_debugger, menu_action_group, - 0 ); - g_object_unref( menu_action_group ); - - /* Load the menu */ - ui_menu_id = gtk_ui_manager_add_ui_from_string( ui_manager_debugger, - debugger_menu, - sizeof( debugger_menu ), - &error ); - if( error ) { - g_error_free( error ); - return 1; - } - else if( !ui_menu_id ) return 1; - - *accel_group = gtk_ui_manager_get_accel_group( ui_manager_debugger ); - - menu_bar = gtk_ui_manager_get_widget( ui_manager_debugger, "/DebuggerMenu" ); - - gtk_box_pack_start( parent, menu_bar, FALSE, FALSE, 0 ); - - return 0; -} - -static void -toggle_display( GtkToggleAction* action, debugger_pane pane_id ) -{ - GtkWidget *pane; - - pane = get_pane( pane_id ); if( !pane ) return; - - if( gtk_toggle_action_get_active( action ) ) { - gtk_widget_show_all( pane ); - } else { - gtk_widget_hide( pane ); - } -} - -static void -toggle_display_registers( GtkToggleAction* action, gpointer data GCC_UNUSED ) -{ - toggle_display( action, DEBUGGER_PANE_REGISTERS ); -} - -static void -toggle_display_memory_map( GtkToggleAction* action, gpointer data GCC_UNUSED ) -{ - toggle_display( action, DEBUGGER_PANE_MEMORYMAP ); -} - -static void -toggle_display_breakpoints( GtkToggleAction* action, gpointer data GCC_UNUSED ) -{ - toggle_display( action, DEBUGGER_PANE_BREAKPOINTS ); -} - -static void -toggle_display_disassembly( GtkToggleAction* action, gpointer data GCC_UNUSED ) -{ - toggle_display( action, DEBUGGER_PANE_DISASSEMBLY ); -} - -static void -toggle_display_stack( GtkToggleAction* action, gpointer data GCC_UNUSED ) -{ - toggle_display( action, DEBUGGER_PANE_STACK ); -} - -static void -toggle_display_events( GtkToggleAction* action, gpointer data GCC_UNUSED ) -{ - toggle_display( action, DEBUGGER_PANE_EVENTS ); -} - -static int -create_register_display( GtkBox *parent, PangoFontDescription *font ) -{ - size_t i; - -#if GTK_CHECK_VERSION( 3, 0, 0 ) - - register_display = gtk_grid_new(); - gtk_grid_set_row_spacing( GTK_GRID( register_display ), 4 ); - gtk_container_set_border_width( GTK_CONTAINER( register_display ), 6 ); - -#else /* #if GTK_CHECK_VERSION( 3, 0, 0 ) */ - - register_display = gtk_table_new( 9, 2, FALSE ); - -#endif - - gtk_box_pack_start( parent, register_display, FALSE, FALSE, 0 ); - - for( i = 0; i < 18; i++ ) { - PangoAttrList *list; - PangoAttribute *attr; - - registers[i] = gtk_label_new( "" ); - - list = pango_attr_list_new(); - attr = pango_attr_font_desc_new( font ); - pango_attr_list_insert( list, attr ); - gtk_label_set_attributes( GTK_LABEL( registers[i] ), list ); - pango_attr_list_unref( list ); - -#if GTK_CHECK_VERSION( 3, 0, 0 ) - gtk_grid_attach( GTK_GRID( register_display ), registers[i], - i%2, i/2, 1, 1 ); -#else - gtk_table_attach( GTK_TABLE( register_display ), registers[i], - i%2, i%2+1, i/2, i/2+1, 0, 0, 2, 2 ); -#endif - - } - - return 0; -} - -static int -create_memory_map( GtkBox *parent ) -{ - GtkWidget *label_address, *label_source, *label_writable, *label_contended; - - label_address = gtk_label_new( "Address" ); - label_source = gtk_label_new( "Source" ); - label_writable = gtk_label_new( "W?" ); - label_contended = gtk_label_new( "C?" ); - - memory_map = gtk_frame_new( "Memory Map" ); - gtk_box_pack_start( parent, memory_map, FALSE, FALSE, 0 ); - -#if GTK_CHECK_VERSION( 3, 0, 0 ) - - memory_map_table = gtk_grid_new(); - gtk_grid_set_row_spacing( GTK_GRID( memory_map_table ), 4 ); - gtk_grid_set_column_spacing( GTK_GRID( memory_map_table ), 6 ); - gtk_container_set_border_width( GTK_CONTAINER( memory_map_table ), 6 ); - gtk_container_add( GTK_CONTAINER( memory_map ), memory_map_table ); - - gtk_grid_attach( GTK_GRID( memory_map_table ), label_address, 0, 0, 1, 1 ); - gtk_grid_attach( GTK_GRID( memory_map_table ), label_source, 1, 0, 1, 1 ); - gtk_grid_attach( GTK_GRID( memory_map_table ), label_writable, 2, 0, 1, 1 ); - gtk_grid_attach( GTK_GRID( memory_map_table ), label_contended, 3, 0, 1, 1 ); - -#else /* #if GTK_CHECK_VERSION( 3, 0, 0 ) */ - - memory_map_table = gtk_table_new( 1 + MEMORY_PAGES_IN_64K, 4, FALSE ); - gtk_container_add( GTK_CONTAINER( memory_map ), memory_map_table ); - - gtk_table_attach( GTK_TABLE( memory_map_table ), label_address, - 0, 1, 0, 1, 0, 0, 2, 2 ); - gtk_table_attach( GTK_TABLE( memory_map_table ), label_source, - 1, 2, 0, 1, 0, 0, 2, 2 ); - gtk_table_attach( GTK_TABLE( memory_map_table ), label_writable, - 2, 3, 0, 1, 0, 0, 2, 2 ); - gtk_table_attach( GTK_TABLE( memory_map_table ), label_contended, - 3, 4, 0, 1, 0, 0, 2, 2 ); - -#endif - - return 0; -} - -static void -create_breakpoints( GtkBox *parent ) -{ - size_t i; - - static const gchar *const titles[] = - { "ID", "Type", "Value", "Ignore", "Life", "Condition" }; - - breakpoints_model = gtk_list_store_new( BREAKPOINTS_COLUMN_COUNT, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING ); - - breakpoints = gtk_tree_view_new_with_model( GTK_TREE_MODEL( breakpoints_model ) ); - for( i = 0; i < BREAKPOINTS_COLUMN_COUNT; i++ ) { - GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes( titles[i], renderer, "text", i, NULL ); - gtk_tree_view_append_column( GTK_TREE_VIEW( breakpoints ), column ); - } - - gtk_box_pack_start( parent, breakpoints, TRUE, TRUE, 0 ); -} - -static void -create_disassembly( GtkBox *parent, PangoFontDescription *font ) -{ - size_t i; - - GtkWidget *scrollbar; - static const gchar *const titles[] = - { "Address", "Instruction" }; - - /* A box to hold the disassembly listing and the scrollbar */ - disassembly_box = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ); - gtk_box_pack_start( parent, disassembly_box, TRUE, TRUE, 0 ); - - /* The disassembly itself */ - disassembly_model = - gtk_list_store_new( DISASSEMBLY_COLUMN_COUNT, G_TYPE_STRING, G_TYPE_STRING ); - - disassembly = gtk_tree_view_new_with_model( GTK_TREE_MODEL( disassembly_model ) ); - for( i = 0; i < DISASSEMBLY_COLUMN_COUNT; i++ ) { - GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes( titles[i], renderer, "text", i, NULL ); - g_object_set( G_OBJECT( renderer ), "font-desc", font, "height", 18, NULL ); - gtk_tree_view_append_column( GTK_TREE_VIEW( disassembly ), column ); - } - - gtk_box_pack_start( GTK_BOX( disassembly_box ), disassembly, TRUE, TRUE, 0 ); - - /* The disassembly scrollbar */ - disassembly_scrollbar_adjustment = GTK_ADJUSTMENT( - gtk_adjustment_new( 0, 0x0000, 0x10000, 1, 20, 20 ) ); - g_signal_connect( G_OBJECT( disassembly_scrollbar_adjustment ), - "value-changed", G_CALLBACK( move_disassembly ), - NULL ); - scrollbar = gtk_scrollbar_new( GTK_ORIENTATION_VERTICAL, - disassembly_scrollbar_adjustment ); - gtk_box_pack_start( GTK_BOX( disassembly_box ), scrollbar, FALSE, FALSE, 0 ); - - /* Scrolling with keys */ - g_signal_connect( GTK_TREE_VIEW( disassembly ), "key-press-event", - G_CALLBACK( disassembly_key_press ), - disassembly_scrollbar_adjustment ); - - /* Scrolling with mouse wheel */ - g_signal_connect( GTK_TREE_VIEW( disassembly ), "scroll-event", - G_CALLBACK( disassembly_wheel_scroll ), - disassembly_scrollbar_adjustment ); -} - -static void -create_stack_display( GtkBox *parent, PangoFontDescription *font ) -{ - size_t i; - static const gchar *const titles[] = { "Address", "Instruction" }; - - stack_model = - gtk_list_store_new( STACK_COLUMN_COUNT, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_INT ); - - stack = gtk_tree_view_new_with_model( GTK_TREE_MODEL( stack_model ) ); - - for( i = 0; i < 2; i++ ) { - GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes( titles[i], renderer, "text", i, NULL ); - g_object_set( G_OBJECT( renderer ), "font-desc", font, "height", 18, NULL ); - gtk_tree_view_append_column( GTK_TREE_VIEW( stack ), column ); - } - - gtk_box_pack_start( parent, stack, TRUE, TRUE, 5 ); - - g_signal_connect( G_OBJECT( stack ), "row-activated", G_CALLBACK( stack_activate ), NULL ); -} - -static void -stack_activate( GtkTreeView *tree_view, GtkTreePath *path, - GtkTreeViewColumn *column GCC_UNUSED, - gpointer user_data GCC_UNUSED ) -{ - GtkTreeIter it; - GtkTreeModel *model = gtk_tree_view_get_model( tree_view ); - - if( model && gtk_tree_model_get_iter( model, &it, path ) ) { - gint address; - int error; - - gtk_tree_model_get( model, &it, STACK_COLUMN_VALUE_INT, &address, -1 ); - - error = debugger_breakpoint_add_address( - DEBUGGER_BREAKPOINT_TYPE_EXECUTE, memory_source_any, 0, address, 0, - DEBUGGER_BREAKPOINT_LIFE_ONESHOT, NULL - ); - if( error ) return; - - debugger_run(); - } -} - -static void -create_events( GtkBox *parent ) -{ - static const gchar *const titles[] = { "Time", "Type" }; - size_t i; - - events_model = - gtk_list_store_new( EVENTS_COLUMN_COUNT, G_TYPE_INT, G_TYPE_STRING ); - - events = gtk_tree_view_new_with_model( GTK_TREE_MODEL( events_model ) ); - - for( i = 0; i < EVENTS_COLUMN_COUNT; i++ ) { - GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes( titles[i], renderer, "text", i, NULL ); - gtk_tree_view_append_column( GTK_TREE_VIEW( events ), column ); - } - - gtk_box_pack_start( parent, events, TRUE, TRUE, 5 ); - - g_signal_connect( G_OBJECT( events ), "row-activated", G_CALLBACK( events_activate ), NULL ); -} - -static void -events_activate( GtkTreeView *tree_view, GtkTreePath *path, - GtkTreeViewColumn *column GCC_UNUSED, - gpointer user_data GCC_UNUSED ) -{ - GtkTreeIter it; - GtkTreeModel *model = gtk_tree_view_get_model( tree_view ); - - if( model && gtk_tree_model_get_iter( model, &it, path ) ) { - libspectrum_dword event_tstates; - int error; - - gtk_tree_model_get( model, &it, EVENTS_COLUMN_TIME, &event_tstates, -1 ); - - error = debugger_breakpoint_add_time( - DEBUGGER_BREAKPOINT_TYPE_TIME, event_tstates, 0, - DEBUGGER_BREAKPOINT_LIFE_ONESHOT, NULL - ); - if( error ) return; - - debugger_run(); - } -} - -static int -create_command_entry( GtkBox *parent, GtkAccelGroup *accel_group ) -{ - GtkWidget *hbox, *entry, *eval_button; - - /* An hbox to hold the command entry widget and the 'evaluate' button */ - hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 5 ); - gtk_box_pack_start( parent, hbox, FALSE, FALSE, 0 ); - - /* The command entry widget */ - entry = gtk_entry_new(); - g_signal_connect( G_OBJECT( entry ), "activate", - G_CALLBACK( evaluate_command ), NULL ); - gtk_box_pack_start( GTK_BOX( hbox ), entry, TRUE, TRUE, 0 ); - - /* The 'command evaluate' button */ - eval_button = gtk_button_new_with_label( "Evaluate" ); - g_signal_connect_swapped( G_OBJECT( eval_button ), "clicked", - G_CALLBACK( evaluate_command ), - G_OBJECT( entry ) ); - gtk_box_pack_start( GTK_BOX( hbox ), eval_button, FALSE, FALSE, 0 ); - - /* Return is equivalent to clicking on 'evaluate' */ - gtk_widget_add_accelerator( eval_button, "clicked", accel_group, - GDK_KEY_Return, 0, 0 ); - - return 0; -} - -static int -create_buttons( GtkDialog *parent, GtkAccelGroup *accel_group ) -{ - static const gtkstock_button - step = { "Single step", G_CALLBACK( gtkui_debugger_done_step ), NULL, NULL, 0, 0, 0, 0, GTK_RESPONSE_NONE }, - cont = { "Continue", G_CALLBACK( gtkui_debugger_done_continue ), NULL, NULL, 0, 0, 0, 0, GTK_RESPONSE_NONE }, - brk = { "Break", G_CALLBACK( gtkui_debugger_break ), NULL, NULL, 0, 0, 0, 0, GTK_RESPONSE_NONE }; - - /* Create the action buttons for the dialog box */ - gtkstock_create_button( GTK_WIDGET( parent ), accel_group, &step ); - continue_button = gtkstock_create_button( GTK_WIDGET( parent ), accel_group, - &cont ); - break_button = gtkstock_create_button( GTK_WIDGET( parent ), accel_group, - &brk ); - gtkstock_create_close( GTK_WIDGET( parent ), accel_group, - G_CALLBACK( gtkui_debugger_done_close ), TRUE ); - - return 0; -} - -static int -activate_debugger( void ) -{ - debugger_active = 1; - - ui_debugger_disassemble( PC ); - ui_debugger_update(); - - gtk_main(); - return 0; -} - -/* Update the debugger's display */ -int -ui_debugger_update( void ) -{ - size_t i; - char buffer[1024], format_string[1024]; - gchar buffer1[80], buffer2[80]; - libspectrum_word address; - int capabilities; size_t length; - - const char *register_name[] = { "PC", "SP", - "AF", "AF'", - "BC", "BC'", - "DE", "DE'", - "HL", "HL'", - "IX", "IY", - }; - - libspectrum_word *value_ptr[] = { &PC, &SP, &AF, &AF_, - &BC, &BC_, &DE, &DE_, - &HL, &HL_, &IX, &IY, - }; - - if( !dialog_created ) return 0; - - for( i = 0; i < 12; i++ ) { - snprintf( buffer, 5, "%3s ", register_name[i] ); - snprintf( &buffer[4], 76, format_16_bit(), *value_ptr[i] ); - gtk_label_set_text( GTK_LABEL( registers[i] ), buffer ); - } - - strcpy( buffer, " I " ); snprintf( &buffer[6], 76, format_8_bit(), I ); - gtk_label_set_text( GTK_LABEL( registers[12] ), buffer ); - strcpy( buffer, " R " ); - snprintf( &buffer[6], 80, format_8_bit(), ( R & 0x7f ) | ( R7 & 0x80 ) ); - gtk_label_set_text( GTK_LABEL( registers[13] ), buffer ); - - snprintf( buffer, 80, "T-states %5d\nHalted %d", tstates, z80.halted ); - gtk_label_set_text( GTK_LABEL( registers[14] ), buffer ); - snprintf( buffer, 80, " IM %d\nIFF1 %d\nIFF2 %d", IM, IFF1, IFF2 ); - gtk_label_set_text( GTK_LABEL( registers[15] ), buffer ); - - strcpy( buffer, "SZ5H3PNC\n" ); - for( i = 0; i < 8; i++ ) buffer[i+9] = ( F & ( 0x80 >> i ) ) ? '1' : '0'; - buffer[17] = '\0'; - gtk_label_set_text( GTK_LABEL( registers[16] ), buffer ); - - capabilities = libspectrum_machine_capabilities( machine_current->machine ); - - sprintf( format_string, " ULA %s", format_8_bit() ); - snprintf( buffer, 1024, format_string, ula_last_byte() ); - - if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_AY ) { - sprintf( format_string, "\n AY %s", format_8_bit() ); - length = strlen( buffer ); - snprintf( &buffer[length], 1024-length, format_string, - machine_current->ay.current_register ); - } - - if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_128_MEMORY ) { - sprintf( format_string, "\n128Mem %s", format_8_bit() ); - length = strlen( buffer ); - snprintf( &buffer[length], 1024-length, format_string, - machine_current->ram.last_byte ); - } - - if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_PLUS3_MEMORY ) { - sprintf( format_string, "\n+3 Mem %s", format_8_bit() ); - length = strlen( buffer ); - snprintf( &buffer[length], 1024-length, format_string, - machine_current->ram.last_byte2 ); - } - - if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_VIDEO || - capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_MEMORY || - capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_SE_MEMORY ) { - sprintf( format_string, "\nTmxDec %s", format_8_bit() ); - length = strlen( buffer ); - snprintf( &buffer[length], 1024-length, format_string, - scld_last_dec.byte ); - } - - if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_MEMORY || - capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_SE_MEMORY ) { - sprintf( format_string, "\nTmxHsr %s", format_8_bit() ); - length = strlen( buffer ); - snprintf( &buffer[length], 1024-length, format_string, scld_last_hsr ); - } - - if( settings_current.zxcf_active ) { - sprintf( format_string, "\n ZXCF %s", format_8_bit() ); - length = strlen( buffer ); - snprintf( &buffer[length], 1024-length, format_string, - zxcf_last_memctl() ); - } - - gtk_label_set_text( GTK_LABEL( registers[17] ), buffer ); - - update_memory_map(); - update_breakpoints(); - update_disassembly(); - - /* And the stack display */ - gtk_list_store_clear( stack_model ); - - for( i = 0, address = SP + 38; i < 20; i++, address -= 2 ) { - - GtkTreeIter it; - - libspectrum_word contents = readbyte_internal( address ) + - 0x100 * readbyte_internal( address + 1 ); - - snprintf( buffer1, sizeof( buffer1 ), format_16_bit(), address ); - snprintf( buffer2, sizeof( buffer2 ), format_16_bit(), contents ); - - gtk_list_store_append( stack_model, &it ); - gtk_list_store_set( stack_model, &it, STACK_COLUMN_ADDRESS, buffer1, STACK_COLUMN_VALUE_TEXT, buffer2, STACK_COLUMN_VALUE_INT, (gint)contents, -1 ); - } - - /* And the events display */ - update_events(); - - return 0; -} - -static void -update_memory_map( void ) -{ - int source, page_num, writable, contended; - libspectrum_word offset; - size_t i, j, block, row; - - for( i = 0; i < MEMORY_PAGES_IN_64K; i++ ) { - if( map_label[i][0] ) { - for( j = 0; j < 4; j++ ) { - gtk_container_remove( GTK_CONTAINER( memory_map_table ), map_label[i][j] ); - map_label[i][j] = NULL; - } - } - } - - source = page_num = writable = contended = -1; - offset = 0; - row = 0; - - for( block = 0; block < MEMORY_PAGES_IN_64K; block++ ) { - memory_page *page = &memory_map_read[block]; - - if( page->source != source || - page->page_num != page_num || - page->offset != offset || - page->writable != writable || - page->contended != contended ) { - - char buffer[40]; - GtkWidget **row_labels = map_label[row]; - - snprintf( buffer, 40, format_16_bit(), - (unsigned)block * MEMORY_PAGE_SIZE ); - row_labels[0] = gtk_label_new( buffer ); - - snprintf( buffer, 40, "%s %d", - memory_source_description( page->source ), page->page_num ); - row_labels[1] = gtk_label_new( buffer ); - - row_labels[2] = gtk_label_new( page->writable ? "Y" : "N" ); - row_labels[3] = gtk_label_new( page->contended ? "Y" : "N" ); - - for( i = 0; i < 4; i++ ) { - -#if GTK_CHECK_VERSION( 3, 0, 0 ) - gtk_grid_attach( GTK_GRID( memory_map_table ), row_labels[i], - i, row + 1, 1, 1 ); -#else - gtk_table_attach( GTK_TABLE( memory_map_table ), row_labels[i], - i, i + 1, row + 1, row + 2, 0, 0, 2, 2 ); -#endif - - } - - row++; - - source = page->source; - page_num = page->page_num; - writable = page->writable; - contended = page->contended; - offset = page->offset; - } - - /* We expect the next page to have an increased offset */ - offset += MEMORY_PAGE_SIZE; - } - - gtk_widget_show_all( GTK_WIDGET( memory_map_table ) ); -} - -static void -update_breakpoints( void ) -{ - GSList *ptr; - - gtk_list_store_clear( breakpoints_model ); - - for( ptr = debugger_breakpoints; ptr; ptr = ptr->next ) { - - debugger_breakpoint *bp = ptr->data; - GtkTreeIter it; - gchar buffer[40], format_string[40]; - - switch( bp->type ) { - - case DEBUGGER_BREAKPOINT_TYPE_EXECUTE: - case DEBUGGER_BREAKPOINT_TYPE_READ: - case DEBUGGER_BREAKPOINT_TYPE_WRITE: - if( bp->value.address.source == memory_source_any ) { - snprintf( buffer, sizeof( buffer ), format_16_bit(), - bp->value.address.offset ); - } else { - snprintf( format_string, sizeof( format_string ), "%%s:%s:%s", - format_16_bit(), format_16_bit() ); - snprintf( buffer, sizeof( buffer ), format_string, - memory_source_description( bp->value.address.source ), - bp->value.address.page, bp->value.address.offset ); - } - break; - - case DEBUGGER_BREAKPOINT_TYPE_PORT_READ: - case DEBUGGER_BREAKPOINT_TYPE_PORT_WRITE: - snprintf( format_string, sizeof( format_string ), "%s:%s", - format_16_bit(), format_16_bit() ); - snprintf( buffer, sizeof( buffer ), format_string, bp->value.port.mask, - bp->value.port.port ); - break; - - case DEBUGGER_BREAKPOINT_TYPE_TIME: - snprintf( buffer, sizeof( buffer ), "%5d", bp->value.time.tstates ); - break; - - case DEBUGGER_BREAKPOINT_TYPE_EVENT: - snprintf( buffer, sizeof( buffer ), "%s:%s", bp->value.event.type, - bp->value.event.detail ); - break; - - } - - gtk_list_store_append( breakpoints_model, &it ); - gtk_list_store_set( - breakpoints_model, &it, - BREAKPOINTS_COLUMN_ID, bp->id, - BREAKPOINTS_COLUMN_TYPE, debugger_breakpoint_type_text[ bp->type ], - BREAKPOINTS_COLUMN_VALUE, buffer, - BREAKPOINTS_COLUMN_IGNORE, bp->ignore, - BREAKPOINTS_COLUMN_LIFE, debugger_breakpoint_life_text[ bp->life ], - -1 - ); - - if( bp->condition ) { - gchar buffer2[80]; - debugger_expression_deparse( buffer2, sizeof( buffer2 ), bp->condition ); - gtk_list_store_set( breakpoints_model, &it, BREAKPOINTS_COLUMN_CONDITION, buffer2, -1 ); - } - - } -} - -static void -update_disassembly( void ) -{ - size_t i; libspectrum_word address; - GtkTreeIter it; - - gtk_list_store_clear( disassembly_model ); - - for( i = 0, address = disassembly_top; i < 20; i++ ) { - size_t l, length; - char buffer1[40], buffer2[40]; - - snprintf( buffer1, sizeof( buffer1 ), format_16_bit(), address ); - debugger_disassemble( buffer2, sizeof( buffer2 ), &length, address ); - - /* pad to 16 characters (long instruction) to avoid varying width */ - l = strlen( buffer2 ); - while( l < 16 ) buffer2[l++] = ' '; - buffer2[l] = 0; - - gtk_list_store_append( disassembly_model, &it ); - gtk_list_store_set( disassembly_model, &it, DISASSEMBLY_COLUMN_ADDRESS, buffer1, DISASSEMBLY_COLUMN_INSTRUCTION, buffer2, -1 ); - - address += length; - } - - disassembly_bottom = address; -} - -static void -update_events( void ) -{ - gtk_list_store_clear( events_model ); - event_foreach( add_event, NULL ); -} - -static void -add_event( gpointer data, gpointer user_data GCC_UNUSED ) -{ - event_t *ptr = data; - GtkTreeIter it; - - if( ptr->type != event_type_null ) { - gtk_list_store_append( events_model, &it ); - gtk_list_store_set( events_model, &it, EVENTS_COLUMN_TIME, ptr->tstates, EVENTS_COLUMN_TYPE, event_name( ptr->type ), -1 ); - } -} - -static int -deactivate_debugger( void ) -{ - gtk_main_quit(); - debugger_active = 0; - fuse_emulation_unpause(); - return 0; -} - -/* Set the disassembly to start at 'address' */ -int -ui_debugger_disassemble( libspectrum_word address ) -{ - disassembly_top = address; - - /* Block further events while adjusting scrollbar. */ - g_signal_handlers_block_by_func( G_OBJECT( disassembly_scrollbar_adjustment ), - G_CALLBACK( move_disassembly ), NULL ); - - /* Note: GtkAdjustment can not cope with "upper bound - page_size" value and - higher */ - gtk_adjustment_set_value( disassembly_scrollbar_adjustment, address ); - - /* Enable events for scrollbar */ - g_signal_handlers_unblock_by_func( G_OBJECT(disassembly_scrollbar_adjustment), - G_CALLBACK( move_disassembly ), NULL ); - - /* And update the disassembly if the debugger is active */ - if( debugger_active ) { - update_disassembly(); - } - - return 0; -} - -/* Called when the disassembly scrollbar is moved */ -static void -move_disassembly( GtkAdjustment *adjustment, gpointer user_data GCC_UNUSED ) -{ - gdouble value; - int cursor_row; - libspectrum_word addresss; - - /* FIXME: Movements are imprecise while dragging the scroll bar */ - value = gtk_adjustment_get_value( adjustment ); - - cursor_row = gtkui_list_get_cursor( GTK_TREE_VIEW( disassembly ) ); - - /* disassembly_top < value <= disassembly_top + 1 => 'down' button pressed - Move the disassembly on by one instruction */ - if( value > disassembly_top && value - disassembly_top <= 1 ) { - - addresss = debugger_search_instruction( disassembly_top, 1 ); - ui_debugger_disassemble( addresss ); - - /* disassembly_top - 1 <= value < disassembly_top => 'up' button pressed - - The desired state after this is for the current top instruction - to be the second instruction shown in the disassembly. - - Unfortunately, it's not trivial to determine where disassembly - should now start, as we have variable length instructions of - unbounded length (multiple DD and FD prefixes on one instruction - are possible). - - In general, we want the _longest_ opcode which produces the - current top in second place (consider something like LD A,nn: - we're not interested if nn happens to represent a one-byte - opcode), so look back a reasonable length (say, 8 bytes) and see - what we find. - - In some cases (eg if we're currently pointing to a data byte of a - multi-byte opcode), it will be impossible to get the current top - second. In this case, just move back a byte. - - */ - } else if( value < disassembly_top && disassembly_top - value <= 1 ) { - - addresss = debugger_search_instruction( disassembly_top, -1 ); - ui_debugger_disassemble( addresss ); - - /* Anything else, just set disassembly_top to that value */ - } else if( value != disassembly_top ) { - - ui_debugger_disassemble( value ); - - } - - /* Mark selected row */ - gtkui_list_set_cursor( GTK_TREE_VIEW( disassembly ), cursor_row ); -} - -static gboolean -disassembly_key_press( GtkTreeView *list, GdkEventKey *event, - gpointer user_data ) -{ - GtkAdjustment *adjustment = user_data; - gdouble page_size, page_increment; - int cursor_row; - libspectrum_word initial_top, addresss; - - initial_top = disassembly_top; - page_size = gtk_adjustment_get_page_size( adjustment ); - page_increment = gtk_adjustment_get_page_increment( adjustment ); - - /* Get selected row */ - cursor_row = gtkui_list_get_cursor( list ); - - switch( event->keyval ) { - - case GDK_KEY_Down: - if( cursor_row == page_size - 1 ) { - addresss = debugger_search_instruction( disassembly_top, 1 ); - ui_debugger_disassemble( addresss ); - } - break; - - case GDK_KEY_Up: - if( cursor_row == 0 ) { - addresss = debugger_search_instruction( disassembly_top, -1 ); - ui_debugger_disassemble( addresss ); - } - break; - - case GDK_KEY_Page_Down: - ui_debugger_disassemble( disassembly_bottom ); - break; - - case GDK_KEY_Page_Up: - addresss = debugger_search_instruction( disassembly_top, -page_increment ); - ui_debugger_disassemble( addresss ); - break; - - case GDK_KEY_Home: - cursor_row = 0; - ui_debugger_disassemble( 0x0000 ); - break; - - case GDK_KEY_End: - cursor_row = page_size - 1; - addresss = debugger_search_instruction( 0x0000, -page_size ); - ui_debugger_disassemble( addresss ); - break; - - default: - return FALSE; - } - - if( initial_top != disassembly_top ) { - update_disassembly(); - - /* Mark selected row */ - gtkui_list_set_cursor( list, cursor_row ); - return TRUE; - } - - return FALSE; -} - -/* Called when the wheel mouse is moved on the list (not on the scrollbar) */ -static gboolean -disassembly_wheel_scroll( GtkTreeView *list GCC_UNUSED, GdkEvent *event, - gpointer user_data ) -{ - libspectrum_word initial_top, addresss; - int cursor_row; - - initial_top = disassembly_top; - - /* Get selected row */ - cursor_row = gtkui_list_get_cursor( list ); - - switch( event->scroll.direction ) { - case GDK_SCROLL_UP: - addresss = debugger_search_instruction( disassembly_top, -1 ); - ui_debugger_disassemble( addresss ); - break; - - case GDK_SCROLL_DOWN: - addresss = debugger_search_instruction( disassembly_top, 1 ); - ui_debugger_disassemble( addresss ); - break; - -#if GTK_CHECK_VERSION( 3, 4, 0 ) - - case GDK_SCROLL_SMOOTH: - { - GtkAdjustment *adjustment = user_data; - static gdouble total_dy = 0; - gdouble dx, dy, page_size; - int delta; - - if( gdk_event_get_scroll_deltas( event, &dx, &dy ) ) { - /* Calculate number of instructions to jump */ - total_dy += dy; - page_size = gtk_adjustment_get_page_size( adjustment ); - delta = total_dy * pow( page_size, 2.0 / 3.0 ); - - /* Is movement significative? */ - if( delta ) { - addresss = debugger_search_instruction( disassembly_top, delta ); - ui_debugger_disassemble( addresss ); - total_dy = 0; - } - } - break; - } - -#endif - - default: - return FALSE; - } - - if( initial_top != disassembly_top ) { - /* Mark selected row */ - gtkui_list_set_cursor( list, cursor_row ); - return TRUE; - } - - return FALSE; -} - -/* Evaluate the command currently in the entry box */ -static void -evaluate_command( GtkWidget *widget, gpointer user_data GCC_UNUSED ) -{ - debugger_command_evaluate( gtk_entry_get_text( GTK_ENTRY( widget ) ) ); -} - -static void -gtkui_debugger_done_step( GtkWidget *widget GCC_UNUSED, - gpointer user_data GCC_UNUSED ) -{ - debugger_step(); -} - -static void -gtkui_debugger_done_continue( GtkWidget *widget GCC_UNUSED, - gpointer user_data GCC_UNUSED ) -{ - debugger_run(); -} - -static void -gtkui_debugger_break( GtkWidget *widget GCC_UNUSED, - gpointer user_data GCC_UNUSED ) -{ - debugger_mode = DEBUGGER_MODE_HALTED; - gtk_widget_set_sensitive( continue_button, 1 ); - gtk_widget_set_sensitive( break_button, 0 ); -} - -static gboolean -delete_dialog( GtkWidget *widget, GdkEvent *event GCC_UNUSED, - gpointer user_data ) -{ - gtkui_debugger_done_close( widget, user_data ); - return TRUE; -} - -static void -gtkui_debugger_done_close( GtkWidget *widget, gpointer user_data GCC_UNUSED ) -{ - gtk_widget_hide( widget ); - gtkui_debugger_done_continue( NULL, NULL ); -} diff --git a/fuse/ui/gtk/fileselector.c b/fuse/ui/gtk/fileselector.c deleted file mode 100644 index 05dfd81..0000000 --- a/fuse/ui/gtk/fileselector.c +++ /dev/null @@ -1,357 +0,0 @@ -/* fileselector.c: GTK fileselector routines - Copyright (c) 2000-2007 Philip Kendall - Copyright (c) 2015-2016 Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include - -#include "gtkinternals.h" -#include "ui/ui.h" - -static gchar *current_folder; - -static void add_filter_defaults( GtkWidget *file_chooser ); -static void add_filter_auxiliary_files( GtkFileFilter *filter ); -static void add_filter_disk_files( GtkFileFilter *filter ); -static void add_filter_dock_files( GtkFileFilter *filter ); -static void add_filter_harddisk_files( GtkFileFilter *filter ); -static void add_filter_microdrive_files( GtkFileFilter *filter ); -static void add_filter_movie_files( GtkFileFilter *filter ); -static void add_filter_recording_files( GtkFileFilter *filter ); -static void add_filter_snapshot_files( GtkFileFilter *filter ); -static void add_filter_tape_files( GtkFileFilter *filter ); - -#if defined LIBSPECTRUM_SUPPORTS_BZ2_COMPRESSION || \ - defined LIBSPECTRUM_SUPPORTS_ZLIB_COMPRESSION -static void add_filter_compressed_files( GtkFileFilter *filter ); -#endif - -static char* -run_dialog( const char *title, GtkFileChooserAction action ) -{ - GtkWidget *dialog; - char *filename = NULL; - const char *button; - - if( action == GTK_FILE_CHOOSER_ACTION_SAVE ) { - button = "_Save"; - } else { - button = "_Open"; - } - - dialog = - gtk_file_chooser_dialog_new( title, GTK_WINDOW( gtkui_window ), - action, "_Cancel", GTK_RESPONSE_CANCEL, - button, GTK_RESPONSE_ACCEPT, - NULL ); - - gtk_dialog_set_default_response( GTK_DIALOG( dialog ), GTK_RESPONSE_ACCEPT ); - - /* TODO: select filter based on UI operation (snapshot, recording, screenshot) */ - /* TODO: custom filter based file action (open, save) */ - add_filter_defaults( dialog ); - - if( current_folder ) - gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( dialog ), current_folder ); - - if( gtk_dialog_run( GTK_DIALOG( dialog ) ) == GTK_RESPONSE_ACCEPT ) { - gchar *new_folder = gtk_file_chooser_get_current_folder( GTK_FILE_CHOOSER( dialog ) ); - if( new_folder ) { - g_free( current_folder ); - current_folder = new_folder; - } - filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( dialog ) ); - } - - gtk_widget_destroy( dialog ); - - return filename; -} - - -char* -ui_get_open_filename( const char *title ) -{ - return run_dialog( title, GTK_FILE_CHOOSER_ACTION_OPEN ); -} - -char* -ui_get_save_filename( const char *title ) -{ - return run_dialog( title, GTK_FILE_CHOOSER_ACTION_SAVE ); -} - -static void -add_filter_defaults( GtkWidget *file_chooser ) -{ - GtkFileFilter *filter; - - /* TODO: poll libspectrum for supported file extensions and avoid duplication - between UIs */ - filter = gtk_file_filter_new(); - gtk_file_filter_set_name( filter, "Supported Files" ); - add_filter_auxiliary_files( filter ); -#if defined LIBSPECTRUM_SUPPORTS_BZ2_COMPRESSION || \ - defined LIBSPECTRUM_SUPPORTS_ZLIB_COMPRESSION - add_filter_compressed_files( filter ); -#endif - add_filter_disk_files( filter ); - add_filter_dock_files( filter ); - add_filter_harddisk_files( filter ); - add_filter_microdrive_files( filter ); - add_filter_movie_files( filter ); - add_filter_recording_files( filter ); - add_filter_snapshot_files( filter ); - add_filter_tape_files( filter ); - gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( file_chooser ), filter ); - - filter = gtk_file_filter_new(); - gtk_file_filter_set_name( filter, "All Files" ); - gtk_file_filter_add_pattern( filter, "*" ); - gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( file_chooser ), filter ); - - filter = gtk_file_filter_new(); - gtk_file_filter_set_name( filter, "Auxiliary Files" ); - add_filter_auxiliary_files( filter ); - gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( file_chooser ), filter ); - - filter = gtk_file_filter_new(); - gtk_file_filter_set_name( filter, "Cartridge Files" ); - add_filter_dock_files( filter ); - gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( file_chooser ), filter ); - -#if defined LIBSPECTRUM_SUPPORTS_BZ2_COMPRESSION || \ - defined LIBSPECTRUM_SUPPORTS_ZLIB_COMPRESSION - filter = gtk_file_filter_new(); - gtk_file_filter_set_name( filter, "Compressed Files" ); - add_filter_compressed_files( filter ); - gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( file_chooser ), filter ); -#endif - - filter = gtk_file_filter_new(); - gtk_file_filter_set_name( filter, "Disk Files" ); - add_filter_disk_files( filter ); - gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( file_chooser ), filter ); - - filter = gtk_file_filter_new(); - gtk_file_filter_set_name( filter, "Harddisk Files" ); - add_filter_harddisk_files( filter ); - gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( file_chooser ), filter ); - - filter = gtk_file_filter_new(); - gtk_file_filter_set_name( filter, "Microdrive Files" ); - add_filter_microdrive_files( filter ); - gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( file_chooser ), filter ); - - filter = gtk_file_filter_new(); - gtk_file_filter_set_name( filter, "Movie Files" ); - add_filter_movie_files( filter ); - gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( file_chooser ), filter ); - - filter = gtk_file_filter_new(); - gtk_file_filter_set_name( filter, "Recording Files" ); - add_filter_recording_files( filter ); - gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( file_chooser ), filter ); - - filter = gtk_file_filter_new(); - gtk_file_filter_set_name( filter, "Snapshot Files" ); - add_filter_snapshot_files( filter ); - gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( file_chooser ), filter ); - - filter = gtk_file_filter_new(); - gtk_file_filter_set_name( filter, "Tape Files" ); - add_filter_tape_files( filter ); - gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( file_chooser ), filter ); - -} - -static void -add_filter_auxiliary_files( GtkFileFilter *filter ) -{ - gtk_file_filter_add_pattern( filter, "*.bin" ); - gtk_file_filter_add_pattern( filter, "*.log" ); - gtk_file_filter_add_pattern( filter, "*.pok" ); - gtk_file_filter_add_pattern( filter, "*.scr" ); - gtk_file_filter_add_pattern( filter, "*.mlt" ); - - gtk_file_filter_add_pattern( filter, "*.BIN" ); - gtk_file_filter_add_pattern( filter, "*.LOG" ); - gtk_file_filter_add_pattern( filter, "*.POK" ); - gtk_file_filter_add_pattern( filter, "*.SCR" ); - gtk_file_filter_add_pattern( filter, "*.MLT" ); - -#ifdef USE_LIBPNG - gtk_file_filter_add_pattern( filter, "*.png" ); - gtk_file_filter_add_pattern( filter, "*.PNG" ); -#endif - -#ifdef HAVE_LIB_XML2 - gtk_file_filter_add_pattern( filter, "*.svg" ); - gtk_file_filter_add_pattern( filter, "*.SVG" ); -#endif -} - - -#if defined LIBSPECTRUM_SUPPORTS_BZ2_COMPRESSION || \ - defined LIBSPECTRUM_SUPPORTS_ZLIB_COMPRESSION - -static void -add_filter_compressed_files( GtkFileFilter *filter ) -{ -#ifdef LIBSPECTRUM_SUPPORTS_ZLIB_COMPRESSION - gtk_file_filter_add_pattern( filter, "*.gz" ); - gtk_file_filter_add_pattern( filter, "*.GZ" ); - gtk_file_filter_add_pattern( filter, "*.zip" ); - gtk_file_filter_add_pattern( filter, "*.ZIP" ); -#endif - -#ifdef LIBSPECTRUM_SUPPORTS_BZ2_COMPRESSION - gtk_file_filter_add_pattern( filter, "*.bz2" ); - gtk_file_filter_add_pattern( filter, "*.BZ2" ); -#endif -} - -#endif - -static void -add_filter_disk_files( GtkFileFilter *filter ) -{ - gtk_file_filter_add_pattern( filter, "*.d40" ); - gtk_file_filter_add_pattern( filter, "*.d80" ); - gtk_file_filter_add_pattern( filter, "*.dsk" ); - gtk_file_filter_add_pattern( filter, "*.fdi" ); - gtk_file_filter_add_pattern( filter, "*.img" ); - gtk_file_filter_add_pattern( filter, "*.mgt" ); - gtk_file_filter_add_pattern( filter, "*.opd" ); - gtk_file_filter_add_pattern( filter, "*.opu" ); - gtk_file_filter_add_pattern( filter, "*.sad" ); - gtk_file_filter_add_pattern( filter, "*.scl" ); - gtk_file_filter_add_pattern( filter, "*.td0" ); - gtk_file_filter_add_pattern( filter, "*.trd" ); - gtk_file_filter_add_pattern( filter, "*.udi" ); - - gtk_file_filter_add_pattern( filter, "*.D40" ); - gtk_file_filter_add_pattern( filter, "*.D80" ); - gtk_file_filter_add_pattern( filter, "*.DSK" ); - gtk_file_filter_add_pattern( filter, "*.FDI" ); - gtk_file_filter_add_pattern( filter, "*.IMG" ); - gtk_file_filter_add_pattern( filter, "*.MGT" ); - gtk_file_filter_add_pattern( filter, "*.OPD" ); - gtk_file_filter_add_pattern( filter, "*.OPU" ); - gtk_file_filter_add_pattern( filter, "*.SAD" ); - gtk_file_filter_add_pattern( filter, "*.SCL" ); - gtk_file_filter_add_pattern( filter, "*.TD0" ); - gtk_file_filter_add_pattern( filter, "*.TRD" ); - gtk_file_filter_add_pattern( filter, "*.UDI" ); -} - -static void -add_filter_dock_files( GtkFileFilter *filter ) -{ - gtk_file_filter_add_pattern( filter, "*.dck" ); - gtk_file_filter_add_pattern( filter, "*.rom" ); - - gtk_file_filter_add_pattern( filter, "*.DCK" ); - gtk_file_filter_add_pattern( filter, "*.ROM" ); -} - -static void -add_filter_harddisk_files( GtkFileFilter *filter ) -{ - gtk_file_filter_add_pattern( filter, "*.hdf" ); - - gtk_file_filter_add_pattern( filter, "*.HDF" ); -} - -static void -add_filter_microdrive_files( GtkFileFilter *filter ) -{ - gtk_file_filter_add_pattern( filter, "*.mdr" ); - - gtk_file_filter_add_pattern( filter, "*.MDR" ); -} - -static void -add_filter_movie_files( GtkFileFilter *filter ) -{ - gtk_file_filter_add_pattern( filter, "*.fmf" ); - - gtk_file_filter_add_pattern( filter, "*.FMF" ); -} - -static void -add_filter_recording_files( GtkFileFilter *filter ) -{ - gtk_file_filter_add_pattern( filter, "*.rzx" ); - - gtk_file_filter_add_pattern( filter, "*.RZX" ); -} - -static void -add_filter_snapshot_files( GtkFileFilter *filter ) -{ - gtk_file_filter_add_pattern( filter, "*.mgtsnp" ); - gtk_file_filter_add_pattern( filter, "*.slt" ); - gtk_file_filter_add_pattern( filter, "*.sna" ); - gtk_file_filter_add_pattern( filter, "*.snapshot" ); - gtk_file_filter_add_pattern( filter, "*.snp" ); - gtk_file_filter_add_pattern( filter, "*.sp" ); - gtk_file_filter_add_pattern( filter, "*.szx" ); - gtk_file_filter_add_pattern( filter, "*.z80" ); - gtk_file_filter_add_pattern( filter, "*.zx-state" ); - - gtk_file_filter_add_pattern( filter, "*.MGTSNP" ); - gtk_file_filter_add_pattern( filter, "*.SLT" ); - gtk_file_filter_add_pattern( filter, "*.SNA" ); - gtk_file_filter_add_pattern( filter, "*.SNAPSHOT" ); - gtk_file_filter_add_pattern( filter, "*.SNP" ); - gtk_file_filter_add_pattern( filter, "*.SP" ); - gtk_file_filter_add_pattern( filter, "*.SZX" ); - gtk_file_filter_add_pattern( filter, "*.Z80" ); - gtk_file_filter_add_pattern( filter, "*.ZX-STATE" ); -} - -static void -add_filter_tape_files( GtkFileFilter *filter ) -{ - gtk_file_filter_add_pattern( filter, "*.csw" ); - gtk_file_filter_add_pattern( filter, "*.ltp" ); - gtk_file_filter_add_pattern( filter, "*.pzx" ); - gtk_file_filter_add_pattern( filter, "*.raw" ); - gtk_file_filter_add_pattern( filter, "*.spc" ); - gtk_file_filter_add_pattern( filter, "*.sta" ); - gtk_file_filter_add_pattern( filter, "*.tzx" ); - gtk_file_filter_add_pattern( filter, "*.tap" ); - gtk_file_filter_add_pattern( filter, "*.wav" ); - - gtk_file_filter_add_pattern( filter, "*.CSW" ); - gtk_file_filter_add_pattern( filter, "*.LTP" ); - gtk_file_filter_add_pattern( filter, "*.PZX" ); - gtk_file_filter_add_pattern( filter, "*.RAW" ); - gtk_file_filter_add_pattern( filter, "*.SPC" ); - gtk_file_filter_add_pattern( filter, "*.STA" ); - gtk_file_filter_add_pattern( filter, "*.TZX" ); - gtk_file_filter_add_pattern( filter, "*.TAP" ); - gtk_file_filter_add_pattern( filter, "*.WAV" ); -} diff --git a/fuse/ui/gtk/gtkcompat.c b/fuse/ui/gtk/gtkcompat.c deleted file mode 100644 index 3fbf79a..0000000 --- a/fuse/ui/gtk/gtkcompat.c +++ /dev/null @@ -1,56 +0,0 @@ -/* gtkcompat.c: various compatibility bits between GTK versions - Copyright (c) 2012-2014 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include - -#include "gtkcompat.h" - -#if !GTK_CHECK_VERSION( 3, 0, 0 ) - -GtkWidget * -gtk_box_new( GtkOrientation orientation, gint spacing ) -{ - return ( orientation == GTK_ORIENTATION_HORIZONTAL )? - gtk_hbox_new( FALSE, spacing ) : - gtk_vbox_new( FALSE, spacing ); -} - -GtkWidget * -gtk_separator_new( GtkOrientation orientation ) -{ - return ( orientation == GTK_ORIENTATION_HORIZONTAL )? - gtk_hseparator_new() : - gtk_vseparator_new(); -} - -GtkWidget * -gtk_scrollbar_new( GtkOrientation orientation, GtkAdjustment *adjustment ) -{ - return ( orientation == GTK_ORIENTATION_HORIZONTAL )? - gtk_hscrollbar_new( adjustment ) : - gtk_vscrollbar_new( adjustment ); -} - -#endif /* #if !GTK_CHECK_VERSION( 3, 0, 0 ) */ diff --git a/fuse/ui/gtk/gtkcompat.h b/fuse/ui/gtk/gtkcompat.h deleted file mode 100644 index d2efe0a..0000000 --- a/fuse/ui/gtk/gtkcompat.h +++ /dev/null @@ -1,198 +0,0 @@ -/* gtkcompat.h: various compatibility bits between GTK versions - Copyright (c) 2012 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#ifndef FUSE_GTKCOMPAT_H -#define FUSE_GTKCOMPAT_H - -#include -#include -#include - -#ifndef GTK_TYPE_COMBO_BOX_TEXT - -#define GTK_COMBO_BOX_TEXT( X ) GTK_COMBO_BOX( X ) -#define gtk_combo_box_text_new() gtk_combo_box_new_text() -#define gtk_combo_box_text_append_text( X, Y ) gtk_combo_box_append_text( X, Y ) - -#endif /* #ifndef GTK_TYPE_COMBO_BOX_TEXT */ - - -#if !GTK_CHECK_VERSION( 3, 0, 0 ) - -GtkWidget * -gtk_box_new( GtkOrientation orientation, gint spacing ); - -GtkWidget * -gtk_separator_new( GtkOrientation orientation ); - -GtkWidget * -gtk_scrollbar_new( GtkOrientation orientation, GtkAdjustment *adjustment ); - -#define gtk_widget_override_font( X, Y ) gtk_widget_modify_font( X, Y ) - -#endif - - -#if !GTK_CHECK_VERSION( 2, 22, 0 ) - -#define GDK_KEY_VoidSymbol GDK_VoidSymbol -#define GDK_KEY_Tab GDK_Tab -#define GDK_KEY_Return GDK_Return -#define GDK_KEY_Escape GDK_Escape -#define GDK_KEY_space GDK_space -#define GDK_KEY_quotedbl GDK_quotedbl -#define GDK_KEY_exclam GDK_exclam -#define GDK_KEY_numbersign GDK_numbersign -#define GDK_KEY_dollar GDK_dollar -#define GDK_KEY_percent GDK_percent -#define GDK_KEY_ampersand GDK_ampersand -#define GDK_KEY_apostrophe GDK_apostrophe -#define GDK_KEY_parenleft GDK_parenleft -#define GDK_KEY_parenright GDK_parenright -#define GDK_KEY_asterisk GDK_asterisk -#define GDK_KEY_plus GDK_plus -#define GDK_KEY_comma GDK_comma -#define GDK_KEY_minus GDK_minus -#define GDK_KEY_period GDK_period -#define GDK_KEY_slash GDK_slash -#define GDK_KEY_0 GDK_0 -#define GDK_KEY_1 GDK_1 -#define GDK_KEY_2 GDK_2 -#define GDK_KEY_3 GDK_3 -#define GDK_KEY_4 GDK_4 -#define GDK_KEY_5 GDK_5 -#define GDK_KEY_6 GDK_6 -#define GDK_KEY_7 GDK_7 -#define GDK_KEY_8 GDK_8 -#define GDK_KEY_9 GDK_9 -#define GDK_KEY_colon GDK_colon -#define GDK_KEY_semicolon GDK_semicolon -#define GDK_KEY_less GDK_less -#define GDK_KEY_equal GDK_equal -#define GDK_KEY_greater GDK_greater -#define GDK_KEY_question GDK_question -#define GDK_KEY_at GDK_at -#define GDK_KEY_A GDK_A -#define GDK_KEY_B GDK_B -#define GDK_KEY_C GDK_C -#define GDK_KEY_D GDK_D -#define GDK_KEY_E GDK_E -#define GDK_KEY_F GDK_F -#define GDK_KEY_G GDK_G -#define GDK_KEY_H GDK_H -#define GDK_KEY_I GDK_I -#define GDK_KEY_J GDK_J -#define GDK_KEY_K GDK_K -#define GDK_KEY_L GDK_L -#define GDK_KEY_M GDK_M -#define GDK_KEY_N GDK_N -#define GDK_KEY_O GDK_O -#define GDK_KEY_P GDK_P -#define GDK_KEY_Q GDK_Q -#define GDK_KEY_R GDK_R -#define GDK_KEY_S GDK_S -#define GDK_KEY_T GDK_T -#define GDK_KEY_U GDK_U -#define GDK_KEY_V GDK_V -#define GDK_KEY_W GDK_W -#define GDK_KEY_X GDK_X -#define GDK_KEY_Y GDK_Y -#define GDK_KEY_Z GDK_Z -#define GDK_KEY_bracketleft GDK_bracketleft -#define GDK_KEY_backslash GDK_backslash -#define GDK_KEY_bracketright GDK_bracketright -#define GDK_KEY_asciicircum GDK_asciicircum -#define GDK_KEY_underscore GDK_underscore -#define GDK_KEY_dead_circumflex GDK_dead_circumflex -#define GDK_KEY_a GDK_a -#define GDK_KEY_b GDK_b -#define GDK_KEY_c GDK_c -#define GDK_KEY_d GDK_d -#define GDK_KEY_e GDK_e -#define GDK_KEY_f GDK_f -#define GDK_KEY_g GDK_g -#define GDK_KEY_h GDK_h -#define GDK_KEY_i GDK_i -#define GDK_KEY_j GDK_j -#define GDK_KEY_k GDK_k -#define GDK_KEY_l GDK_l -#define GDK_KEY_m GDK_m -#define GDK_KEY_n GDK_n -#define GDK_KEY_o GDK_o -#define GDK_KEY_p GDK_p -#define GDK_KEY_q GDK_q -#define GDK_KEY_r GDK_r -#define GDK_KEY_s GDK_s -#define GDK_KEY_t GDK_t -#define GDK_KEY_u GDK_u -#define GDK_KEY_v GDK_v -#define GDK_KEY_w GDK_w -#define GDK_KEY_x GDK_x -#define GDK_KEY_y GDK_y -#define GDK_KEY_z GDK_z -#define GDK_KEY_braceleft GDK_braceleft -#define GDK_KEY_bar GDK_bar -#define GDK_KEY_braceright GDK_braceright -#define GDK_KEY_asciitilde GDK_asciitilde -#define GDK_KEY_BackSpace GDK_BackSpace -#define GDK_KEY_KP_Enter GDK_KP_Enter -#define GDK_KEY_Up GDK_Up -#define GDK_KEY_Down GDK_Down -#define GDK_KEY_Left GDK_Left -#define GDK_KEY_Right GDK_Right -#define GDK_KEY_Insert GDK_Insert -#define GDK_KEY_Delete GDK_Delete -#define GDK_KEY_Home GDK_Home -#define GDK_KEY_End GDK_End -#define GDK_KEY_Page_Up GDK_Page_Up -#define GDK_KEY_Page_Down GDK_Page_Down -#define GDK_KEY_Caps_Lock GDK_Caps_Lock -#define GDK_KEY_F1 GDK_F1 -#define GDK_KEY_F2 GDK_F2 -#define GDK_KEY_F3 GDK_F3 -#define GDK_KEY_F4 GDK_F4 -#define GDK_KEY_F5 GDK_F5 -#define GDK_KEY_F6 GDK_F6 -#define GDK_KEY_F7 GDK_F7 -#define GDK_KEY_F8 GDK_F8 -#define GDK_KEY_F9 GDK_F9 -#define GDK_KEY_F10 GDK_F10 -#define GDK_KEY_F11 GDK_F11 -#define GDK_KEY_F12 GDK_F12 -#define GDK_KEY_Shift_L GDK_Shift_L -#define GDK_KEY_Shift_R GDK_Shift_R -#define GDK_KEY_Control_L GDK_Control_L -#define GDK_KEY_Control_R GDK_Control_R -#define GDK_KEY_Alt_L GDK_Alt_L -#define GDK_KEY_Alt_R GDK_Alt_R -#define GDK_KEY_Meta_L GDK_Meta_L -#define GDK_KEY_Meta_R GDK_Meta_R -#define GDK_KEY_Super_L GDK_Super_L -#define GDK_KEY_Super_R GDK_Super_R -#define GDK_KEY_Hyper_L GDK_Hyper_L -#define GDK_KEY_Hyper_R GDK_Hyper_R -#define GDK_KEY_Mode_switch GDK_Mode_switch - -#endif /* #if !GTK_CHECK_VERSION( 2, 22, 0 ) */ - -#endif /* #ifndef FUSE_GTKCOMPAT_H */ diff --git a/fuse/ui/gtk/gtkdisplay.c b/fuse/ui/gtk/gtkdisplay.c deleted file mode 100644 index 61b0807..0000000 --- a/fuse/ui/gtk/gtkdisplay.c +++ /dev/null @@ -1,687 +0,0 @@ -/* gtkdisplay.c: GTK routines for dealing with the Speccy screen - Copyright (c) 2000-2005 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include - -#include - -#ifdef GDK_WINDOWING_WAYLAND -#include -#endif - -#include "display.h" -#include "fuse.h" -#include "gtkinternals.h" -#include "screenshot.h" -#include "ui/ui.h" -#include "ui/uidisplay.h" -#include "ui/scaler/scaler.h" -#include "settings.h" - -/* The biggest size screen (in units of DISPLAY_ASPECT_WIDTH x - DISPLAY_SCREEN_HEIGHT ie a Timex screen is size 2) we will be - creating via the scalers */ -#define MAX_SCALE 4 - -/* The size of a 1x1 image in units of - DISPLAY_ASPECT WIDTH x DISPLAY_SCREEN_HEIGHT */ -int image_scale; - -/* The height and width of a 1x1 image in pixels */ -int image_width, image_height; - -/* A copy of every pixel on the screen, replaceable by plotting directly into - rgb_image below */ -libspectrum_word - gtkdisplay_image[ 2 * DISPLAY_SCREEN_HEIGHT ][ DISPLAY_SCREEN_WIDTH ]; -ptrdiff_t gtkdisplay_pitch = DISPLAY_SCREEN_WIDTH * sizeof( libspectrum_word ); - -/* An RGB image of the Spectrum screen; slightly bigger than the real - screen to handle the smoothing filters which read around each pixel */ -static guchar rgb_image[ 4 * 2 * ( DISPLAY_SCREEN_HEIGHT + 4 ) * - ( DISPLAY_SCREEN_WIDTH + 3 ) ]; -static const gint rgb_pitch = ( DISPLAY_SCREEN_WIDTH + 3 ) * 4; - -/* The scaled image */ -static guchar scaled_image[ MAX_SCALE * DISPLAY_SCREEN_HEIGHT * - MAX_SCALE * DISPLAY_SCREEN_WIDTH * 2 ]; -static const ptrdiff_t scaled_pitch = MAX_SCALE * DISPLAY_SCREEN_WIDTH * 2; - -/* The colour palette */ -static const guchar rgb_colours[16][3] = { - - { 0, 0, 0 }, - { 0, 0, 192 }, - { 192, 0, 0 }, - { 192, 0, 192 }, - { 0, 192, 0 }, - { 0, 192, 192 }, - { 192, 192, 0 }, - { 192, 192, 192 }, - { 0, 0, 0 }, - { 0, 0, 255 }, - { 255, 0, 0 }, - { 255, 0, 255 }, - { 0, 255, 0 }, - { 0, 255, 255 }, - { 255, 255, 0 }, - { 255, 255, 255 }, - -}; - -/* And the colours (and black and white 'colours') in 32-bit format */ -libspectrum_dword gtkdisplay_colours[16]; -static libspectrum_dword bw_colours[16]; - -/* Colour format for the back buffer in endianess-order */ -typedef enum { - FORMAT_x8r8g8b8, /* Cairo (GTK3) */ - FORMAT_x8b8g8r8 /* GdkRGB (GTK2) */ -} colour_format_t; - - -#if GTK_CHECK_VERSION( 3, 0, 0 ) - -static int display_updated = 0; - -static cairo_surface_t *surface = NULL; - -#endif /* #if GTK_CHECK_VERSION( 3, 0, 0 ) */ - -/* The current size of the window (in units of DISPLAY_SCREEN_*) */ -static int gtkdisplay_current_size=1; - -/* Extra height used for menu and status bars */ -static int extra_height = 0; - -static int init_colours( colour_format_t format ); -static void gtkdisplay_area(int x, int y, int width, int height); -static void register_scalers( int force_scaler ); -static void gtkdisplay_load_gfx_mode( void ); - -/* Callbacks */ - -#if !GTK_CHECK_VERSION( 3, 0, 0 ) -static gint gtkdisplay_expose(GtkWidget *widget, GdkEvent *event, - gpointer data); -#else -static gboolean gtkdisplay_draw( GtkWidget *widget, cairo_t *cr, - gpointer user_data ); -#endif /* #if !GTK_CHECK_VERSION( 3, 0, 0 ) */ - -static gint drawing_area_resize_callback( GtkWidget *widget, GdkEvent *event, - gpointer data ); - -static int -init_colours( colour_format_t format ) -{ - size_t i; - - for( i = 0; i < 16; i++ ) { - - - guchar red, green, blue, grey; - - red = rgb_colours[i][0]; - green = rgb_colours[i][1]; - blue = rgb_colours[i][2]; - - /* Addition of 0.5 is to avoid rounding errors */ - grey = ( 0.299 * red + 0.587 * green + 0.114 * blue ) + 0.5; - -#ifdef WORDS_BIGENDIAN - - switch( format ) { - case FORMAT_x8b8g8r8: - gtkdisplay_colours[i] = red << 24 | green << 16 | blue << 8; - break; - case FORMAT_x8r8g8b8: - gtkdisplay_colours[i] = blue << 24 | green << 16 | red << 8; - break; - } - - bw_colours[i] = grey << 24 | grey << 16 | grey << 8; - -#else /* #ifdef WORDS_BIGENDIAN */ - - switch( format ) { - case FORMAT_x8b8g8r8: - gtkdisplay_colours[i] = red | green << 8 | blue << 16; - break; - case FORMAT_x8r8g8b8: - gtkdisplay_colours[i] = blue | green << 8 | red << 16; - break; - } - - bw_colours[i] = grey | grey << 8 | grey << 16; - -#endif /* #ifdef WORDS_BIGENDIAN */ - - } - - return 0; -} - -int -uidisplay_init( int width, int height ) -{ - int x, y, error; - libspectrum_dword black; - const char *machine_name; - colour_format_t colour_format; - -#if !GTK_CHECK_VERSION( 3, 0, 0 ) - - g_signal_connect( G_OBJECT( gtkui_drawing_area ), "expose_event", - G_CALLBACK( gtkdisplay_expose ), NULL ); - - colour_format = FORMAT_x8b8g8r8; - - g_signal_connect( G_OBJECT( gtkui_drawing_area ), "configure_event", - G_CALLBACK( drawing_area_resize_callback ), NULL ); - -#else - - g_signal_connect( G_OBJECT( gtkui_drawing_area ), "draw", - G_CALLBACK( gtkdisplay_draw ), NULL ); - - colour_format = FORMAT_x8r8g8b8; - - g_signal_connect( G_OBJECT( gtkui_window ), "configure_event", - G_CALLBACK( drawing_area_resize_callback ), NULL ); - -#endif /* #if !GTK_CHECK_VERSION( 3, 0, 0 ) */ - - error = init_colours( colour_format ); if( error ) return error; - - black = settings_current.bw_tv ? bw_colours[0] : gtkdisplay_colours[0]; - - for( y = 0; y < DISPLAY_SCREEN_HEIGHT + 4; y++ ) - for( x = 0; x < DISPLAY_SCREEN_WIDTH + 3; x++ ) - *(libspectrum_dword*)( rgb_image + y * rgb_pitch + 4 * x ) = black; - - image_width = width; image_height = height; - image_scale = width / DISPLAY_ASPECT_WIDTH; - - register_scalers( 0 ); - - display_refresh_all(); - - if ( scaler_select_scaler( current_scaler ) ) - scaler_select_scaler( SCALER_NORMAL ); - - gtkdisplay_load_gfx_mode(); - - machine_name = libspectrum_machine_name( machine_current->machine ); - gtkstatusbar_update_machine( machine_name ); - - display_ui_initialised = 1; - - return 0; -} - -/* Ensure that an appropriate Cairo surface exists */ -static void -ensure_appropriate_surface( void ) -{ -#if GTK_CHECK_VERSION( 3, 0, 0 ) - - /* Create a bigger surface for the new display size */ - float scale = (float)gtkdisplay_current_size / image_scale; - if( surface ) cairo_surface_destroy( surface ); - - surface = - cairo_image_surface_create_for_data( scaled_image, - CAIRO_FORMAT_RGB24, - scale * image_width, - scale * image_height, - scaled_pitch ); - -#endif /* #if GTK_CHECK_VERSION( 3, 0, 0 ) */ -} - -static int -drawing_area_resize( int width, int height, int force_scaler ) -{ - int size; - - size = width / DISPLAY_ASPECT_WIDTH; - if( size > height / DISPLAY_SCREEN_HEIGHT ) - size = height / DISPLAY_SCREEN_HEIGHT; - - /* If we're the same size as before, no need to do anything else */ - if( size == gtkdisplay_current_size ) return 0; - - gtkdisplay_current_size = size; - - register_scalers( force_scaler ); - - memset( scaled_image, 0, sizeof( scaled_image ) ); - - ensure_appropriate_surface(); - - display_refresh_all(); - - return 0; -} - -static void -register_scalers( int force_scaler ) -{ - scaler_type scaler; - float drawing_area_scale, scaling_factor; - - scaler_register_clear(); - - if( machine_current->timex ) { - scaler_register( SCALER_HALF ); - scaler_register( SCALER_HALFSKIP ); - scaler_register( SCALER_TIMEXTV ); - scaler_register( SCALER_TIMEX1_5X ); - scaler_register( SCALER_TIMEX2X ); - } else { - scaler_register( SCALER_DOUBLESIZE ); - scaler_register( SCALER_TRIPLESIZE ); - scaler_register( SCALER_QUADSIZE ); - scaler_register( SCALER_TV2X ); - scaler_register( SCALER_TV3X ); - scaler_register( SCALER_TV4X ); - scaler_register( SCALER_PALTV2X ); - scaler_register( SCALER_PALTV3X ); - scaler_register( SCALER_PALTV4X ); - scaler_register( SCALER_HQ2X ); - scaler_register( SCALER_HQ3X ); - scaler_register( SCALER_HQ4X ); - scaler_register( SCALER_ADVMAME2X ); - scaler_register( SCALER_ADVMAME3X ); - scaler_register( SCALER_2XSAI ); - scaler_register( SCALER_SUPER2XSAI ); - scaler_register( SCALER_SUPEREAGLE ); - scaler_register( SCALER_DOTMATRIX ); - } - scaler_register( SCALER_NORMAL ); - scaler_register( SCALER_PALTV ); - - scaler = - scaler_is_supported( current_scaler ) ? current_scaler : SCALER_NORMAL; - - drawing_area_scale = (float)gtkdisplay_current_size / image_scale; - scaling_factor = scaler_get_scaling_factor( current_scaler ); - - /* Override scaler if the image doesn't fit well in the drawing area */ - if( force_scaler && drawing_area_scale != scaling_factor ) { - - switch( gtkdisplay_current_size ) { - case 1: scaler = machine_current->timex ? SCALER_HALF : SCALER_NORMAL; - break; - case 2: scaler = machine_current->timex ? SCALER_NORMAL : SCALER_DOUBLESIZE; - break; - case 3: scaler = machine_current->timex ? SCALER_TIMEX1_5X : - SCALER_TRIPLESIZE; - break; - case 4: scaler = machine_current->timex ? SCALER_TIMEX2X : - SCALER_QUADSIZE; - break; - } - } - - scaler_select_scaler( scaler ); -} - -void -uidisplay_frame_end( void ) -{ -#if GTK_CHECK_VERSION( 3, 0, 0 ) - if( display_updated ) { - gdk_window_process_updates( gtk_widget_get_window( gtkui_drawing_area ), - FALSE ); - display_updated = 0; - } -#endif /* #if GTK_CHECK_VERSION( 3, 0, 0 ) */ - - return; -} - -void -uidisplay_area( int x, int y, int w, int h ) -{ - float scale = (float)gtkdisplay_current_size / image_scale; - int scaled_x, scaled_y, i, yy; - libspectrum_dword *palette; - - /* Extend the dirty region by 1 pixel for scalers - that "smear" the screen, e.g. 2xSAI */ - if( scaler_flags & SCALER_FLAGS_EXPAND ) - scaler_expander( &x, &y, &w, &h, image_width, image_height ); - - scaled_x = scale * x; scaled_y = scale * y; - - palette = settings_current.bw_tv ? bw_colours : gtkdisplay_colours; - - /* Create the RGB image */ - for( yy = y; yy < y + h; yy++ ) { - - libspectrum_dword *rgb; libspectrum_word *display; - - rgb = (libspectrum_dword*)( rgb_image + ( yy + 2 ) * rgb_pitch ); - rgb += x + 1; - - display = >kdisplay_image[yy][x]; - - for( i = 0; i < w; i++, rgb++, display++ ) *rgb = palette[ *display ]; - } - - /* Create scaled image */ - scaler_proc32( &rgb_image[ ( y + 2 ) * rgb_pitch + 4 * ( x + 1 ) ], - rgb_pitch, - &scaled_image[ scaled_y * scaled_pitch + 4 * scaled_x ], - scaled_pitch, w, h ); - - w *= scale; h *= scale; - - /* Blit to the real screen */ - gtkdisplay_area( scaled_x, scaled_y, w, h ); -} - -static void gtkdisplay_area(int x, int y, int width, int height) -{ -#if !GTK_CHECK_VERSION( 3, 0, 0 ) - - gdk_draw_rgb_32_image( gtkui_drawing_area->window, - gtkui_drawing_area->style->fg_gc[GTK_STATE_NORMAL], - x, y, width, height, GDK_RGB_DITHER_NONE, - &scaled_image[ y * scaled_pitch + 4 * x ], - scaled_pitch ); - -#else - display_updated = 1; - - gtk_widget_queue_draw_area( gtkui_drawing_area, x, y, width, height ); - -#endif /* #if !GTK_CHECK_VERSION( 3, 0, 0 ) */ -} - -int -uidisplay_hotswap_gfx_mode( void ) -{ - fuse_emulation_pause(); - - /* Setup the new GFX mode */ - gtkdisplay_load_gfx_mode(); - - fuse_emulation_unpause(); - - return 0; -} - -int -uidisplay_end( void ) -{ - return 0; -} - -/* Set one pixel in the display */ -void -uidisplay_putpixel( int x, int y, int colour ) -{ - if( machine_current->timex ) { - x <<= 1; y <<= 1; - gtkdisplay_image[y ][x ] = colour; - gtkdisplay_image[y ][x+1] = colour; - gtkdisplay_image[y+1][x ] = colour; - gtkdisplay_image[y+1][x+1] = colour; - } else { - gtkdisplay_image[y][x] = colour; - } -} - -/* Print the 8 pixels in `data' using ink colour `ink' and paper - colour `paper' to the screen at ( (8*x) , y ) */ -void -uidisplay_plot8( int x, int y, libspectrum_byte data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - x <<= 3; - - if( machine_current->timex ) { - int i; - - x <<= 1; y <<= 1; - for( i=0; i<2; i++,y++ ) { - gtkdisplay_image[y][x+ 0] = ( data & 0x80 ) ? ink : paper; - gtkdisplay_image[y][x+ 1] = ( data & 0x80 ) ? ink : paper; - gtkdisplay_image[y][x+ 2] = ( data & 0x40 ) ? ink : paper; - gtkdisplay_image[y][x+ 3] = ( data & 0x40 ) ? ink : paper; - gtkdisplay_image[y][x+ 4] = ( data & 0x20 ) ? ink : paper; - gtkdisplay_image[y][x+ 5] = ( data & 0x20 ) ? ink : paper; - gtkdisplay_image[y][x+ 6] = ( data & 0x10 ) ? ink : paper; - gtkdisplay_image[y][x+ 7] = ( data & 0x10 ) ? ink : paper; - gtkdisplay_image[y][x+ 8] = ( data & 0x08 ) ? ink : paper; - gtkdisplay_image[y][x+ 9] = ( data & 0x08 ) ? ink : paper; - gtkdisplay_image[y][x+10] = ( data & 0x04 ) ? ink : paper; - gtkdisplay_image[y][x+11] = ( data & 0x04 ) ? ink : paper; - gtkdisplay_image[y][x+12] = ( data & 0x02 ) ? ink : paper; - gtkdisplay_image[y][x+13] = ( data & 0x02 ) ? ink : paper; - gtkdisplay_image[y][x+14] = ( data & 0x01 ) ? ink : paper; - gtkdisplay_image[y][x+15] = ( data & 0x01 ) ? ink : paper; - } - } else { - gtkdisplay_image[y][x+ 0] = ( data & 0x80 ) ? ink : paper; - gtkdisplay_image[y][x+ 1] = ( data & 0x40 ) ? ink : paper; - gtkdisplay_image[y][x+ 2] = ( data & 0x20 ) ? ink : paper; - gtkdisplay_image[y][x+ 3] = ( data & 0x10 ) ? ink : paper; - gtkdisplay_image[y][x+ 4] = ( data & 0x08 ) ? ink : paper; - gtkdisplay_image[y][x+ 5] = ( data & 0x04 ) ? ink : paper; - gtkdisplay_image[y][x+ 6] = ( data & 0x02 ) ? ink : paper; - gtkdisplay_image[y][x+ 7] = ( data & 0x01 ) ? ink : paper; - } -} - -/* Print the 16 pixels in `data' using ink colour `ink' and paper - colour `paper' to the screen at ( (16*x) , y ) */ -void -uidisplay_plot16( int x, int y, libspectrum_word data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - int i; - x <<= 4; y <<= 1; - - for( i=0; i<2; i++,y++ ) { - gtkdisplay_image[y][x+ 0] = ( data & 0x8000 ) ? ink : paper; - gtkdisplay_image[y][x+ 1] = ( data & 0x4000 ) ? ink : paper; - gtkdisplay_image[y][x+ 2] = ( data & 0x2000 ) ? ink : paper; - gtkdisplay_image[y][x+ 3] = ( data & 0x1000 ) ? ink : paper; - gtkdisplay_image[y][x+ 4] = ( data & 0x0800 ) ? ink : paper; - gtkdisplay_image[y][x+ 5] = ( data & 0x0400 ) ? ink : paper; - gtkdisplay_image[y][x+ 6] = ( data & 0x0200 ) ? ink : paper; - gtkdisplay_image[y][x+ 7] = ( data & 0x0100 ) ? ink : paper; - gtkdisplay_image[y][x+ 8] = ( data & 0x0080 ) ? ink : paper; - gtkdisplay_image[y][x+ 9] = ( data & 0x0040 ) ? ink : paper; - gtkdisplay_image[y][x+10] = ( data & 0x0020 ) ? ink : paper; - gtkdisplay_image[y][x+11] = ( data & 0x0010 ) ? ink : paper; - gtkdisplay_image[y][x+12] = ( data & 0x0008 ) ? ink : paper; - gtkdisplay_image[y][x+13] = ( data & 0x0004 ) ? ink : paper; - gtkdisplay_image[y][x+14] = ( data & 0x0002 ) ? ink : paper; - gtkdisplay_image[y][x+15] = ( data & 0x0001 ) ? ink : paper; - } -} - -/* Callbacks */ - -#if !GTK_CHECK_VERSION( 3, 0, 0 ) - -/* Called by gtkui_drawing_area on "expose_event" */ -static gint -gtkdisplay_expose( GtkWidget *widget GCC_UNUSED, GdkEvent *event, - gpointer data GCC_UNUSED ) -{ - gtkdisplay_area(event->expose.area.x, event->expose.area.y, - event->expose.area.width, event->expose.area.height); - return TRUE; -} - -/* Called by gtkui_drawing_area on "configure_event". - On GTK 2 the drawing_area determines the size of the window */ -static gint -drawing_area_resize_callback( GtkWidget *widget GCC_UNUSED, GdkEvent *event, - gpointer data GCC_UNUSED ) -{ - drawing_area_resize( event->configure.width, event->configure.height, 1 ); - - return TRUE; -} - -#else /* #if !GTK_CHECK_VERSION( 3, 0, 0 ) */ - -/* Called by gtkui_drawing_area on "draw" event */ -static gboolean -gtkdisplay_draw( GtkWidget *widget, cairo_t *cr, gpointer user_data ) -{ - /* Create a new surface for this gfx mode */ - if( !surface ) ensure_appropriate_surface(); - - /* Repaint the drawing area */ - cairo_set_source_surface( cr, surface, 0, 0 ); - cairo_set_operator( cr, CAIRO_OPERATOR_SOURCE ); - cairo_paint( cr ); - - return FALSE; -} - -/* Called by gtkui_window on "configure_event". - On GTK 3 the window determines the size of the drawing area */ -static gint -drawing_area_resize_callback( GtkWidget *widget GCC_UNUSED, GdkEvent *event, - gpointer data GCC_UNUSED ) -{ - drawing_area_resize( event->configure.width, - event->configure.height - extra_height, 1 ); - - return FALSE; -} - -#endif /* #if !GTK_CHECK_VERSION( 3, 0, 0 ) */ - -void -gtkdisplay_update_geometry( void ) -{ - GdkGeometry geometry; - GdkWindowHints hints; - GtkWidget *geometry_widget; - float scale; - - if( !scalers_registered ) return; - - scale = scaler_get_scaling_factor( current_scaler ); - - hints = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | - GDK_HINT_BASE_SIZE | GDK_HINT_RESIZE_INC; - -#if GTK_CHECK_VERSION( 3, 0, 0 ) - - /* Since GTK 3.20 it is intended that gtk_window_set_geometry_hints - don't set geometry of widgets. See [bugs:#344] */ - geometry_widget = NULL; - - /* Add extra space for menu bar */ - extra_height = gtkui_menubar_get_height(); - - /* Add extra space for status bar + padding */ - if( settings_current.statusbar ) { - extra_height += gtkstatusbar_get_height(); - } - -#ifdef GDK_WINDOWING_WAYLAND - /* We don't calculate the window size enough accurately on wayland - backend to force the window geometry (bug #367) */ - GdkDisplay *display = gdk_display_get_default(); - - if( GDK_IS_WAYLAND_DISPLAY( display ) ) { - hints &= ~GDK_HINT_RESIZE_INC; - } -#endif /* #ifdef GDK_WINDOWING_WAYLAND */ - -#else /* #if GTK_CHECK_VERSION( 3, 0, 0 ) */ - - geometry_widget = gtkui_drawing_area; - -#endif /* #if GTK_CHECK_VERSION( 3, 0, 0 ) */ - - - geometry.min_width = DISPLAY_ASPECT_WIDTH; - geometry.min_height = DISPLAY_SCREEN_HEIGHT + extra_height; - geometry.max_width = MAX_SCALE * DISPLAY_ASPECT_WIDTH; - geometry.max_height = MAX_SCALE * DISPLAY_SCREEN_HEIGHT + extra_height; - geometry.base_width = scale * image_width; - geometry.base_height = scale * image_height + extra_height; - geometry.width_inc = DISPLAY_ASPECT_WIDTH; - geometry.height_inc = DISPLAY_SCREEN_HEIGHT; - - if( settings_current.aspect_hint ) { - hints |= GDK_HINT_ASPECT; - - geometry.min_aspect = geometry.max_aspect = - ( scale * DISPLAY_ASPECT_WIDTH ) / - ( scale * DISPLAY_SCREEN_HEIGHT + extra_height ); - - if( !settings_current.strict_aspect_hint ) { - geometry.min_aspect *= 0.9; - geometry.max_aspect *= 1.125; - } - } - - gtk_window_set_geometry_hints( GTK_WINDOW( gtkui_window ), - geometry_widget, - &geometry, hints ); -} - -static void -gtkdisplay_load_gfx_mode( void ) -{ - float scale; - - scale = scaler_get_scaling_factor( current_scaler ); - - gtkdisplay_update_geometry(); - -#if !GTK_CHECK_VERSION( 3, 0, 0 ) - - /* This function should be innocuous when the main window is shown */ - gtk_window_set_default_size( GTK_WINDOW( gtkui_window ), - scale * image_width, - scale * image_height + extra_height ); - - drawing_area_resize( scale * image_width, scale * image_height, 0 ); - -#endif /* #if !GTK_CHECK_VERSION( 3, 0, 0 ) */ - - gtk_window_resize( GTK_WINDOW( gtkui_window ), scale * image_width, - scale * image_height + extra_height ); - - /* Redraw the entire screen... */ - display_refresh_all(); -} diff --git a/fuse/ui/gtk/gtkinternals.h b/fuse/ui/gtk/gtkinternals.h deleted file mode 100644 index f3e566c..0000000 --- a/fuse/ui/gtk/gtkinternals.h +++ /dev/null @@ -1,171 +0,0 @@ -/* gtkinternals.h: stuff internal to the GTK UI - Copyright (c) 2003-2015 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#ifndef FUSE_GTKINTERNALS_H -#define FUSE_GTKINTERNALS_H - -#include -#include - -/* - * Display routines (gtkdisplay.c) - */ - -/* The colour palette in use */ -extern libspectrum_dword gtkdisplay_colours[ 16 ]; - -void gtkdisplay_update_geometry( void ); - -/* - * Keyboard routines (gtkkeyboard.c) - */ - -int gtkkeyboard_keypress( GtkWidget *widget, GdkEvent *event, - gpointer data); -int gtkkeyboard_keyrelease( GtkWidget *widget, GdkEvent *event, - gpointer data); -int gtkkeyboard_release_all( GtkWidget *widget, GdkEvent *event, - gpointer data ); - -/* - * Mouse routines (gtkmouse.c) - */ - -void gtkmouse_init( void ); - -/* - * General user interface routines (gtkui.c) - */ - -extern GtkWidget *gtkui_window; -extern GtkWidget *gtkui_drawing_area; - -void gtkui_destroy_widget_and_quit( GtkWidget *widget, gpointer data ); - -int gtkui_confirm( const char *string ); - -int gtkui_picture( const char *filename, int border ); - -extern void gtkui_popup_menu(void); - -GtkAccelGroup* gtkstock_add_accel_group( GtkWidget *widget ); - -/* Set modifier=0 to use the first default accel key. - * Set modifier_alt=0 to use the second default accel key. - * For either, GDK_KEY_VoidSymbol means "no accel key". - */ -typedef struct gtkstock_button { - const gchar *label; - GCallback action; /* "clicked" func; data is actiondata. */ - gpointer actiondata; - GCallback destroy; /* "clicked" func; data is parent widget */ - guint shortcut; - GdkModifierType modifier; /* primary shortcut */ - guint shortcut_alt; - GdkModifierType modifier_alt; /* secondary shortcut */ - gint response_id; /* response id for dialog */ -} gtkstock_button; - -/* GTK1: create a simple button with the given label. - * "gtk-" prefixes are stripped and are used to select default accel keys. - * GTK2: chooses between stock and normal based on "gtk-" prefix. - * GTK3: GtkStock has been deprecated, we should not use "gtk-" prefix. - * - * If the target widget is a GtkDialog, then created buttons are put in its - * action area. - * - * If the label begins with "!", then g_signal_connect_swapped, rather than - * g_signal_connect, is used to connect the action function. - */ -GtkWidget* gtkstock_create_button( GtkWidget *widget, GtkAccelGroup *accel, - const gtkstock_button *btn ); -GtkAccelGroup* -gtkstock_create_buttons( GtkWidget *widget, GtkAccelGroup *accel, - const gtkstock_button *buttons, size_t count ); -GtkAccelGroup* gtkstock_create_ok_cancel( GtkWidget *widget, - GtkAccelGroup *accel, - /* for OK button -> */ GCallback action, - gpointer actiondata, - /* for both buttons -> */ GCallback destroy_ok, - GCallback destroy_cancel ); -GtkAccelGroup* gtkstock_create_close( GtkWidget *widget, GtkAccelGroup *accel, - GCallback destroy, - gboolean esconly ); - /* destroy==NULL => use DEFAULT_DESTROY */ - -#define DEFAULT_DESTROY ( G_CALLBACK( gtkui_destroy_widget_and_quit ) ) - -GtkWidget *gtkstock_dialog_new( const gchar *title, GCallback destroy ); - -int gtkui_get_monospaced_font( PangoFontDescription **font ); -void gtkui_free_font( PangoFontDescription *font ); - -int gtkui_menubar_get_height( void ); - -/* - * The menu data (menu_data.c) - */ - -extern GtkActionEntry gtkui_menu_data[]; -extern guint gtkui_menu_data_size; - -/* - * The icon pixmaps (pixmaps.c) - */ -extern const char *gtkpixmap_tape_inactive[]; -extern const char *gtkpixmap_tape_active[]; -extern const char *gtkpixmap_mdr_inactive[]; -extern const char *gtkpixmap_mdr_active[]; -extern const char *gtkpixmap_disk_inactive[]; -extern const char *gtkpixmap_disk_active[]; -extern const char *gtkpixmap_pause_inactive[]; -extern const char *gtkpixmap_pause_active[]; -extern const char *gtkpixmap_tape_marker[]; -extern const char *gtkpixmap_mouse_inactive[]; -extern const char *gtkpixmap_mouse_active[]; - -/* - * Statusbar routines (statusbar.c) - */ - - -int gtkstatusbar_create( GtkBox *parent ); -int gtkstatusbar_get_height( void ); -int gtkstatusbar_set_visibility( int visible ); -void gtkstatusbar_update_machine( const char *name ); - -/* - * Routines for list widgets - */ - -void gtkui_scroll_connect( GtkTreeView *list, GtkAdjustment *adj ); -void gtkui_list_set_cursor( GtkTreeView *list, int row ); -int gtkui_list_get_cursor( GtkTreeView *list ); - -/* - * Dialog box reset - */ - -void gtkui_pokefinder_clear( void ); - -#endif /* #ifndef FUSE_GTKINTERNALS_H */ diff --git a/fuse/ui/gtk/gtkjoystick.c b/fuse/ui/gtk/gtkjoystick.c deleted file mode 100644 index f2ce192..0000000 --- a/fuse/ui/gtk/gtkjoystick.c +++ /dev/null @@ -1,466 +0,0 @@ -/* gtkjoystick.c: Joystick emulation - Copyright (c) 2003-2015 Darren Salt, Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - - Darren: linux@youmustbejoking.demon.co.uk - -*/ - -#include - -#include -#include - -#include "compat.h" -#include "fuse.h" -#include "gtkcompat.h" -#include "gtkinternals.h" -#include "keyboard.h" -#include "peripherals/joystick.h" -#include "menu.h" -#include "settings.h" - -#if !defined USE_JOYSTICK || defined HAVE_JSW_H -/* Fake joystick, or override UI-specific handling */ -#include "../uijoystick.c" - -#else /* #if !defined USE_JOYSTICK || defined HAVE_JSW_H */ - -#include "../sdl/sdljoystick.c" - -#endif /* #if !defined USE_JOYSTICK || defined HAVE_JSW_H */ - -enum -{ - COL_TEXT = 0, - COL_KEY, - NUM_COLS -}; - -struct button_info { - int *setting; - char name[80]; - GtkWidget *label; - keyboard_key_name key; -}; - -struct joystick_info { - - int *type; - GtkWidget *radio[ JOYSTICK_TYPE_COUNT ]; - - struct button_info button[NUM_JOY_BUTTONS]; -}; - -typedef enum key_item_t { - ITEM = 0, - KEY_GROUP, - SUBITEM, -} key_item_t; - -typedef struct key_menu_t { - key_item_t item; - const gchar *text; - keyboard_key_name key; -} key_menu_t; - -static void setup_info( struct joystick_info *info, int callback_action ); -static void create_joystick_type_selector( struct joystick_info *info, - GtkBox *parent ); -static void -create_fire_button_selector( const char *title, struct button_info *info, - GtkBox *parent, GtkTreeModel *model ); -static void set_key_text( GtkWidget *label, keyboard_key_name key ); - -static void key_callback( GtkComboBox *widget, gpointer user_data ); -static void joystick_done( GtkButton *button, gpointer user_data ); - -static key_menu_t key_menu[] = { - - { ITEM, "Joystick Fire", KEYBOARD_JOYSTICK_FIRE }, - - { KEY_GROUP, "Numbers", KEYBOARD_NONE }, - { SUBITEM, "0", KEYBOARD_0 }, - { SUBITEM, "1", KEYBOARD_1 }, - { SUBITEM, "2", KEYBOARD_2 }, - { SUBITEM, "3", KEYBOARD_3 }, - { SUBITEM, "4", KEYBOARD_4 }, - { SUBITEM, "5", KEYBOARD_5 }, - { SUBITEM, "6", KEYBOARD_6 }, - { SUBITEM, "7", KEYBOARD_7 }, - { SUBITEM, "8", KEYBOARD_8 }, - { SUBITEM, "9", KEYBOARD_9 }, - - { KEY_GROUP, "A - M", KEYBOARD_NONE }, - { SUBITEM, "A", KEYBOARD_a }, - { SUBITEM, "B", KEYBOARD_b }, - { SUBITEM, "C", KEYBOARD_c }, - { SUBITEM, "D", KEYBOARD_d }, - { SUBITEM, "E", KEYBOARD_e }, - { SUBITEM, "F", KEYBOARD_f }, - { SUBITEM, "G", KEYBOARD_g }, - { SUBITEM, "H", KEYBOARD_h }, - { SUBITEM, "I", KEYBOARD_i }, - { SUBITEM, "J", KEYBOARD_j }, - { SUBITEM, "K", KEYBOARD_k }, - { SUBITEM, "L", KEYBOARD_l }, - { SUBITEM, "M", KEYBOARD_m }, - - { KEY_GROUP, "N - Z", KEYBOARD_NONE }, - { SUBITEM, "N", KEYBOARD_n }, - { SUBITEM, "O", KEYBOARD_o }, - { SUBITEM, "P", KEYBOARD_p }, - { SUBITEM, "Q", KEYBOARD_q }, - { SUBITEM, "R", KEYBOARD_r }, - { SUBITEM, "S", KEYBOARD_s }, - { SUBITEM, "T", KEYBOARD_t }, - { SUBITEM, "U", KEYBOARD_u }, - { SUBITEM, "V", KEYBOARD_v }, - { SUBITEM, "W", KEYBOARD_w }, - { SUBITEM, "X", KEYBOARD_x }, - { SUBITEM, "Y", KEYBOARD_y }, - { SUBITEM, "Z", KEYBOARD_z }, - - { ITEM, "Space", KEYBOARD_space }, - { ITEM, "Enter", KEYBOARD_Enter }, - { ITEM, "Caps Shift", KEYBOARD_Caps }, - { ITEM, "Symbol Shift", KEYBOARD_Symbol }, - { ITEM, "Nothing", KEYBOARD_NONE }, - -}; - -static GtkTreeModel * -create_joystick_options_store( void ) -{ - GtkTreeIter iter, iter2; - GtkTreeStore *store; - guint i; - - store = gtk_tree_store_new( NUM_COLS, G_TYPE_STRING, G_TYPE_INT ); - - for( i = 0; i < ARRAY_SIZE( key_menu ); i++ ) { - - switch( key_menu[i].item ) { - - case ITEM: - case KEY_GROUP: - gtk_tree_store_append( store, &iter, NULL ); - gtk_tree_store_set( store, &iter, - COL_TEXT, key_menu[i].text, - COL_KEY, key_menu[i].key, - -1 ); - break; - - case SUBITEM: - gtk_tree_store_append( store, &iter2, &iter ); - gtk_tree_store_set( store, &iter2, - COL_TEXT, key_menu[i].text, - COL_KEY, key_menu[i].key, - -1 ); - break; - - } - - } - - return GTK_TREE_MODEL( store ); -} - -void -menu_options_joysticks_select( GtkAction *gtk_action GCC_UNUSED, - guint callback_action ) -{ - GtkWidget *dialog, *hbox, *vbox, *content_area; - GtkTreeModel *model; - struct joystick_info info; - int i; - - fuse_emulation_pause(); - - setup_info( &info, callback_action ); - - dialog = gtkstock_dialog_new( "Fuse - Configure Joystick", NULL ); - content_area = gtk_dialog_get_content_area( GTK_DIALOG( dialog ) ); - - hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 4 ); - gtk_container_set_border_width( GTK_CONTAINER( hbox ), 4 ); - gtk_box_pack_start( GTK_BOX( content_area ), hbox, FALSE, FALSE, 0 ); - - create_joystick_type_selector( &info, GTK_BOX( hbox ) ); - - vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 2 ); - gtk_box_pack_start( GTK_BOX( hbox ), vbox, TRUE, TRUE, 0 ); - - model = create_joystick_options_store(); - - for( i = 0; i < NUM_JOY_BUTTONS; i += 5 ) { - - int j; - - vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 2 ); - gtk_box_pack_start( GTK_BOX( hbox ), vbox, TRUE, TRUE, 0 ); - - for( j = i; j < i + 5; j++ ) - if( info.button[j].setting ) { - create_fire_button_selector( info.button[j].name, &( info.button[j] ), - GTK_BOX( vbox ), model ); - } - } - - g_object_unref( model ); - - gtkstock_create_ok_cancel( dialog, NULL, G_CALLBACK( joystick_done ), - &info, DEFAULT_DESTROY, DEFAULT_DESTROY ); - - gtk_dialog_set_default_response( GTK_DIALOG( dialog ), GTK_RESPONSE_OK ); - - gtk_widget_show_all( dialog ); - gtk_main(); - - fuse_emulation_unpause(); -} - -static void -setup_info( struct joystick_info *info, int callback_action ) -{ - size_t i; - - switch( callback_action ) { - - case 1: - info->type = &( settings_current.joystick_1_output ); - info->button[0].setting = &( settings_current.joystick_1_fire_1 ); - info->button[1].setting = &( settings_current.joystick_1_fire_2 ); - info->button[2].setting = &( settings_current.joystick_1_fire_3 ); - info->button[3].setting = &( settings_current.joystick_1_fire_4 ); - info->button[4].setting = &( settings_current.joystick_1_fire_5 ); - info->button[5].setting = &( settings_current.joystick_1_fire_6 ); - info->button[6].setting = &( settings_current.joystick_1_fire_7 ); - info->button[7].setting = &( settings_current.joystick_1_fire_8 ); - info->button[8].setting = &( settings_current.joystick_1_fire_9 ); - info->button[9].setting = &( settings_current.joystick_1_fire_10 ); - info->button[10].setting = &( settings_current.joystick_1_fire_11 ); - info->button[11].setting = &( settings_current.joystick_1_fire_12 ); - info->button[12].setting = &( settings_current.joystick_1_fire_13 ); - info->button[13].setting = &( settings_current.joystick_1_fire_14 ); - info->button[14].setting = &( settings_current.joystick_1_fire_15 ); - for( i = 0; i < NUM_JOY_BUTTONS; i++ ) - snprintf( info->button[i].name, 80, "Button %lu", (unsigned long)i + 1 ); - break; - - case 2: - info->type = &( settings_current.joystick_2_output ); - info->button[0].setting = &( settings_current.joystick_2_fire_1 ); - info->button[1].setting = &( settings_current.joystick_2_fire_2 ); - info->button[2].setting = &( settings_current.joystick_2_fire_3 ); - info->button[3].setting = &( settings_current.joystick_2_fire_4 ); - info->button[4].setting = &( settings_current.joystick_2_fire_5 ); - info->button[5].setting = &( settings_current.joystick_2_fire_6 ); - info->button[6].setting = &( settings_current.joystick_2_fire_7 ); - info->button[7].setting = &( settings_current.joystick_2_fire_8 ); - info->button[8].setting = &( settings_current.joystick_2_fire_9 ); - info->button[9].setting = &( settings_current.joystick_2_fire_10 ); - info->button[10].setting = &( settings_current.joystick_2_fire_10 ); - info->button[11].setting = &( settings_current.joystick_2_fire_11 ); - info->button[12].setting = &( settings_current.joystick_2_fire_12 ); - info->button[13].setting = &( settings_current.joystick_2_fire_13 ); - info->button[14].setting = &( settings_current.joystick_2_fire_14 ); - for( i = 0; i < NUM_JOY_BUTTONS; i++ ) - snprintf( info->button[i].name, 80, "Button %lu", (unsigned long)i + 1 ); - break; - - case 3: - info->type = &( settings_current.joystick_keyboard_output ); - info->button[0].setting = &( settings_current.joystick_keyboard_up ); - snprintf( info->button[0].name, 80, "Button for UP" ); - info->button[1].setting = &( settings_current.joystick_keyboard_down ); - snprintf( info->button[1].name, 80, "Button for DOWN" ); - info->button[2].setting = &( settings_current.joystick_keyboard_left ); - snprintf( info->button[2].name, 80, "Button for LEFT" ); - info->button[3].setting = &( settings_current.joystick_keyboard_right ); - snprintf( info->button[3].name, 80, "Button for RIGHT" ); - info->button[4].setting = &( settings_current.joystick_keyboard_fire ); - snprintf( info->button[4].name, 80, "Button for FIRE" ); - for( i = 5; i < NUM_JOY_BUTTONS; i++ ) info->button[i].setting = NULL; - break; - - } -} - -static void -create_joystick_type_selector( struct joystick_info *info, GtkBox *parent ) -{ - GtkWidget *frame, *box; - GSList *button_group; - int i; - - frame = gtk_frame_new( "Joystick type" ); - gtk_box_pack_start( parent, frame, FALSE, FALSE, 0 ); - - box = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 ); - gtk_container_add( GTK_CONTAINER( frame ), box ); - - button_group = NULL; - - for( i = 0; i < JOYSTICK_TYPE_COUNT; i++ ) { - - info->radio[ i ] = - gtk_radio_button_new_with_label( button_group, joystick_name[ i ] ); - button_group = - gtk_radio_button_get_group( GTK_RADIO_BUTTON( info->radio[ i ] ) ); - gtk_box_pack_start( GTK_BOX( box ), info->radio[ i ], FALSE, FALSE, 0 ); - - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( info->radio[ i ] ), - i == *( info->type ) ); - - } - -} - -static void -set_entry_properties( GtkCellLayout *cell_layout GCC_UNUSED, - GtkCellRenderer *cell, GtkTreeModel *tree_model, - GtkTreeIter *iter, gpointer data GCC_UNUSED ) -{ - gboolean sensitive; - - sensitive = !gtk_tree_model_iter_has_child( tree_model, iter ); - - g_object_set( cell, "sensitive", sensitive, NULL ); - - g_object_set( cell, "xpad", 10, NULL ); -} - -static void -create_fire_button_selector( const char *title, struct button_info *info, - GtkBox *parent, GtkTreeModel *model ) -{ - GtkWidget *frame, *box, *combo; - GtkCellRenderer *renderer; - GtkTreeIter iter; - GtkTreePath *path; - size_t i; - - frame = gtk_frame_new( title ); - gtk_box_pack_start( parent, frame, TRUE, TRUE, 0 ); - - box = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 4 ); - gtk_container_set_border_width( GTK_CONTAINER( box ), 2 ); - gtk_container_add( GTK_CONTAINER( frame ), box ); - - /* Create label */ - info->key = *info->setting; - info->label = gtk_label_new( "" ); - - for( i = 0; i < ARRAY_SIZE( key_menu ); i++ ) { - - keyboard_key_name key; - - key = key_menu[i].key; - - if( key_menu[i].item != KEY_GROUP && key == (unsigned int)*info->setting ) { - set_key_text( info->label, key ); - break; - } - - } - - gtk_box_pack_start( GTK_BOX( box ), info->label, TRUE, TRUE, 0 ); - - /* Create combobox */ - combo = gtk_combo_box_new_with_model( model ); - renderer = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start( GTK_CELL_LAYOUT( combo ), renderer, TRUE ); - gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT( combo ), renderer, - "text", 0, NULL ); - gtk_cell_layout_set_cell_data_func( GTK_CELL_LAYOUT( combo ), renderer, - set_entry_properties, NULL, NULL ); - - /* Select first item */ - path = gtk_tree_path_new_from_indices( 0, -1 ); - gtk_tree_model_get_iter( model, &iter, path ); - gtk_tree_path_free( path ); - gtk_combo_box_set_active_iter( GTK_COMBO_BOX( combo ), &iter ); - - gtk_box_pack_start( GTK_BOX( box ), combo, TRUE, TRUE, 0 ); - - g_signal_connect( G_OBJECT( combo ), "changed", G_CALLBACK( key_callback ), - info ); -} - -static void -set_key_text( GtkWidget *label, keyboard_key_name key ) -{ - const char *text; - char buffer[40]; - - text = keyboard_key_text( key ); - - snprintf( buffer, 40, "%s", text ); - - gtk_label_set_text( GTK_LABEL( label ), buffer ); -} - -static void -key_callback( GtkComboBox *widget, gpointer user_data ) -{ - GtkTreeIter iter; - GValue value; - struct button_info *info = user_data; - keyboard_key_name key; - GtkTreeModel *model; - - /* Get current selection */ - gtk_combo_box_get_active_iter( GTK_COMBO_BOX( widget ), &iter ); - memset( &value, 0, sizeof( value ) ); - model = gtk_combo_box_get_model( GTK_COMBO_BOX( widget ) ); - gtk_tree_model_get_value( model, &iter, COL_KEY, &value ); - key = g_value_get_int( &value ); - g_value_unset( &value ); - - /* Store and display selection */ - info->key = key; - set_key_text( info->label, info->key ); -} - -static void -joystick_done( GtkButton *button GCC_UNUSED, gpointer user_data ) -{ - struct joystick_info *info = user_data; - - int i; - GtkToggleButton *toggle; - - for( i = 0; i < NUM_JOY_BUTTONS; i++ ) - if( info->button[i].setting ) - *info->button[i].setting = info->button[i].key; - - for( i = 0; i < JOYSTICK_TYPE_COUNT; i++ ) { - - toggle = GTK_TOGGLE_BUTTON( info->radio[ i ] ); - - if( gtk_toggle_button_get_active( toggle ) ) { - *( info->type ) = i; - return; - } - - } - -} diff --git a/fuse/ui/gtk/gtkkeyboard.c b/fuse/ui/gtk/gtkkeyboard.c deleted file mode 100644 index 9f538c8..0000000 --- a/fuse/ui/gtk/gtkkeyboard.c +++ /dev/null @@ -1,106 +0,0 @@ -/* gtkkeyboard.c: GTK routines for dealing with the keyboard - Copyright (c) 2000-2008 Philip Kendall, Russell Marks - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include - -#include "compat.h" -#include "gtkcompat.h" -#include "gtkinternals.h" -#include "input.h" -#include "keyboard.h" -#include "ui/ui.h" - -/* Given a hardware keycode, return the keyval which would have been returned if - the key were unshifted */ -static guint -unshift_keysym( guint keycode, gint group ) -{ - GdkKeymapKey *maps; - guint *keyvals, i, r = GDK_KEY_VoidSymbol, r2 = GDK_KEY_VoidSymbol; - gint count; - - gdk_keymap_get_entries_for_keycode( gdk_keymap_get_default(), keycode, - &maps, &keyvals, &count ); - - for( i = 0; i < count; i++ ) { - if( maps[i].group == group && maps[i].level == 0 ) { - r = keyvals[i]; - break; - } - if( maps[i].group == 0 && maps[i].level == 0 ) { - r2 = keyvals[i]; - } - } - if (i == count) - r = r2; - - g_free( keyvals ); g_free( maps ); - - return r; -} - -static void -get_keysyms( input_event_t *event, guint keycode, guint keysym, gint group ) -{ - guint unshifted; - - /* The GTK UI doesn't actually use the native keysym for anything, - but we may as well set it up anyway as we've got it */ - event->types.key.native_key = keysyms_remap( keysym ); - - unshifted = unshift_keysym( keycode, group ); - event->types.key.spectrum_key = keysyms_remap( unshifted ); -} - -int -gtkkeyboard_keypress( GtkWidget *widget GCC_UNUSED, GdkEvent *event, - gpointer data GCC_UNUSED ) -{ - input_event_t fuse_event; - - if( event->key.keyval == GDK_KEY_F1 && event->key.state == 0 ) - ui_mouse_suspend(); - - fuse_event.type = INPUT_EVENT_KEYPRESS; - get_keysyms( &fuse_event, event->key.hardware_keycode, event->key.keyval, event->key.group ); - - return input_event( &fuse_event ); - - /* FIXME: handle F1 to deal with the pop-up menu */ -} - -int -gtkkeyboard_keyrelease( GtkWidget *widget GCC_UNUSED, GdkEvent *event, - gpointer data GCC_UNUSED ) -{ - input_event_t fuse_event; - - fuse_event.type = INPUT_EVENT_KEYRELEASE; - get_keysyms( &fuse_event, event->key.hardware_keycode, event->key.keyval, event->key.group ); - - return input_event( &fuse_event ); -} diff --git a/fuse/ui/gtk/gtkmouse.c b/fuse/ui/gtk/gtkmouse.c deleted file mode 100644 index 801616c..0000000 --- a/fuse/ui/gtk/gtkmouse.c +++ /dev/null @@ -1,270 +0,0 @@ -/* gtkmouse.c: GTK routines for emulating Spectrum mice - Copyright (c) 2004 Darren Salt - Copyright (c) 2015 Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: linux@youmustbejoking.demon.co.uk - -*/ - -#include - -#include -#include - -#include "gtkinternals.h" -#include "ui/ui.h" - -#ifdef GDK_WINDOWING_WAYLAND -#include -#endif - -#ifdef GDK_WINDOWING_X11 -/* For XWarpPointer *only* - see below */ -#include -#include -#endif - -static GdkCursor *nullpointer = NULL; - -/* The widget we base our events, grabs, warping etc on */ -static GtkWidget *mouse_widget = NULL; - -/* Translate absolute pointer coordinate to relative movement */ -static void (*mouse_motion_fn)( gdouble x, gdouble y, int *rel_x, int *rel_y ); - -#if defined GDK_WINDOWING_WAYLAND || defined GDK_WINDOWING_WIN32 - -/* On Wayland we can't warp the pointer so we keep the last position */ -static gdouble last_pos_x = 0; -static gdouble last_pos_y = 0; -static int have_last_position = 0; - -static void -mouse_motion_relative( gdouble x, gdouble y, int *rel_x, int *rel_y ) -{ - if( have_last_position ) { - *rel_x = x - last_pos_x; - *rel_y = y - last_pos_y; - } else { - *rel_x = 0; - *rel_y = 0; - have_last_position = 1; - } - - last_pos_x = x; - last_pos_y = y; -} - -#endif /* if defined GDK_WINDOWING_WAYLAND || - defined GDK_WINDOWING_WIN32 */ - -#ifdef GDK_WINDOWING_X11 - -static void -mouse_motion_x11( gdouble x, gdouble y, int *rel_x, int *rel_y ) -{ - *rel_x = x - 128; - *rel_y = y - 128; - - if( x != 128 || y != 128 ) { - GdkWindow *window = gtk_widget_get_window( mouse_widget ); - XWarpPointer( GDK_WINDOW_XDISPLAY( window ), None, - GDK_WINDOW_XID( window ), 0, 0, 0, 0, 128, 128 ); - } -} - -#endif /* #ifdef GDK_WINDOWING_X11 */ - -#ifdef GDK_WINDOWING_WIN32 - -static void -mouse_motion_win32( gdouble x, gdouble y, int *rel_x, int *rel_y ) -{ - mouse_motion_relative( x, y, rel_x, rel_y ); - - /* Keep pointer hidden */ - SetCursor( NULL ); -} - -#endif /* #ifdef GDK_WINDOWING_WIN32 */ - -static void -gtkmouse_reset_pointer( void ) -{ - /* Ugh. GDK doesn't have its own move-pointer function :-| - - The logic here is a bit hairy: - - * On GTK 2.x, we warp relative to the drawing area - * On GTK 3.x on X11, we warp relative to the top-level window - * On GTK 3.x on Wayland, we don't warp at all because it causes a - segfault (see bug #435) - * On GTK 3.x on win32, we don't warp at all - */ - -#ifdef GDK_WINDOWING_WAYLAND - - GdkDisplay *display = gdk_display_get_default(); - if( GDK_IS_WAYLAND_DISPLAY( display ) ) { - mouse_motion_fn = mouse_motion_relative; - have_last_position = 0; - return; - } - -#endif /* #ifdef GDK_WINDOWING_WAYLAND */ - -#ifdef GDK_WINDOWING_X11 - - mouse_motion_fn = mouse_motion_x11; - - /* Force initial position */ - GdkWindow *window = gtk_widget_get_window( mouse_widget ); - XWarpPointer( GDK_WINDOW_XDISPLAY( window ), None, - GDK_WINDOW_XID( window ), 0, 0, 0, 0, 128, 128 ); - return; - -#endif /* #ifdef GDK_WINDOWING_WAYLAND */ - -#ifdef GDK_WINDOWING_WIN32 - - mouse_motion_fn = mouse_motion_win32; - have_last_position = 0; - return; - -#endif /* #ifdef GDK_WINDOWING_WIN32 */ - -} - -static gboolean -motion_event( GtkWidget *widget GCC_UNUSED, GdkEventMotion *event, - gpointer data GCC_UNUSED ) -{ - int rel_x, rel_y; - - if( !ui_mouse_grabbed ) return FALSE; - - /* Get relative movement from last position */ - (*mouse_motion_fn)( event->x, event->y, &rel_x, &rel_y ); - ui_mouse_motion( rel_x, rel_y ); - - return FALSE; -} - -static gboolean -button_event( GtkWidget *widget GCC_UNUSED, GdkEventButton *event, - gpointer data GCC_UNUSED ) -{ - if( event->type == GDK_BUTTON_PRESS || event->type == GDK_2BUTTON_PRESS - || event->type == GDK_3BUTTON_PRESS ) - ui_mouse_button( event->button, 1 ); - else - ui_mouse_button( event->button, 0 ); - - /* Stop other handlers only if we've grabbed the mouse */ - return ui_mouse_grabbed? TRUE : FALSE; -} - -void -gtkmouse_init( void ) -{ -#if GTK_CHECK_VERSION( 3, 0, 0 ) - mouse_widget = gtkui_window; -#else /* #if GTK_CHECK_VERSION( 3, 0, 0 ) */ - mouse_widget = gtkui_drawing_area; -#endif /* #if GTK_CHECK_VERSION( 3, 0, 0 ) */ - - gtk_widget_add_events( GTK_WIDGET( mouse_widget ), - GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK ); - g_signal_connect( G_OBJECT( mouse_widget ), "motion-notify-event", - G_CALLBACK( motion_event ), NULL ); - g_signal_connect( G_OBJECT( mouse_widget ), "button-press-event", - G_CALLBACK( button_event ), NULL ); - g_signal_connect( G_OBJECT( mouse_widget ), "button-release-event", - G_CALLBACK( button_event ), NULL ); -} - -int -ui_mouse_grab( int startup ) -{ - GdkWindow *window; - GdkGrabStatus status; - - if( startup ) return 0; - - window = gtk_widget_get_window( mouse_widget ); - -#if !GTK_CHECK_VERSION( 3, 20, 0 ) - - if( !nullpointer ) { - nullpointer = gdk_cursor_new( GDK_BLANK_CURSOR ); - } - - status = gdk_pointer_grab( window, FALSE, - GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK, - window, nullpointer, GDK_CURRENT_TIME ); - -#else - - GdkDisplay *display; - GdkSeat *seat; - - display = gdk_window_get_display( window ); - - if( !nullpointer ) { - nullpointer = gdk_cursor_new_for_display( display, GDK_BLANK_CURSOR ); - } - - seat = gdk_display_get_default_seat( display ); - status = gdk_seat_grab( seat, window, GDK_SEAT_CAPABILITY_ALL_POINTING, - FALSE, nullpointer, NULL, NULL, NULL ); - -#endif /* #if !GTK_CHECK_VERSION( 3, 20, 0 ) */ - - if( status == GDK_GRAB_SUCCESS ) { - gtkmouse_reset_pointer(); - ui_statusbar_update( UI_STATUSBAR_ITEM_MOUSE, UI_STATUSBAR_STATE_ACTIVE ); - return 1; - } - - ui_error( UI_ERROR_WARNING, "Mouse grab failed" ); - return 0; -} - -int -ui_mouse_release( int suspend GCC_UNUSED ) -{ -#if !GTK_CHECK_VERSION( 3, 20, 0 ) - - gdk_pointer_ungrab( GDK_CURRENT_TIME ); - -#else - - GdkDisplay *display; - GdkSeat *seat; - - display = gtk_widget_get_display( mouse_widget ); - seat = gdk_display_get_default_seat( display ); - gdk_seat_ungrab( seat ); - -#endif /* #if !GTK_CHECK_VERSION( 3, 20, 0 ) */ - - ui_statusbar_update( UI_STATUSBAR_ITEM_MOUSE, UI_STATUSBAR_STATE_INACTIVE ); - return 0; -} diff --git a/fuse/ui/gtk/gtkui.c b/fuse/ui/gtk/gtkui.c deleted file mode 100644 index fcb2d7e..0000000 --- a/fuse/ui/gtk/gtkui.c +++ /dev/null @@ -1,1000 +0,0 @@ -/* gtkui.c: GTK routines for dealing with the user interface - Copyright (c) 2000-2015 Philip Kendall, Russell Marks, Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include -#include - -#include - -#include - -#include "debugger/debugger.h" -#include "fuse.h" -#include "gtkcompat.h" -#include "gtkinternals.h" -#include "keyboard.h" -#include "machine.h" -#include "machines/specplus3.h" -#include "menu.h" -#include "peripherals/ide/simpleide.h" -#include "peripherals/ide/zxatasp.h" -#include "peripherals/ide/zxcf.h" -#include "peripherals/joystick.h" -#include "psg.h" -#include "rzx.h" -#include "screenshot.h" -#include "settings.h" -#include "snapshot.h" -#include "timer/timer.h" -#include "ui/ui.h" -#include "utils.h" - -/* The main Fuse window */ -GtkWidget *gtkui_window; - -/* The area into which the screen will be drawn */ -GtkWidget *gtkui_drawing_area; - -static GtkWidget *menu_bar; - -/* The UIManager used to create the menu bar */ -GtkUIManager *ui_manager_menu = NULL; - -/* True if we were paused via the Machine/Pause menu item */ -static int paused = 0; - -/* Structure used by the radio button selection widgets (eg the - graphics filter selectors and Machine/Select) */ -typedef struct gtkui_select_info { - - GtkWidget *dialog; - GtkWidget **buttons; - - /* Used by the graphics filter selectors */ - scaler_available_fn selector; - scaler_type selected; - - /* Used by the joystick confirmation */ - ui_confirm_joystick_t joystick; - -} gtkui_select_info; - -static gboolean gtkui_make_menu(GtkAccelGroup **accel_group, - GtkWidget **menu_bar, - GtkActionEntry *menu_data, - guint menu_data_size); - -static gboolean gtkui_lose_focus( GtkWidget*, GdkEvent*, gpointer ); -static gboolean gtkui_gain_focus( GtkWidget*, GdkEvent*, gpointer ); - -static gboolean gtkui_delete( GtkWidget *widget, GdkEvent *event, - gpointer data ); - -static void menu_options_filter_done( GtkWidget *widget, gpointer user_data ); -static void menu_machine_select_done( GtkWidget *widget, gpointer user_data ); - -static const GtkTargetEntry drag_types[] = -{ - { (gchar *)"text/uri-list", GTK_TARGET_OTHER_APP, 0 } -}; - -static void gtkui_drag_data_received( GtkWidget *widget GCC_UNUSED, - GdkDragContext *drag_context, - gint x GCC_UNUSED, gint y GCC_UNUSED, - GtkSelectionData *data, - guint info GCC_UNUSED, guint timestamp ) -{ - static char uri_prefix[] = "file://"; - char *filename, *selection_filename; - const guchar *selection_data, *data_begin, *data_end, *p; - gint selection_length; - - selection_length = gtk_selection_data_get_length( data ); - - if ( data && selection_length > (gint) sizeof( uri_prefix ) ) { - selection_data = gtk_selection_data_get_data( data ); - data_begin = selection_data + sizeof( uri_prefix ) - 1; - data_end = selection_data + selection_length; - p = data_begin; - do { - if ( *p == '\r' || *p == '\n' ) { - data_end = p; - break; - } - } while ( p++ != data_end ); - - selection_filename = g_strndup( (const gchar *)data_begin, - data_end - data_begin ); - - filename = g_uri_unescape_string( selection_filename, NULL ); - if ( filename ) { - fuse_emulation_pause(); - utils_open_file( filename, settings_current.auto_load, NULL ); - free( filename ); - display_refresh_all(); - fuse_emulation_unpause(); - } - - g_free( selection_filename ); - } - gtk_drag_finish( drag_context, FALSE, FALSE, timestamp ); -} - -int -ui_init( int *argc, char ***argv ) -{ - GtkWidget *box; - GtkAccelGroup *accel_group; - GtkSettings *settings; - -#if GTK_CHECK_VERSION( 3, 10, 0 ) - /* The Wayland output is buggy, see #367 */ - gdk_set_allowed_backends( "quartz,win32,mir,x11,*" ); -#endif - - gtk_init(argc,argv); - -#if !GTK_CHECK_VERSION( 3, 0, 0 ) - gdk_rgb_init(); - gdk_rgb_set_install( TRUE ); - gtk_widget_set_default_colormap( gdk_rgb_get_cmap() ); - gtk_widget_set_default_visual( gdk_rgb_get_visual() ); -#endif /* #if !GTK_CHECK_VERSION( 3, 0, 0 ) */ - - gtkui_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - -#ifdef FUSE_ICON_AVAILABLE - gtk_window_set_icon_name( GTK_WINDOW( gtkui_window ), "fuse" ); -#endif - - settings = gtk_widget_get_settings( GTK_WIDGET( gtkui_window ) ); - g_object_set( settings, "gtk-menu-bar-accel", "F1", NULL ); - gtk_window_set_title( GTK_WINDOW(gtkui_window), "Fuse" ); - - g_signal_connect(G_OBJECT(gtkui_window), "delete-event", - G_CALLBACK(gtkui_delete), NULL); - g_signal_connect(G_OBJECT(gtkui_window), "key-press-event", - G_CALLBACK(gtkkeyboard_keypress), NULL); - gtk_widget_add_events( gtkui_window, GDK_KEY_RELEASE_MASK ); - g_signal_connect(G_OBJECT(gtkui_window), "key-release-event", - G_CALLBACK(gtkkeyboard_keyrelease), NULL); - - /* If we lose the focus, disable all keys */ - g_signal_connect( G_OBJECT( gtkui_window ), "focus-out-event", - G_CALLBACK( gtkui_lose_focus ), NULL ); - g_signal_connect( G_OBJECT( gtkui_window ), "focus-in-event", - G_CALLBACK( gtkui_gain_focus ), NULL ); - - gtk_drag_dest_set( GTK_WIDGET( gtkui_window ), - GTK_DEST_DEFAULT_ALL, - drag_types, - ARRAY_SIZE( drag_types ), - GDK_ACTION_COPY | GDK_ACTION_PRIVATE | GDK_ACTION_MOVE ); - /* GDK_ACTION_PRIVATE alone DNW with ROX-Filer, - GDK_ACTION_MOVE allow DnD from KDE */ - - g_signal_connect( G_OBJECT( gtkui_window ), "drag-data-received", - G_CALLBACK( gtkui_drag_data_received ), NULL ); - - box = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 ); - gtk_container_add(GTK_CONTAINER(gtkui_window), box); - - if( gtkui_make_menu( &accel_group, &menu_bar, gtkui_menu_data, - gtkui_menu_data_size ) ) { - fprintf(stderr,"%s: couldn't make menus %s:%d\n", - fuse_progname,__FILE__,__LINE__); - return 1; - } - - gtk_window_add_accel_group( GTK_WINDOW(gtkui_window), accel_group ); - gtk_box_pack_start( GTK_BOX(box), menu_bar, FALSE, FALSE, 0 ); - - gtkui_drawing_area = gtk_drawing_area_new(); - if(!gtkui_drawing_area) { - fprintf(stderr,"%s: couldn't create drawing area at %s:%d\n", - fuse_progname,__FILE__,__LINE__); - return 1; - } - - /* Set minimum size for drawing area */ - gtk_widget_set_size_request( gtkui_drawing_area, DISPLAY_ASPECT_WIDTH, - DISPLAY_SCREEN_HEIGHT ); - - gtkmouse_init(); - - gtk_box_pack_start( GTK_BOX(box), gtkui_drawing_area, TRUE, TRUE, 0 ); - - /* Create the statusbar */ - gtkstatusbar_create( GTK_BOX( box ) ); - - gtk_widget_show_all( gtkui_window ); - gtkstatusbar_set_visibility( settings_current.statusbar ); - - ui_mouse_present = 1; - - return 0; -} - -static void -gtkui_menu_deactivate( GtkMenuShell *menu GCC_UNUSED, - gpointer data GCC_UNUSED ) -{ - ui_mouse_resume(); -} - -static gboolean -gtkui_make_menu(GtkAccelGroup **accel_group, - GtkWidget **menu_bar, - GtkActionEntry *menu_data, - guint menu_data_size) -{ - *accel_group = NULL; - *menu_bar = NULL; - GError *error = NULL; - char ui_file[ PATH_MAX ]; - - ui_manager_menu = gtk_ui_manager_new(); - - /* Load actions */ - GtkActionGroup *menu_action_group = gtk_action_group_new( "MenuActionGroup" ); - gtk_action_group_add_actions( menu_action_group, menu_data, menu_data_size, - NULL ); - gtk_ui_manager_insert_action_group( ui_manager_menu, menu_action_group, 0 ); - g_object_unref( menu_action_group ); - - /* Load the UI */ - if( utils_find_file_path( "menu_data.ui", ui_file, UTILS_AUXILIARY_GTK ) ) { - fprintf( stderr, "%s: Error getting path for menu_data.ui\n", - fuse_progname ); - return TRUE; - } - - guint ui_menu_id = gtk_ui_manager_add_ui_from_file( ui_manager_menu, ui_file, - &error ); - if( error ) { - g_error_free( error ); - return TRUE; - } - else if( !ui_menu_id ) return TRUE; - - *accel_group = gtk_ui_manager_get_accel_group( ui_manager_menu ); - - *menu_bar = gtk_ui_manager_get_widget( ui_manager_menu, "/MainMenu" ); - g_signal_connect( G_OBJECT( *menu_bar ), "deactivate", - G_CALLBACK( gtkui_menu_deactivate ), NULL ); - - /* Start various menus in the 'off' state */ - ui_menu_activate( UI_MENU_ITEM_AY_LOGGING, 0 ); - ui_menu_activate( UI_MENU_ITEM_FILE_MOVIE_RECORDING, 0 ); - ui_menu_activate( UI_MENU_ITEM_MACHINE_PROFILER, 0 ); - ui_menu_activate( UI_MENU_ITEM_RECORDING, 0 ); - ui_menu_activate( UI_MENU_ITEM_RECORDING_ROLLBACK, 0 ); - ui_menu_activate( UI_MENU_ITEM_TAPE_RECORDING, 0 ); -#ifdef HAVE_LIB_XML2 - ui_menu_activate( UI_MENU_ITEM_FILE_SVG_CAPTURE, 0 ); -#endif - return FALSE; -} - -int -ui_event(void) -{ - while(gtk_events_pending()) - gtk_main_iteration(); - return 0; -} - -int -ui_end(void) -{ - /* Don't display the window whilst doing all this! */ - gtk_widget_hide( gtkui_window ); - - g_object_unref( ui_manager_menu ); - - return 0; -} - -/* Create a dialog box with the given error message */ -int -ui_error_specific( ui_error_level severity, const char *message ) -{ - GtkWidget *dialog, *label, *vbox, *content_area; - const gchar *title; - - /* If we don't have a UI yet, we can't output widgets */ - if( !display_ui_initialised ) return 0; - - /* Set the appropriate title */ - switch( severity ) { - case UI_ERROR_INFO: title = "Fuse - Info"; break; - case UI_ERROR_WARNING: title = "Fuse - Warning"; break; - case UI_ERROR_ERROR: title = "Fuse - Error"; break; - default: title = "Fuse - (Unknown Error Level)"; break; - } - - /* Create the dialog box */ - dialog = gtkstock_dialog_new( title, G_CALLBACK( gtk_widget_destroy ) ); - - /* Add the OK button into the lower half */ - gtkstock_create_close( dialog, NULL, G_CALLBACK (gtk_widget_destroy), - FALSE ); - - /* Create a label with that message */ - label = gtk_label_new( message ); - - /* Make a new vbox for the top part for saner spacing */ - vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 ); - content_area = gtk_dialog_get_content_area( GTK_DIALOG( dialog ) ); - gtk_box_pack_start( GTK_BOX( content_area ), vbox, TRUE, TRUE, 0 ); - gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - - /* Put the label in it */ - gtk_container_add( GTK_CONTAINER( vbox ), label ); - - gtk_widget_show_all( dialog ); - - return 0; -} - -/* The callbacks used by various routines */ - -static gboolean -gtkui_lose_focus( GtkWidget *widget GCC_UNUSED, - GdkEvent *event GCC_UNUSED, gpointer data GCC_UNUSED ) -{ - keyboard_release_all(); - ui_mouse_suspend(); - return TRUE; -} - -static gboolean -gtkui_gain_focus( GtkWidget *widget GCC_UNUSED, - GdkEvent *event GCC_UNUSED, gpointer data GCC_UNUSED ) -{ - ui_mouse_resume(); - return TRUE; -} - -/* Called by the main window on a "delete-event" */ -static gboolean -gtkui_delete( GtkWidget *widget GCC_UNUSED, GdkEvent *event GCC_UNUSED, - gpointer data GCC_UNUSED ) -{ - menu_file_exit( NULL, NULL ); - return TRUE; -} - -/* Called by the menu when File/Exit selected */ -void -menu_file_exit( GtkAction *gtk_action GCC_UNUSED, gpointer data GCC_UNUSED ) -{ - if( gtkui_confirm( "Exit Fuse?" ) ) { - - if( menu_check_media_changed() ) return; - - fuse_exiting = 1; - - /* Stop the paused state to allow us to exit (occurs from main - emulation loop) */ - if( paused ) menu_machine_pause( NULL, NULL ); - - /* Ensure we break out of the main Z80 loop, there could be active - breakpoints before the next event */ - debugger_exit_emulator( NULL ); - } -} - -/* Select a graphics filter from those for which `available' returns - true */ -scaler_type -menu_get_scaler( scaler_available_fn selector ) -{ - GtkWidget *content_area; - gtkui_select_info dialog; - GSList *button_group = NULL; - - int count; - scaler_type scaler; - - /* Store the function which tells us which scalers are currently - available */ - dialog.selector = selector; - - /* No scaler currently selected */ - dialog.selected = SCALER_NUM; - - /* Some space to store the radio buttons in */ - dialog.buttons = malloc( SCALER_NUM * sizeof(GtkWidget* ) ); - if( dialog.buttons == NULL ) { - ui_error( UI_ERROR_ERROR, "out of memory at %s:%d", __FILE__, __LINE__ ); - return SCALER_NUM; - } - - count = 0; - - /* Create the necessary widgets */ - dialog.dialog = gtkstock_dialog_new( "Fuse - Select Scaler", NULL ); - content_area = gtk_dialog_get_content_area( GTK_DIALOG( dialog.dialog ) ); - - for( scaler = 0; scaler < SCALER_NUM; scaler++ ) { - - if( !selector( scaler ) ) continue; - - dialog.buttons[ count ] = - gtk_radio_button_new_with_label( button_group, scaler_name( scaler ) ); - button_group = - gtk_radio_button_get_group( GTK_RADIO_BUTTON( dialog.buttons[ count ] ) ); - - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( dialog.buttons[ count ] ), - current_scaler == scaler ); - - gtk_container_add( GTK_CONTAINER( content_area ), dialog.buttons[ count ] ); - - count++; - } - - /* Create and add the actions buttons to the dialog box */ - gtkstock_create_ok_cancel( dialog.dialog, NULL, - G_CALLBACK( menu_options_filter_done ), - (gpointer) &dialog, DEFAULT_DESTROY, - DEFAULT_DESTROY ); - - gtk_dialog_set_default_response( GTK_DIALOG( dialog.dialog ), - GTK_RESPONSE_OK ); - - gtk_widget_show_all( dialog.dialog ); - - /* Process events until the window is done with */ - gtk_main(); - - return dialog.selected; -} - -/* Callback used by the filter selection dialog */ -static void -menu_options_filter_done( GtkWidget *widget GCC_UNUSED, gpointer user_data ) -{ - int i, count; - gtkui_select_info *ptr = (gtkui_select_info*)user_data; - - count = 0; - - for( i = 0; i < SCALER_NUM; i++ ) { - - if( !ptr->selector( i ) ) continue; - - if( gtk_toggle_button_get_active( - GTK_TOGGLE_BUTTON( ptr->buttons[ count ] ) - ) - ) { - ptr->selected = i; - } - - count++; - } - - gtk_widget_destroy( ptr->dialog ); - gtk_main_quit(); -} - -static gboolean -gtkui_run_main_loop( gpointer user_data GCC_UNUSED ) -{ - gtk_main(); - return FALSE; -} - -/* Machine/Pause */ -void -menu_machine_pause( GtkAction *gtk_action GCC_UNUSED, gpointer data GCC_UNUSED ) -{ - int error; - - if( paused ) { - paused = 0; - ui_statusbar_update( UI_STATUSBAR_ITEM_PAUSED, - UI_STATUSBAR_STATE_INACTIVE ); - timer_estimate_reset(); - gtk_main_quit(); - } else { - - /* Stop recording any competition mode RZX file */ - if( rzx_recording && rzx_competition_mode ) { - ui_error( UI_ERROR_INFO, "Stopping competition mode RZX recording" ); - error = rzx_stop_recording(); if( error ) return; - } - - paused = 1; - ui_statusbar_update( UI_STATUSBAR_ITEM_PAUSED, UI_STATUSBAR_STATE_ACTIVE ); - - /* Create nested main loop outside this callback to allow unpause */ - g_idle_add( (GSourceFunc)gtkui_run_main_loop, NULL ); - } - -} - -/* Called by the menu when Machine/Reset selected */ -void -menu_machine_reset( GtkAction *gtk_action GCC_UNUSED, guint action ) -{ - int hard_reset = action; - const char *message = "Reset?"; - - if( hard_reset ) - message = "Hard reset?"; - - if( !gtkui_confirm( message ) ) - return; - - /* Stop any ongoing RZX */ - rzx_stop_recording(); - rzx_stop_playback( 1 ); - - if( machine_reset( hard_reset ) ) { - ui_error( UI_ERROR_ERROR, "couldn't reset machine: giving up!" ); - - /* FIXME: abort() seems a bit extreme here, but it'll do for now */ - fuse_abort(); - } -} - -/* Called by the menu when Machine/Select selected */ -void -menu_machine_select( GtkAction *gtk_action GCC_UNUSED, - gpointer data GCC_UNUSED ) -{ - GtkWidget *content_area; - gtkui_select_info dialog; - - int i; - - /* Some space to store the radio buttons in */ - dialog.buttons = malloc( machine_count * sizeof(GtkWidget* ) ); - if( dialog.buttons == NULL ) { - ui_error( UI_ERROR_ERROR, "out of memory at %s:%d", __FILE__, __LINE__ ); - return; - } - - /* Stop emulation */ - fuse_emulation_pause(); - - /* Create the necessary widgets */ - dialog.dialog = gtkstock_dialog_new( "Fuse - Select Machine", NULL ); - content_area = gtk_dialog_get_content_area( GTK_DIALOG( dialog.dialog ) ); - - dialog.buttons[0] = - gtk_radio_button_new_with_label( - NULL, libspectrum_machine_name( machine_types[0]->machine ) - ); - - for( i=1; imachine ) - ); - } - - for( i=0; ibuttons[i]) ) && - machine_current != machine_types[i] - ) - { - machine_select( machine_types[i]->machine ); - } - } - - gtk_widget_destroy( ptr->dialog ); - gtk_main_quit(); -} - -void -menu_machine_debugger( GtkAction *gtk_action GCC_UNUSED, - gpointer data GCC_UNUSED ) -{ - debugger_mode = DEBUGGER_MODE_HALTED; - if( paused ) ui_debugger_activate(); -} - -/* Called on machine selection */ -int -ui_widgets_reset( void ) -{ - gtkui_pokefinder_clear(); - return 0; -} - -void -menu_help_keyboard( GtkAction *gtk_action GCC_UNUSED, gpointer data GCC_UNUSED ) -{ - gtkui_picture( "keyboard.png", 0 ); -} - -void -menu_help_about( GtkAction *gtk_action GCC_UNUSED, gpointer data GCC_UNUSED ) -{ - gtk_show_about_dialog( GTK_WINDOW( gtkui_window ), - "program-name", "Fuse", - "comments", "The Free Unix Spectrum Emulator", - "copyright", FUSE_COPYRIGHT, -#ifdef FUSE_ICON_AVAILABLE - "logo-icon-name", "fuse", -#else - "logo-icon-name", NULL, -#endif - "version", VERSION, - "website", PACKAGE_URL, - NULL ); -} - -/* Generic `tidy-up' callback */ -void -gtkui_destroy_widget_and_quit( GtkWidget *widget, gpointer data GCC_UNUSED ) -{ - gtk_widget_destroy( widget ); - gtk_main_quit(); -} - -/* Functions to activate and deactivate certain menu items */ - -int -ui_menu_item_set_active( const char *path, int active ) -{ - GtkWidget *menu_item; - - /* Translate UI-indepentment path to GTK UI path */ - gchar *full_path = g_strdup_printf ("/MainMenu%s", path ); - - menu_item = gtk_ui_manager_get_widget( ui_manager_menu, full_path ); - g_free( full_path ); - - if( !menu_item ) { - ui_error( UI_ERROR_ERROR, "couldn't get menu item '%s' from menu_factory", - path ); - return 1; - } - gtk_widget_set_sensitive( menu_item, active ); - - return 0; -} - -static void -confirm_joystick_done( GtkWidget *widget GCC_UNUSED, gpointer user_data ) -{ - int i; - gtkui_select_info *ptr = user_data; - - for( i = 0; i < JOYSTICK_CONN_COUNT; i++ ) { - - GtkToggleButton *button = GTK_TOGGLE_BUTTON( ptr->buttons[ i ] ); - - if( gtk_toggle_button_get_active( button ) ) { - ptr->joystick = i; - break; - } - } - - gtk_widget_destroy( ptr->dialog ); - gtk_main_quit(); -} - -ui_confirm_joystick_t -ui_confirm_joystick( libspectrum_joystick libspectrum_type, - int inputs GCC_UNUSED ) -{ - GtkWidget *content_area; - gtkui_select_info dialog; - char title[ 80 ]; - int i; - GSList *group = NULL; - - if( !settings_current.joy_prompt ) return UI_CONFIRM_JOYSTICK_NONE; - - /* Some space to store the radio buttons in */ - dialog.buttons = - malloc( JOYSTICK_CONN_COUNT * sizeof( *dialog.buttons ) ); - if( !dialog.buttons ) { - ui_error( UI_ERROR_ERROR, "out of memory at %s:%d", __FILE__, __LINE__ ); - return UI_CONFIRM_JOYSTICK_NONE; - } - - /* Stop emulation */ - fuse_emulation_pause(); - - /* Create the necessary widgets */ - snprintf( title, sizeof( title ), "Fuse - Configure %s Joystick", - libspectrum_joystick_name( libspectrum_type ) ); - dialog.dialog = gtkstock_dialog_new( title, NULL ); - content_area = gtk_dialog_get_content_area( GTK_DIALOG( dialog.dialog ) ); - - for( i = 0; i < JOYSTICK_CONN_COUNT; i++ ) { - - GtkWidget **button = &( dialog.buttons[ i ] ); - - *button = - gtk_radio_button_new_with_label( group, joystick_connection[ i ] ); - group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( *button ) ); - - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( *button ), i == 0 ); - gtk_container_add( GTK_CONTAINER( content_area ), *button ); - } - - /* Create and add the actions buttons to the dialog box */ - gtkstock_create_ok_cancel( dialog.dialog, NULL, - G_CALLBACK( confirm_joystick_done ), - (gpointer) &dialog, DEFAULT_DESTROY, - DEFAULT_DESTROY ); - - gtk_dialog_set_default_response( GTK_DIALOG( dialog.dialog ), - GTK_RESPONSE_OK ); - - gtk_widget_show_all( dialog.dialog ); - - /* Process events until the window is done with */ - dialog.joystick = UI_CONFIRM_JOYSTICK_NONE; - gtk_main(); - - /* And then carry on with emulation again */ - fuse_emulation_unpause(); - - return dialog.joystick; -} - -/* - * Font code - */ - -int -gtkui_get_monospaced_font( PangoFontDescription **font ) -{ - *font = pango_font_description_from_string( "Monospace 10" ); - if( !(*font) ) { - ui_error( UI_ERROR_ERROR, "couldn't find a monospaced font" ); - return 1; - } - - return 0; -} - -void -gtkui_free_font( PangoFontDescription *font ) -{ - pango_font_description_free( font ); -} - -void -gtkui_list_set_cursor( GtkTreeView *list, int row ) -{ - GtkTreePath *path; - - if( row >= 0 ) { - path = gtk_tree_path_new_from_indices( row, -1 ); - gtk_tree_view_set_cursor( list, path, NULL, FALSE ); - gtk_tree_path_free( path ); - } -} - -int -gtkui_list_get_cursor( GtkTreeView *list ) -{ - GtkTreePath *path; - GtkTreeViewColumn *focus_column; - int *indices; - int row = -1; - - /* Get selected row */ - gtk_tree_view_get_cursor( list, &path, &focus_column ); - if( path ) { - indices = gtk_tree_path_get_indices( path ); - if( indices ) row = indices[0]; - gtk_tree_path_free( path ); - } - - return row; -} - -static gboolean -key_press( GtkTreeView *list, GdkEventKey *event, gpointer user_data ) -{ - GtkAdjustment *adjustment = user_data; - gdouble base, oldbase, base_limit; - gdouble page_size, step_increment; - int cursor_row; - int num_rows; - - base = oldbase = gtk_adjustment_get_value( adjustment ); - page_size = gtk_adjustment_get_page_size( adjustment ); - step_increment = gtk_adjustment_get_step_increment( adjustment ); - num_rows = ( page_size + 1 ) / step_increment; - - /* Get selected row */ - cursor_row = gtkui_list_get_cursor( list ); - - switch( event->keyval ) - { - case GDK_KEY_Up: - if( cursor_row == 0 ) - base -= step_increment; - break; - - case GDK_KEY_Down: - if( cursor_row == num_rows - 1 ) - base += step_increment; - break; - - case GDK_KEY_Page_Up: - base -= gtk_adjustment_get_page_increment( adjustment ); - break; - - case GDK_KEY_Page_Down: - base += gtk_adjustment_get_page_increment( adjustment ); - break; - - case GDK_KEY_Home: - cursor_row = 0; - base = gtk_adjustment_get_lower( adjustment ); - break; - - case GDK_KEY_End: - cursor_row = num_rows - 1; - base = gtk_adjustment_get_upper( adjustment ) - page_size; - break; - - default: - return FALSE; - } - - if( base < 0 ) { - base = 0; - } else { - base_limit = gtk_adjustment_get_upper( adjustment ) - page_size; - if( base > base_limit ) base = base_limit; - } - - if( base != oldbase ) { - gtk_adjustment_set_value( adjustment, base ); - - /* Mark selected row */ - gtkui_list_set_cursor( list, cursor_row ); - return TRUE; - } - - return FALSE; -} - -static gboolean -wheel_scroll_event( GtkTreeView *list, GdkEvent *event, gpointer user_data ) -{ - GtkAdjustment *adjustment = user_data; - gdouble base, oldbase, base_limit; - int cursor_row; - - base = oldbase = gtk_adjustment_get_value( adjustment ); - - switch( event->scroll.direction ) - { - case GDK_SCROLL_UP: - base -= gtk_adjustment_get_page_increment( adjustment ) / 2; - break; - case GDK_SCROLL_DOWN: - base += gtk_adjustment_get_page_increment( adjustment ) / 2; - break; - -#if GTK_CHECK_VERSION( 3, 4, 0 ) - case GDK_SCROLL_SMOOTH: - { - static gdouble total_dy = 0; - gdouble dx, dy, page_size; - int delta; - - if( gdk_event_get_scroll_deltas( event, &dx, &dy ) ) { - total_dy += dy; - page_size = gtk_adjustment_get_page_size( adjustment ); - delta = total_dy * pow( page_size, 2.0 / 3.0 ); - - /* Is movement significative? */ - if( delta ) { - base += delta; - total_dy = 0; - } - } - break; - } -#endif - - default: - return FALSE; - } - - if( base < 0 ) { - base = 0; - } else { - base_limit = gtk_adjustment_get_upper( adjustment ) - - gtk_adjustment_get_page_size( adjustment ); - if( base > base_limit ) base = base_limit; - } - - if( base != oldbase ) { - cursor_row = gtkui_list_get_cursor( list ); - gtk_adjustment_set_value( adjustment, base ); - gtkui_list_set_cursor( list, cursor_row ); - } - - return TRUE; -} - -void -gtkui_scroll_connect( GtkTreeView *list, GtkAdjustment *adj ) -{ - g_signal_connect( list, "key-press-event", - G_CALLBACK( key_press ), adj ); - g_signal_connect( list, "scroll-event", - G_CALLBACK( wheel_scroll_event ), adj ); -} - -int -gtkui_menubar_get_height( void ) -{ - GtkAllocation alloc; - - gtk_widget_get_allocation( menu_bar, &alloc ); - - return alloc.height; -} diff --git a/fuse/ui/gtk/memory.c b/fuse/ui/gtk/memory.c deleted file mode 100644 index 76dc33f..0000000 --- a/fuse/ui/gtk/memory.c +++ /dev/null @@ -1,460 +0,0 @@ -/* memory.c: the GTK memory browser - Copyright (c) 2004-2005 Philip Kendall - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "compat.h" -#include "fuse.h" -#include "gtkcompat.h" -#include "gtkinternals.h" -#include "memory_pages.h" -#include "menu.h" -#include "ui/ui.h" - -#define VIEW_NUM_ROWS 20 -#define VIEW_NUM_COLS 16 - -static libspectrum_word memaddr = 0x0000; - -static libspectrum_dword mark_offset = 0xffffffff; - -static int cursor_line_number = -1, cursor_char_offset; -static GtkTextBuffer *cursor_buffer; - -static GtkTextBuffer *buffer_address, *buffer_hex, *buffer_data; -static GtkAdjustment *adjustment; - -static gboolean -textview_wheel_scroll_event( GtkWidget *widget, GdkEvent *event, gpointer user_data ) -{ - GtkAdjustment *adjustment = user_data; - gdouble base, oldbase, base_limit; - - base = oldbase = gtk_adjustment_get_value( adjustment ); - - switch( event->scroll.direction ) - { - case GDK_SCROLL_UP: - base -= gtk_adjustment_get_page_increment( adjustment ) / 2; - break; - case GDK_SCROLL_DOWN: - base += gtk_adjustment_get_page_increment( adjustment ) / 2; - break; - -#if GTK_CHECK_VERSION( 3, 4, 0 ) - case GDK_SCROLL_SMOOTH: - { - static gdouble total_dy = 0; - gdouble dx, dy, page_size; - int delta; - - if( gdk_event_get_scroll_deltas( event, &dx, &dy ) ) { - total_dy += dy; - page_size = gtk_adjustment_get_page_size( adjustment ); - delta = total_dy * pow( page_size, 2.0 / 3.0 ); - - /* Is movement significative? */ - if( delta ) { - base += delta; - total_dy = 0; - } - } - break; - } -#endif - - default: - return FALSE; - } - - if( base < 0 ) { - base = 0; - } else { - base_limit = gtk_adjustment_get_upper( adjustment ) - - gtk_adjustment_get_page_size( adjustment ); - if( base > base_limit ) base = base_limit; - } - - if( base != oldbase ) { - gtk_adjustment_set_value( adjustment, base ); - } - - return TRUE; -} - -static gboolean -textview_key_press_event( GtkWidget *widget, GdkEventKey *event, gpointer user_data ) -{ - GtkAdjustment *adjustment = user_data; - GtkTextBuffer *text_buffer; - GtkTextIter iter; - GtkTextMark *mark; - gdouble base, oldbase, base_limit; - gdouble page_size, step_increment; - gint line, line_offset; - int num_rows, line_width; - - base = oldbase = gtk_adjustment_get_value( adjustment ); - page_size = gtk_adjustment_get_page_size( adjustment ); - step_increment = gtk_adjustment_get_step_increment( adjustment ); - num_rows = ( page_size + 1 ) / step_increment; - - text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( widget ) ); - - /* Get line width (includes CR/LF) */ - line_width = gtk_text_buffer_get_char_count( text_buffer ) / - gtk_text_buffer_get_line_count( text_buffer ); - - /* Get row and offset of cursor */ - mark = gtk_text_buffer_get_insert( text_buffer ); - gtk_text_buffer_get_iter_at_mark( text_buffer, &iter, mark ); - line = gtk_text_iter_get_line( &iter ); - line_offset = gtk_text_iter_get_line_offset( &iter ); - - switch( event->keyval ) - { - - case GDK_KEY_Left: - if( line == 0 && line_offset == 0 ) { - base -= step_increment; - cursor_buffer = text_buffer; - cursor_line_number = line; - cursor_char_offset = line_width; - } - break; - - case GDK_KEY_Right: - if( line == num_rows - 1 && line_offset == line_width ) { - base += step_increment; - cursor_buffer = text_buffer; - cursor_line_number = line; - cursor_char_offset = 0; - } - break; - - case GDK_KEY_Up: - if( line == 0 ) { - base -= step_increment; - cursor_buffer = text_buffer; - cursor_line_number = 0; - cursor_char_offset = line_offset; - } - break; - - case GDK_KEY_Down: - if( line == num_rows - 1 ) { - base += step_increment; - cursor_buffer = text_buffer; - cursor_line_number = line; - cursor_char_offset = line_offset; - } - break; - - case GDK_KEY_Page_Up: - base -= gtk_adjustment_get_page_increment( adjustment ); - cursor_buffer = text_buffer; - cursor_line_number = line; - cursor_char_offset = line_offset; - break; - - case GDK_KEY_Page_Down: - base += gtk_adjustment_get_page_increment( adjustment ); - cursor_buffer = text_buffer; - cursor_line_number = line; - cursor_char_offset = line_offset; - break; - - default: - return FALSE; - } - - if( base < 0 ) { - base = 0; - } else { - base_limit = gtk_adjustment_get_upper( adjustment ) - page_size; - if( base > base_limit ) base = base_limit; - } - - if( base != oldbase ) { - gtk_adjustment_set_value( adjustment, base ); - - /* As we are simulating a full-filled text view, we need to move the cursor - position after page movement/redraw */ - if( cursor_line_number >= 0 && cursor_line_number < VIEW_NUM_ROWS ) { - gtk_text_buffer_get_iter_at_line_offset( cursor_buffer, &iter, - cursor_line_number, - cursor_char_offset ); - gtk_text_buffer_place_cursor( cursor_buffer, &iter ); - cursor_line_number = -1; - } - - return TRUE; - } - - return FALSE; -} - -static void -update_display( libspectrum_word base ) -{ - size_t i, j; - char buffer2[ 8 ]; - char buffer3; - GtkTextIter iter_address, iter_hex, iter_data, start, end; - - memaddr = base; - - gtk_text_buffer_get_bounds( buffer_address, &start, &end ); - gtk_text_buffer_delete( buffer_address, &start, &end ); - gtk_text_buffer_get_bounds( buffer_hex, &start, &end ); - gtk_text_buffer_delete( buffer_hex, &start, &end ); - gtk_text_buffer_get_bounds( buffer_data, &start, &end ); - gtk_text_buffer_delete( buffer_data, &start, &end ); - - gtk_text_buffer_get_start_iter( buffer_address, &iter_address ); - gtk_text_buffer_get_start_iter( buffer_hex, &iter_hex ); - gtk_text_buffer_get_start_iter( buffer_data, &iter_data ); - - for( i = 0; i < VIEW_NUM_ROWS; i++ ) { - if( i > 0 ) { - gtk_text_buffer_insert( buffer_address, &iter_address, "\n", -1 ); - gtk_text_buffer_insert( buffer_hex, &iter_hex, "\n", -1 ); - gtk_text_buffer_insert( buffer_data, &iter_data, "\n", -1 ); - } - - snprintf( buffer2, 8, "%04X", base ); - gtk_text_buffer_insert( buffer_address, &iter_address, buffer2, -1 ); - - for( j = 0; j < VIEW_NUM_COLS; j++, base++ ) { - if( j > 0 ) - gtk_text_buffer_insert( buffer_hex, &iter_hex, " ", -1 ); - - libspectrum_byte b = readbyte_internal( base ); - snprintf( buffer2, 4, "%02X", b ); - - buffer3 = ( b >= 32 && b < 127 ) ? b : '.'; - - if( base != mark_offset ) { - gtk_text_buffer_insert( buffer_hex, &iter_hex, buffer2, -1 ); - gtk_text_buffer_insert( buffer_data, &iter_data, &buffer3, 1 ); - } else { - gtk_text_buffer_insert_with_tags_by_name( buffer_hex, &iter_hex, - buffer2, -1, "background_yellow", NULL ); - gtk_text_buffer_insert_with_tags_by_name( buffer_data, &iter_data, - &buffer3, 1, "background_yellow", NULL ); - } - } - } - - gtk_text_buffer_get_bounds( buffer_address, &start, &end ); - gtk_text_buffer_apply_tag_by_name( buffer_address, "monospace", &start, &end ); - gtk_text_buffer_get_bounds( buffer_hex, &start, &end ); - gtk_text_buffer_apply_tag_by_name( buffer_hex, "monospace", &start, &end ); - gtk_text_buffer_get_bounds( buffer_data, &start, &end ); - gtk_text_buffer_apply_tag_by_name( buffer_data, "monospace", &start, &end ); -} - -static void -scroller( GtkAdjustment *adjustment, gpointer user_data ) -{ - libspectrum_word base; - - /* Drop the low bits before displaying anything */ - base = gtk_adjustment_get_value( adjustment ); - base &= 0xfff0; - - update_display( base ); -} - -#if GTK_CHECK_VERSION( 3, 6, 0 ) -static void -goto_offset( GtkWidget *widget GCC_UNUSED, gpointer user_data GCC_UNUSED ) -{ - long offset; - const gchar *entry; - char *endptr; - int base_num; - - if( gtk_entry_get_text_length( GTK_ENTRY( widget ) ) == 0 ) - return; - - /* Parse address */ - entry = gtk_entry_get_text( GTK_ENTRY( widget ) ); - errno = 0; - base_num = ( g_str_has_prefix( entry, "0x" ) )? 16 : 10; - offset = strtol( entry, &endptr, base_num ); - - /* Validate address */ - if( errno || offset < 0 || offset > 65535 || endptr == entry || - *endptr != '\0' ) { - return; - } - - mark_offset = offset; - gtk_adjustment_set_value( adjustment, offset ); -} -#endif - -void -menu_machine_memorybrowser( GtkAction *gtk_action GCC_UNUSED, - gpointer data GCC_UNUSED ) -{ - GtkWidget *dialog, *content_area, *scrollbar, *label, *offset; - GtkWidget *box, *box_address, *box_hex, *box_data, *box_data_horizontal; - GtkAccelGroup *accel_group; - GtkWidget *view_address, *view_hex, *view_data; - GtkTextTagTable *tag_table; - GtkTextTag *tag; - - fuse_emulation_pause(); - - dialog = gtkstock_dialog_new( "Fuse - Memory Browser", NULL ); - content_area = gtk_dialog_get_content_area( GTK_DIALOG( dialog ) ); - - /* Keyboard shortcuts */ - accel_group = gtk_accel_group_new(); - gtk_window_add_accel_group( GTK_WINDOW( dialog ), accel_group ); - - gtkstock_create_close( dialog, accel_group, NULL, TRUE ); - -#if GTK_CHECK_VERSION( 3, 6, 0 ) - /* Go to offset */ - box = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 8 ); - offset = gtk_search_entry_new(); - /* - * Entry is max 6 chars wide ("0xXXXX") but the GTK widget adds - * a search icon and "clear contents" icon, which between them - * take up about 6 char's widths. So it needs to be wider. - */ - gtk_entry_set_width_chars( GTK_ENTRY( offset ), 15 ); - gtk_entry_set_max_length( GTK_ENTRY( offset ), 6 ); - gtk_box_pack_end( GTK_BOX( box ), offset, FALSE, FALSE, 0 ); - - label = gtk_label_new( "Go to offset" ); - gtk_box_pack_end( GTK_BOX( box ), label, FALSE, FALSE, 0 ); - - gtk_box_pack_start( GTK_BOX( content_area ), box, FALSE, FALSE, 8 ); - - g_signal_connect( G_OBJECT( offset ), "activate", - G_CALLBACK( goto_offset ), NULL ); -#endif - - /* Create text buffers */ - tag_table = gtk_text_tag_table_new(); - tag = gtk_text_tag_new( "monospace" ); - g_object_set( tag, "family", "monospace", NULL ); - gtk_text_tag_table_add( tag_table, tag ); - - tag = gtk_text_tag_new( "background_yellow" ); - g_object_set( tag, "background", "yellow", - "background-full-height", TRUE, NULL ); - gtk_text_tag_table_add( tag_table, tag ); - - buffer_address = gtk_text_buffer_new( tag_table ); - buffer_hex = gtk_text_buffer_new( tag_table ); - buffer_data = gtk_text_buffer_new( tag_table ); - - /* Labels */ - box = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 8 ); - box_address = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 ); - gtk_box_pack_start( GTK_BOX( box ), box_address, FALSE, FALSE, 0 ); - box_hex = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 ); - gtk_box_pack_start( GTK_BOX( box ), box_hex, FALSE, FALSE, 0 ); - box_data = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 ); - gtk_box_pack_start( GTK_BOX( box ), box_data, FALSE, FALSE, 0 ); - gtk_box_pack_start( GTK_BOX( content_area ), box, FALSE, FALSE, 0 ); - - label = gtk_label_new( "Address" ); - gtk_box_pack_start( GTK_BOX( box_address ), label, FALSE, FALSE, 0 ); - label = gtk_label_new( "Hex" ); - gtk_box_pack_start( GTK_BOX( box_hex ), label, FALSE, FALSE, 0 ); - label = gtk_label_new( "Data" ); - gtk_box_pack_start( GTK_BOX( box_data ), label, FALSE, FALSE, 0 ); - - /* Add views */ - view_address = gtk_text_view_new_with_buffer( buffer_address ); - gtk_text_view_set_editable( GTK_TEXT_VIEW( view_address ), FALSE ); - gtk_text_view_set_left_margin( GTK_TEXT_VIEW( view_address ), 1 ); - gtk_text_view_set_right_margin( GTK_TEXT_VIEW( view_address ), 1 ); - view_hex = gtk_text_view_new_with_buffer( buffer_hex ); - gtk_text_view_set_editable( GTK_TEXT_VIEW( view_hex ), FALSE ); - gtk_text_view_set_left_margin( GTK_TEXT_VIEW( view_hex ), 1 ); - gtk_text_view_set_right_margin( GTK_TEXT_VIEW( view_hex ), 1 ); - view_data = gtk_text_view_new_with_buffer( buffer_data ); - gtk_text_view_set_editable( GTK_TEXT_VIEW( view_data ), FALSE ); - gtk_text_view_set_left_margin( GTK_TEXT_VIEW( view_data ), 1 ); - gtk_text_view_set_right_margin( GTK_TEXT_VIEW( view_data ), 1 ); - -#if GTK_CHECK_VERSION( 3, 16, 0 ) - gtk_text_view_set_monospace( GTK_TEXT_VIEW( view_address ), TRUE ); - gtk_text_view_set_monospace( GTK_TEXT_VIEW( view_hex ), TRUE ); - gtk_text_view_set_monospace( GTK_TEXT_VIEW( view_data ), TRUE ); -#endif - - gtk_box_pack_start( GTK_BOX( box_address ), view_address, FALSE, FALSE, 0 ); - gtk_box_pack_start( GTK_BOX( box_hex ), view_hex, FALSE, FALSE, 0 ); - box_data_horizontal = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ); - gtk_box_pack_start( GTK_BOX( box_data ), box_data_horizontal, FALSE, FALSE, 0 ); - gtk_box_pack_start( GTK_BOX( box_data_horizontal ), view_data, FALSE, FALSE, 0 ); - - /* Scroll */ - adjustment = GTK_ADJUSTMENT( - gtk_adjustment_new( memaddr, 0x0000, 0xffff, VIEW_NUM_COLS, - ( VIEW_NUM_ROWS * VIEW_NUM_COLS ) / 2, - ( VIEW_NUM_ROWS * VIEW_NUM_COLS ) - 1 ) ); - g_signal_connect( adjustment, "value-changed", G_CALLBACK( scroller ), NULL ); - scrollbar = gtk_scrollbar_new( GTK_ORIENTATION_VERTICAL, adjustment ); - gtk_box_pack_start( GTK_BOX( box_data_horizontal ), scrollbar, FALSE, FALSE, 0 ); - - /* Allow scroll on text views */ - g_signal_connect( view_address, "scroll-event", - G_CALLBACK( textview_wheel_scroll_event ), adjustment ); - g_signal_connect( view_hex, "scroll-event", - G_CALLBACK( textview_wheel_scroll_event ), adjustment ); - g_signal_connect( view_data, "scroll-event", - G_CALLBACK( textview_wheel_scroll_event ), adjustment ); - g_signal_connect( view_address, "key-press-event", - G_CALLBACK( textview_key_press_event ), adjustment ); - g_signal_connect( view_hex, "key-press-event", - G_CALLBACK( textview_key_press_event ), adjustment ); - g_signal_connect( view_data, "key-press-event", - G_CALLBACK( textview_key_press_event ), adjustment ); - - update_display( memaddr ); - - gtk_widget_show_all( dialog ); - gtk_main(); - - fuse_emulation_unpause(); - - return; -} diff --git a/fuse/ui/gtk/memory_gtk2.c b/fuse/ui/gtk/memory_gtk2.c deleted file mode 100644 index 4dc696a..0000000 --- a/fuse/ui/gtk/memory_gtk2.c +++ /dev/null @@ -1,195 +0,0 @@ -/* memory.c: the GTK memory browser - Copyright (c) 2004-2005 Philip Kendall - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include -#include - -#include "compat.h" -#include "fuse.h" -#include "gtkcompat.h" -#include "gtkinternals.h" -#include "memory_pages.h" -#include "menu.h" - -static libspectrum_word memaddr = 0x0000; - -/* List columns */ -enum -{ - COL_ADDRESS = 0, - COL_HEX, - COL_DATA, - NUM_COLS -}; - -static void -update_display( GtkTreeModel *model, libspectrum_word base ) -{ - size_t i, j; - GtkTreeIter iter; - - gchar buffer[ 8 + 64 + 20 ]; - gchar *text[] = { &buffer[0], &buffer[ 8 ], &buffer[ 8 + 64 ] }; - char buffer2[ 4 ]; - - memaddr = base; - gtk_list_store_clear( GTK_LIST_STORE( model ) ); - - for( i = 0; i < 20; i++ ) { - snprintf( text[0], 8, "%04X", base ); - - text[1][0] = '\0'; - for( j = 0; j < 0x10; j++, base++ ) { - - libspectrum_byte b = readbyte_internal( base ); - - snprintf( buffer2, 4, "%02X ", b ); - strncat( text[1], buffer2, 4 ); - - text[2][j] = ( b >= 32 && b < 127 ) ? b : '.'; - } - text[2][ 0x10 ] = '\0'; - - /* Append a new row and fill data */ - gtk_list_store_append( GTK_LIST_STORE( model ), &iter ); - gtk_list_store_set( GTK_LIST_STORE( model ), &iter, - COL_ADDRESS, text[0], - COL_HEX, text[1], - COL_DATA, text[2], - -1 ); - } - -} - -static void -scroller( GtkAdjustment *adjustment, gpointer user_data ) -{ - libspectrum_word base; - GtkTreeModel *model = user_data; - - /* Drop the low bits before displaying anything */ - base = gtk_adjustment_get_value( adjustment ); - base &= 0xfff0; - - update_display( model, base ); -} - -static GtkWidget * -create_mem_list( void ) -{ - GtkWidget *view; - GtkCellRenderer *renderer; - GtkTreeModel *model; - GtkListStore *store; - - view = gtk_tree_view_new(); - - /* Add columns */ - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( view ), - -1, - "Address", - renderer, - "text", COL_ADDRESS, - NULL ); - - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( view ), - -1, - "Hex", - renderer, - "text", COL_HEX, - NULL ); - - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( view ), - -1, - "Data", - renderer, - "text", COL_DATA, - NULL ); - - /* Create data model */ - store = gtk_list_store_new( NUM_COLS, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_STRING ); - - model = GTK_TREE_MODEL( store ); - gtk_tree_view_set_model( GTK_TREE_VIEW( view ), model ); - g_object_unref( model ); - - return view; -} - -void -menu_machine_memorybrowser( GtkAction *gtk_action GCC_UNUSED, - gpointer data GCC_UNUSED ) -{ - GtkWidget *dialog, *box, *content_area, *list, *scrollbar; - GtkAdjustment *adjustment; - GtkTreeModel *model; - int error; - PangoFontDescription *font; - - fuse_emulation_pause(); - - error = gtkui_get_monospaced_font( &font ); if( error ) return; - - dialog = gtkstock_dialog_new( "Fuse - Memory Browser", NULL ); - - gtkstock_create_close( dialog, NULL, NULL, FALSE ); - - box = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ); - content_area = gtk_dialog_get_content_area( GTK_DIALOG( dialog ) ); - gtk_box_pack_start( GTK_BOX( content_area ), box, TRUE, TRUE, 0 ); - - /* The list itself */ - list = create_mem_list(); - gtk_widget_override_font( list, font ); - model = gtk_tree_view_get_model( GTK_TREE_VIEW( list ) ); - update_display( GTK_TREE_MODEL( model ), memaddr ); - gtk_box_pack_start( GTK_BOX( box ), list, TRUE, TRUE, 0 ); - - adjustment = GTK_ADJUSTMENT( - gtk_adjustment_new( memaddr, 0x0000, 0xffff, 0x10, 0xa0, 0x13f ) ); - g_signal_connect( adjustment, "value-changed", G_CALLBACK( scroller ), - model ); - - gtkui_scroll_connect( GTK_TREE_VIEW( list ), adjustment ); - - scrollbar = gtk_scrollbar_new( GTK_ORIENTATION_VERTICAL, adjustment ); - gtk_box_pack_start( GTK_BOX( box ), scrollbar, FALSE, FALSE, 0 ); - - gtk_widget_show_all( dialog ); - gtk_main(); - - gtkui_free_font( font ); - fuse_emulation_unpause(); - - return; -} diff --git a/fuse/ui/gtk/options-header.pl b/fuse/ui/gtk/options-header.pl deleted file mode 100755 index 3ac1bac..0000000 --- a/fuse/ui/gtk/options-header.pl +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/perl -w - -# options-header.pl: generate options dialog boxes - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Author contact information: - -# E-mail: philip-fuse@shadowmagic.org.uk - -use strict; - -use Fuse; -use Fuse::Dialog; - -die "No data file specified" unless @ARGV; - -my @dialogs = Fuse::Dialog::read( shift @ARGV ); -my $internal = 1; - -$internal = 0 if( @ARGV && shift( @ARGV ) eq 'public' ); - -if( $internal ) { - print Fuse::GPL( 'options_internals.h: options dialog boxes', - '2001-2002 Philip Kendall' ); -} else { - print Fuse::GPL( 'options.h: options dialog boxes public declarations', - '2001-2002 Philip Kendall' ); -} - -print <<"CODE"; - -/* This file is autogenerated from options.dat by options-header.pl. - Do not edit unless you know what you\'re doing! */ - -CODE - -if( $internal ) { - print << "CODE"; -#ifndef FUSE_GTKOPTIONS_INTERNALS_H -#define FUSE_GTKOPTIONS_INTERNALS_H - -#ifndef __GTK_H__ -#include -#endif - -CODE -} else { - print << "CODE"; -#ifndef FUSE_OPTIONS_H -#define FUSE_OPTIONS_H - -CODE -} - -if( $internal ) { - foreach( @dialogs ) { - - print << "CODE"; -void menu_options_$_->{name}( GtkWidget *widget, gpointer data ); - -typedef struct menu_options_$_->{name}_t \{ - - GtkWidget *dialog; - -CODE - - foreach my $widget ( @{ $_->{widgets} } ) { - - if( $widget->{type} eq "Checkbox" or - $widget->{type} eq "Combo" or - $widget->{type} eq "Entry" ) { - print " GtkWidget *$widget->{value};\n"; - } else { - die "Unknown type `$widget->{type}'"; - } - - } - - print "\n} menu_options_$_->{name}_t;\n\n" - - } -} else { - - foreach( @dialogs ) { - foreach my $widget ( @{ $_->{widgets} } ) { - if( $widget->{type} eq "Combo" ) { - print <<"CODE"; -int option_enumerate_$_->{name}_$widget->{value}( void ); - -CODE - } - } - } -} - -if( $internal ) { - print << "CODE"; -#endif /* #ifndef FUSE_GTKOPTIONS_ITERNALS_H */ -CODE -} else { - print << "CODE"; -#endif /* #ifndef FUSE_OPTIONS_H */ -CODE -} diff --git a/fuse/ui/gtk/options.pl b/fuse/ui/gtk/options.pl deleted file mode 100755 index 3c0dec4..0000000 --- a/fuse/ui/gtk/options.pl +++ /dev/null @@ -1,355 +0,0 @@ -#!/usr/bin/perl -w - -# options.pl: generate options dialog boxes - -# Copyright (c) 2002-2015 Philip Kendall - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Author contact information: - -# E-mail: philip-fuse@shadowmagic.org.uk - -use strict; - -use Fuse; -use Fuse::Dialog; - -die "No data file specified" unless @ARGV; - -my @dialogs = Fuse::Dialog::read( shift @ARGV ); - -my %combo_sets; -my %combo_default; - -print Fuse::GPL( 'options.c: options dialog boxes', - '2001-2013 Philip Kendall' ) . << "CODE"; - -/* This file is autogenerated from options.dat by options.pl. - Do not edit unless you know what you\'re doing! */ - -#include - -#ifdef UI_GTK /* Use this file if we're using GTK */ - -#include -#include -#include - -#include -#include - -#include "compat.h" -#include "display.h" -#include "fuse.h" -#include "options.h" -#include "options_internals.h" -#include "periph.h" -#include "settings.h" -#include "ui/gtk/gtkcompat.h" -#include "ui/gtk/gtkinternals.h" -#include "utils.h" - -static int -option_enumerate_combo( const char * const *options, char *value, guint count, - int def ) -{ - guint i; - if( value != NULL ) { - for( i = 0; i < count; i++) { - if( !strcmp( value, options[ i ] ) ) - return i; - } - } - return def; -} - -CODE - -foreach( @dialogs ) { - - foreach my $widget ( @{ $_->{widgets} } ) { - - foreach my $type ( $widget->{type} ) { - - my $text = $widget->{text}; $text =~ tr/()//d; - - if( $type eq "Combo" ) { - my $n = 0; - - foreach( split( /\|/, $widget->{data1} ) ) { - if( /^\*/ ) { - $combo_default{$widget->{value}} = $n; - } - $n++; - } - $n = 0; - $widget->{data1} =~ s/^\*//; - $widget->{data1} =~ s/\|\*/|/; - if( not exists( $combo_sets{$widget->{data1}} ) ) { - $combo_sets{$widget->{data1}} = "$_->{name}_$widget->{value}_combo"; - - print << "CODE"; - -static const char * const $_->{name}_$widget->{value}_combo[] = { -CODE - foreach( split( /\|/, $widget->{data1} ) ) { - print << "CODE"; - "$_", -CODE - $n++; - } - print << "CODE"; -}; - -static const guint $_->{name}_$widget->{value}_combo_count = $n; - -CODE - } else { - print << "CODE"; -\#define $_->{name}_$widget->{value}_combo $combo_sets{$widget->{data1}} -\#define $_->{name}_$widget->{value}_combo_count $combo_sets{$widget->{data1}}_count - -CODE - } - print << "CODE"; -int -option_enumerate_$_->{name}_$widget->{value}( void ) -{ - return option_enumerate_combo( $_->{name}_$widget->{value}_combo, - settings_current.$widget->{value}, - $_->{name}_$widget->{value}_combo_count, - $combo_default{$widget->{value}} ); -} - -CODE - } - } - } - - print << "CODE"; -static void menu_options_$_->{name}_done( GtkWidget *widget, - gpointer user_data ); - -void -menu_options_$_->{name}( GtkWidget *widget GCC_UNUSED, - gpointer data GCC_UNUSED ) -{ - GtkWidget *content_area; - menu_options_$_->{name}_t dialog; - - /* Firstly, stop emulation */ - fuse_emulation_pause(); - - /* Create the necessary widgets */ - dialog.dialog = gtkstock_dialog_new( "Fuse - $_->{title}", NULL ); - content_area = gtk_dialog_get_content_area( GTK_DIALOG( dialog.dialog ) ); - - /* Create the various widgets */ -CODE - - foreach my $widget ( @{ $_->{widgets} } ) { - - foreach my $type ( $widget->{type} ) { - - my $text = $widget->{text}; $text =~ tr/()//d; - - if( $type eq "Checkbox" ) { - - print << "CODE"; - dialog.$widget->{value} = - gtk_check_button_new_with_label( "$text" ); - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( dialog.$widget->{value} ), - settings_current.$widget->{value} ); - gtk_container_add( GTK_CONTAINER( content_area ), dialog.$widget->{value} ); - -CODE - } elsif( $type eq "Entry" ) { - - # FIXME: Make the entry widget resize sensibly - - print << "CODE"; - { - GtkWidget *frame = gtk_frame_new( "$text" ); - GtkWidget *hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ); - GtkWidget *text = gtk_label_new( "$widget->{data2}" ); - gchar buffer[80]; - - gtk_box_pack_start( GTK_BOX( content_area ), frame, TRUE, TRUE, 0 ); - - gtk_container_set_border_width( GTK_CONTAINER( hbox ), 4 ); - gtk_container_add( GTK_CONTAINER( frame ), hbox ); - - dialog.$widget->{value} = gtk_entry_new(); - gtk_entry_set_max_length( GTK_ENTRY( dialog.$widget->{value} ), - $widget->{data1} ); - snprintf( buffer, 80, "%d", settings_current.$widget->{value} ); - gtk_entry_set_text( GTK_ENTRY( dialog.$widget->{value} ), buffer ); - gtk_entry_set_activates_default( GTK_ENTRY( dialog.$widget->{value} ), TRUE ); - - gtk_box_pack_start( GTK_BOX( hbox ), dialog.$widget->{value}, TRUE, TRUE, 0 ); - - gtk_box_pack_start( GTK_BOX( hbox ), text, FALSE, FALSE, 5 ); - } - -CODE - } elsif( $type eq "Combo" ) { - - print << "CODE"; - { - GtkWidget *hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ); - GtkWidget *combo = gtk_combo_box_text_new(); - GtkWidget *text = gtk_label_new( "$text" ); - guint i; - - gtk_box_pack_start( GTK_BOX( hbox ), text, FALSE, FALSE, 5 ); - text = gtk_label_new( " " ); - gtk_box_pack_start( GTK_BOX( hbox ), text, TRUE, FALSE, 5 ); - - for( i = 0; i < $_->{name}_$widget->{value}_combo_count; i++ ) { - gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT( combo ), $_->{name}_$widget->{value}_combo[i] ); - } - gtk_combo_box_set_active( GTK_COMBO_BOX( combo ), $combo_default{$widget->{value}} ); - if( settings_current.$widget->{value} != NULL ) { - for( i = 0; i < $_->{name}_$widget->{value}_combo_count; i++ ) { - if( !strcmp( settings_current.$widget->{value}, $_->{name}_$widget->{value}_combo[i] ) ) { - gtk_combo_box_set_active( GTK_COMBO_BOX( combo ), i ); - } - } - } - - dialog.$widget->{value} = combo; - gtk_box_pack_start( GTK_BOX( hbox ), dialog.$widget->{value}, FALSE, FALSE, 5 ); - - gtk_box_pack_start( GTK_BOX( content_area ), hbox, TRUE, TRUE, 0 ); - } - -CODE - } else { - die "Unknown type `$type'"; - } - } - } - - print << "CODE"; - /* Create the OK and Cancel buttons */ - gtkstock_create_ok_cancel( dialog.dialog, NULL, - G_CALLBACK( menu_options_$_->{name}_done ), - (gpointer) &dialog, NULL, DEFAULT_DESTROY ); - - gtk_dialog_set_default_response( GTK_DIALOG( dialog.dialog ), - GTK_RESPONSE_OK ); - - /* Display the window */ - gtk_widget_show_all( dialog.dialog ); - - /* Process events until the window is done with */ - gtk_main(); - - /* And then carry on with emulation again */ - fuse_emulation_unpause(); -} - -static void -menu_options_$_->{name}_done( GtkWidget *widget GCC_UNUSED, - gpointer user_data ) -{ - menu_options_$_->{name}_t *ptr = user_data; - -CODE - - if( $_->{postcheck} ) { - - print << "CODE"; - /* Get a copy of current settings */ - settings_info original_settings; - memset( &original_settings, 0, sizeof( settings_info ) ); - settings_copy( &original_settings, &settings_current ); - -CODE - - } - - foreach my $widget ( @{ $_->{widgets} } ) { - - if( $widget->{type} eq "Checkbox" ) { - - print << "CODE"; - settings_current.$widget->{value} = - gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( ptr->$widget->{value} ) ); - -CODE - } elsif( $widget->{type} eq "Entry" ) { - - print << "CODE"; - settings_current.$widget->{value} = - atoi( gtk_entry_get_text( GTK_ENTRY( ptr->$widget->{value} ) ) ); - -CODE - } elsif( $widget->{type} eq "Combo" ) { - - print << "CODE"; - libspectrum_free( settings_current.$widget->{value} ); - settings_current.$widget->{value} = utils_safe_strdup( $_->{name}_$widget->{value}_combo[ - gtk_combo_box_get_active( GTK_COMBO_BOX( ptr->$widget->{value} ) ) ] ); - -CODE - } else { - die "Unknown type `$widget->{type}'"; - } - } - - if( $_->{postcheck} ) { - - print << "CODE"; - int needs_hard_reset = $_->{postcheck}(); - - /* Confirm reset */ - if( needs_hard_reset && !gtkui_confirm("Some options need to reset the machine. Reset?" ) ) { - - /* Cancel new settings */ - settings_copy( &settings_current, &original_settings ); - settings_free( &original_settings ); - return; - } - - settings_free( &original_settings ); - -CODE - - } - - print << "CODE"; - gtk_widget_destroy( ptr->dialog ); - -CODE - - print " $_->{posthook}();\n\n" if $_->{posthook}; - - print << "CODE"; - gtkstatusbar_set_visibility( settings_current.statusbar ); - display_refresh_all(); - - gtk_main_quit(); -} - -CODE - -} - -print << "CODE" - -#endif /* #ifdef UI_GTK */ -CODE diff --git a/fuse/ui/gtk/picture.c b/fuse/ui/gtk/picture.c deleted file mode 100644 index 29745c6..0000000 --- a/fuse/ui/gtk/picture.c +++ /dev/null @@ -1,146 +0,0 @@ -/* picture.c: GTK routines to draw the keyboard picture - Copyright (c) 2002-2005 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include - -#include "gtkinternals.h" -#include "ui/ui.h" -#include "utils.h" - -static int dialog_created = 0; - -static GtkWidget *dialog; -static GdkPixbuf *pixbuf = NULL; - -#if GTK_CHECK_VERSION( 3, 0, 0 ) - -static GdkPixbuf *scaled_pixbuf = NULL; - -static gint -picture_size_allocate( GtkWidget *widget GCC_UNUSED, GdkRectangle *allocation, - gpointer data GCC_UNUSED ) -{ - float scale_x, scale_y, scale_factor; - int scaled_width, scaled_height; - - scale_x = (float)allocation->width / gdk_pixbuf_get_width( pixbuf ); - scale_y = (float)allocation->height / gdk_pixbuf_get_height( pixbuf ); - scale_factor = scale_x < scale_y ? scale_x : scale_y; - - scaled_width = gdk_pixbuf_get_width( pixbuf ) * scale_factor; - scaled_height = gdk_pixbuf_get_height( pixbuf ) * scale_factor; - - if( scaled_pixbuf != NULL ) g_object_unref( scaled_pixbuf ); - scaled_pixbuf = gdk_pixbuf_scale_simple( pixbuf, scaled_width, scaled_height, - GDK_INTERP_BILINEAR ); - - return FALSE; -} - -static gboolean -picture_draw( GtkWidget *widget, cairo_t *cr, gpointer user_data GCC_UNUSED ) -{ - int offset_x, offset_y; - int scaled_width, scaled_height; - int allocated_width, allocated_height; - - allocated_width = gtk_widget_get_allocated_width( widget ); - allocated_height = gtk_widget_get_allocated_height( widget ); - - scaled_width = gdk_pixbuf_get_width( scaled_pixbuf ); - scaled_height = gdk_pixbuf_get_height( scaled_pixbuf ); - - offset_x = ( allocated_width - scaled_width ) / 2; - offset_y = ( allocated_height - scaled_height ) / 2; - - gdk_cairo_set_source_pixbuf( cr, scaled_pixbuf, offset_x, offset_y ); - cairo_paint(cr); - - return FALSE; -} - -#endif /* #if GTK_CHECK_VERSION( 3, 0, 0 ) */ - -int -gtkui_picture( const char *filename, int border GCC_UNUSED ) -{ - GtkWidget *content_area; - - if( !dialog_created ) { - - char path[PATH_MAX]; - - if( utils_find_file_path( filename, path, UTILS_AUXILIARY_LIB ) ) return 1; - - pixbuf = gdk_pixbuf_new_from_file( path, NULL ); - if( pixbuf == NULL ) { - ui_error( UI_ERROR_ERROR, "Failed to load keyboard image" ); - return 1; - } - - dialog = gtkstock_dialog_new( "Fuse - Keyboard", - G_CALLBACK( gtk_widget_hide ) ); - - content_area = gtk_dialog_get_content_area( GTK_DIALOG( dialog ) ); - -#if !GTK_CHECK_VERSION( 3, 0, 0 ) - - GtkWidget *image = gtk_image_new(); - gtk_image_set_from_pixbuf( GTK_IMAGE( image ), pixbuf ); - gtk_container_add( GTK_CONTAINER( content_area ), image ); - - /* Stop users resizing this window */ - gtk_window_set_resizable( GTK_WINDOW( dialog ), FALSE ); - -#else - - GtkWidget *box = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 ); - gtk_container_add( GTK_CONTAINER( content_area ), box ); - - GtkWidget *drawing_area = gtk_drawing_area_new(); - gtk_widget_set_vexpand( drawing_area, TRUE ); - gtk_box_pack_start( GTK_BOX( box ), drawing_area, TRUE, TRUE, 0 ); - - g_signal_connect( G_OBJECT( drawing_area ), "draw", - G_CALLBACK( picture_draw ), NULL ); - g_signal_connect( G_OBJECT( drawing_area ), "size-allocate", - G_CALLBACK( picture_size_allocate ), NULL ); - - gtk_widget_set_size_request( GTK_WIDGET( drawing_area ), - gdk_pixbuf_get_width( pixbuf ), - gdk_pixbuf_get_height( pixbuf ) ); - -#endif /* #if !GTK_CHECK_VERSION( 3, 0, 0 ) */ - - gtkstock_create_close( dialog, NULL, G_CALLBACK( gtk_widget_hide ), - FALSE ); - - dialog_created = 1; - } - - gtk_widget_show_all( dialog ); - - return 0; -} diff --git a/fuse/ui/gtk/pixmaps.c b/fuse/ui/gtk/pixmaps.c deleted file mode 100644 index 34b8a7f..0000000 --- a/fuse/ui/gtk/pixmaps.c +++ /dev/null @@ -1,349 +0,0 @@ -/* pixmaps.c: icon pixmaps - Copyright (c) 2003-2005 Fredrick Meunier, Philip Kendall, Darren Salt - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include "gtkinternals.h" - -const char *gtkpixmap_tape_inactive[] = { -"27 17 13 1", -" c None", -". c #D5D5D5", -"+ c #7C7C7C", -"@ c #A5A5A5", -"# c #7F7F7F", -"$ c #979797", -"% c #DEDEDE", -"& c #F9F9F9", -"* c #626262", -"= c #F8F8F8", -"- c #636363", -"; c #616161", -"> c #6A6A6A", -"...........................", -".+.......................+.", -"..@@@@@@@@@@@@@@@@@@@@@@@..", -".@@@@@@@@@@@@@@@@@@@@@@@@@.", -".@@@@@@@@@@@@@@@@@@@@@@@@@.", -".@@@@@###############@@@@@.", -".@@@@$#%&%@*****@%&%#$@@@@.", -".@@@@#@&&=@-****@&&=@#@@@@.", -".@@@@$#%=%@*;***@%=%#$@@@@.", -".@@@@@###############@@@@@.", -".@@@@@@@@@@@@@@@@@@@@@@@@@.", -".@@@@@@@@@@@@@@@@@@@@@@@@@.", -".....>>>>>>>>>>>>>>>>>.....", -"....$>...............>$....", -"....>$...............$>....", -".+..>.................>..+.", -"....>.................>...."}; - -const char *gtkpixmap_tape_active[] = { -"27 17 13 1", -" c None", -". c #00D500", -"+ c #007C00", -"@ c #00A500", -"# c #007F00", -"$ c #009700", -"% c #00DE00", -"& c #00F900", -"* c #006200", -"= c #00F800", -"- c #006300", -"; c #006100", -"> c #006A00", -"...........................", -".+.......................+.", -"..@@@@@@@@@@@@@@@@@@@@@@@..", -".@@@@@@@@@@@@@@@@@@@@@@@@@.", -".@@@@@@@@@@@@@@@@@@@@@@@@@.", -".@@@@@###############@@@@@.", -".@@@@$#%&%@*****@%&%#$@@@@.", -".@@@@#@&&=@-****@&&=@#@@@@.", -".@@@@$#%=%@*;***@%=%#$@@@@.", -".@@@@@###############@@@@@.", -".@@@@@@@@@@@@@@@@@@@@@@@@@.", -".@@@@@@@@@@@@@@@@@@@@@@@@@.", -".....>>>>>>>>>>>>>>>>>.....", -"....$>...............>$....", -"....>$...............$>....", -".+..>.................>..+.", -"....>.................>...."}; - -const char *gtkpixmap_mdr_inactive[] = { -"15 20 6 1", -" c None", -". c #000000", -"+ c #686868", -"@ c #888888", -"# c #AFAFAF", -"$ c #D8D8D8", -"##+$$$$$$$$####", -"###+++..+++####", -"+##++++++++####", -"$+##+++++++####", -"$+#############", -"$+@##@@@@@##@@#", -"$+############@", -"+#############@", -"@#############@", -"@#############@", -"@#############@", -"@#############@", -"@#############@", -"@#############@", -"#@@@#######@@@#", -"###############", -"###############", -"+++++++++++++++", -"+++++++++++++++", -"+++++++++++++++"}; - -const char *gtkpixmap_mdr_active[] = { -"15 20 6 1", -" c None", -". c #000000", -"+ c #686868", -"@ c #008800", -"# c #00AF00", -"$ c #00D800", -"##+$$$$$$$$####", -"###+++..+++####", -"+##++++++++####", -"$+##+++++++####", -"$+#############", -"$+@##@@@@@##@@#", -"$+############@", -"+#############@", -"@#############@", -"@#############@", -"@#############@", -"@#############@", -"@#############@", -"@#############@", -"#@@@#######@@@#", -"###############", -"###############", -"+++++++++++++++", -"+++++++++++++++", -"+++++++++++++++"}; - -const char *gtkpixmap_disk_inactive[] = { -"15 20 7 1", -" c None", -". c #A5A5A5", -"+ c #A6A6A6", -"@ c #6A6A6A", -"# c #696969", -"$ c #DFDFDF", -"% c #F9F9F9", -"..+.+++++..++++", -"+++++.+@.+.+.+.", -"+++.+..@..+.+.+", -"++.++++@+.++..+", -"...++..#+++..+.", -"++.+++.@++.+.+.", -"+.++.+.#.+++.++", -"+......+....+++", -"+.++..+..+.++++", -".++.++$%$+.+.+.", -".+.++.%%%+..++.", -"..+...$%$..+++.", -"+..+..+++++++..", -"++..+...++.+...", -"+++.++.++......", -"..@#@@###@#@#++", -"++@#@@@@@@##@..", -"+.@#@#@@@##@@.+", -"++@@@@@@@#@@#..", -"..##@#@@@@#@#.+"}; - -const char *gtkpixmap_disk_active[] = { -"15 20 7 1", -" c None", -". c #00A500", -"+ c #00A600", -"@ c #006A00", -"# c #006900", -"$ c #00DF00", -"% c #00F900", -"..+.+++++..++++", -"+++++.+@.+.+.+.", -"+++.+..@..+.+.+", -"++.++++@+.++..+", -"...++..#+++..+.", -"++.+++.@++.+.+.", -"+.++.+.#.+++.++", -"+......+....+++", -"+.++..+..+.++++", -".++.++$%$+.+.+.", -".+.++.%%%+..++.", -"..+...$%$..+++.", -"+..+..+++++++..", -"++..+...++.+...", -"+++.++.++......", -"..@#@@###@#@#++", -"++@#@@@@@@##@..", -"+.@#@#@@@##@@.+", -"++@@@@@@@#@@#..", -"..##@#@@@@#@#.+"}; - -const char *gtkpixmap_pause_inactive[] = { -"30 21 7 1", -" c None", -". c #6C6C6C", -"+ c #6A6A6A", -"@ c #6D6D6D", -"# c #6E6E6E", -"$ c #696969", -"% c #6B6B6B", -" .+ @# ", -" #$$+ %$$# ", -" +$# #$$ ", -" @$# .+ ", -" $$$ #$$+ .+ @# ", -" .$@ #+$. %$# #$$+ %$$# ", -" #$$$$+ +$# #$$ ", -" $$$$$$. @$# .+ ", -" @$$$$$$$ $$$ #$$+", -" +$$$$$$$ .$@ #+$. %$#", -" $$$$$$$$# #$$$$+ ", -" $$$$$$$$# $$$$$$. ", -" +$$$$$$$ @$$$$$$$ ", -" #$$$$$$$ +$$$$$$$ ", -" $$$$$$@ $$$$$$$$# ", -" #$$$$+ $$$$$$$$# ", -" %$@ +$$$$$$$ ", -" #$$$$$$$ ", -" $$$$$$@ ", -" #$$$$+ ", -" %$@ "}; - -const char *gtkpixmap_pause_active[] = { -"30 21 7 1", -" c None", -". c #D80000", -"+ c #D40000", -"@ c #DA0000", -"# c #DC0000", -"$ c #D20000", -"% c #D60000", -" .+ @# ", -" #$$+ %$$# ", -" +$# #$$ ", -" @$# .+ ", -" $$$ #$$+ .+ @# ", -" .$@ #+$. %$# #$$+ %$$# ", -" #$$$$+ +$# #$$ ", -" $$$$$$. @$# .+ ", -" @$$$$$$$ $$$ #$$+", -" +$$$$$$$ .$@ #+$. %$#", -" $$$$$$$$# #$$$$+ ", -" $$$$$$$$# $$$$$$. ", -" +$$$$$$$ @$$$$$$$ ", -" #$$$$$$$ +$$$$$$$ ", -" $$$$$$@ $$$$$$$$# ", -" #$$$$+ $$$$$$$$# ", -" %$@ +$$$$$$$ ", -" #$$$$$$$ ", -" $$$$$$@ ", -" #$$$$+ ", -" %$@ "}; - -const char *gtkpixmap_tape_marker[] = { -"8 16 2 1", -" c None", -". c #212FC6", -". ", -".. ", -"... ", -".... ", -"..... ", -"...... ", -"....... ", -"........", -"........", -"....... ", -"...... ", -"..... ", -".... ", -"... ", -".. ", -". "}; - -const char *gtkpixmap_mouse_inactive[] = { -"14 21 4 1", -" c None", -"# c #6C6C6C", -"+ c #A0A0A0", -". c #FFFFFF", -" .. ", -" .. ", -" +####++####+ ", -" #####++##### ", -" ####++++#### ", -" ####+##+#### ", -" ####+##+#### ", -" ####+##+#### ", -" ####+##+#### ", -" ####+##+#### ", -" ++++++++++++ ", -" ############ ", -" ############ ", -" ############ ", -" ############ ", -" ############ ", -" ############ ", -" ############ ", -" +##########+ ", -" +##########+ ", -" ++######++ "}; - -const char *gtkpixmap_mouse_active[] = { -"14 21 4 1", -" c None", -"# c #0000D0", -"+ c #6C6CD0", -". c #FFFFFF", -" .. ", -" .. ", -" +####++####+ ", -" #####++##### ", -" ####++++#### ", -" ####+##+#### ", -" ####+##+#### ", -" ####+##+#### ", -" ####+##+#### ", -" ####+##+#### ", -" ++++++++++++ ", -" ############ ", -" ############ ", -" ############ ", -" ############ ", -" ############ ", -" ############ ", -" ############ ", -" +##########+ ", -" +##########+ ", -" ++######++ "}; diff --git a/fuse/ui/gtk/pokefinder.c b/fuse/ui/gtk/pokefinder.c deleted file mode 100644 index 1d6c93d..0000000 --- a/fuse/ui/gtk/pokefinder.c +++ /dev/null @@ -1,332 +0,0 @@ -/* pokefinder.c: GTK interface to the poke finder - Copyright (c) 2003-2015 Philip Kendall - Copyright (c) 2014 Sergio Baldoví - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include -#include - -#include "compat.h" -#include "debugger/debugger.h" -#include "gtkcompat.h" -#include "gtkinternals.h" -#include "menu.h" -#include "pokefinder/pokefinder.h" -#include "ui/ui.h" - -static int create_dialog( void ); -static void gtkui_pokefinder_incremented( GtkWidget *widget, - gpointer user_data GCC_UNUSED ); -static void gtkui_pokefinder_decremented( GtkWidget *widget, - gpointer user_data GCC_UNUSED ); -static void gtkui_pokefinder_search( GtkWidget *widget, gpointer user_data ); -static void gtkui_pokefinder_reset( GtkWidget *widget, gpointer user_data ); -static void gtkui_pokefinder_close( GtkWidget *widget, gpointer user_data ); -static gboolean delete_dialog( GtkWidget *widget, GdkEvent *event, - gpointer user_data ); -static void update_pokefinder( void ); -static void possible_click( GtkTreeView *treeview, GtkTreePath *path, - GtkTreeViewColumn *col, gpointer user_data ); - -static int dialog_created = 0; - -static GtkWidget - *dialog, /* The dialog box itself */ - *count_label, /* The number of possible locations */ - *location_list; /* The list view of possible locations */ - -static GtkTreeModel *location_model; /* The data of possible locations */ - -/* The possible locations */ - -#define MAX_POSSIBLE 20 - -int possible_page[ MAX_POSSIBLE ]; -libspectrum_word possible_offset[ MAX_POSSIBLE ]; - -/* List columns */ -enum -{ - COL_PAGE = 0, - COL_OFFSET, - NUM_COLS -}; - -void -menu_machine_pokefinder( GtkAction *gtk_action GCC_UNUSED, - gpointer data GCC_UNUSED ) -{ - int error; - - if( !dialog_created ) { - error = create_dialog(); if( error ) return; - } - - gtk_widget_show_all( dialog ); - update_pokefinder(); -} - -static GtkWidget * -create_location_list( void ) -{ - GtkWidget *view; - GtkCellRenderer *renderer; - GtkListStore *store; - - view = gtk_tree_view_new(); - - /* Add columns */ - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( view ), - -1, - "Page", - renderer, - "text", COL_PAGE, - NULL ); - - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( view ), - -1, - "Offset", - renderer, - "text", COL_OFFSET, - NULL ); - - /* Create data model */ - store = gtk_list_store_new( NUM_COLS, G_TYPE_STRING, G_TYPE_STRING ); - - location_model = GTK_TREE_MODEL( store ); - gtk_tree_view_set_model( GTK_TREE_VIEW( view ), location_model ); - g_object_unref( location_model ); - - /* Activate breakpoints */ - g_signal_connect( G_OBJECT( view ), "row-activated", - G_CALLBACK( possible_click ), NULL ); - - return view; -} - -static int -create_dialog( void ) -{ - GtkWidget *hbox, *vbox, *label, *entry, *content_area; - GtkAccelGroup *accel_group; - - dialog = gtkstock_dialog_new( "Fuse - Poke Finder", - G_CALLBACK( delete_dialog ) ); - - hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ); - content_area = gtk_dialog_get_content_area( GTK_DIALOG( dialog ) ); - gtk_box_pack_start( GTK_BOX( content_area ), hbox, TRUE, TRUE, 0 ); - - label = gtk_label_new( "Search for:" ); - gtk_box_pack_start( GTK_BOX( hbox ), label, TRUE, TRUE, 5 ); - - entry = gtk_entry_new(); - g_signal_connect( G_OBJECT( entry ), "activate", - G_CALLBACK( gtkui_pokefinder_search ), NULL ); - gtk_box_pack_start( GTK_BOX( hbox ), entry, TRUE, TRUE, 5 ); - - vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 ); - gtk_box_pack_start( GTK_BOX( hbox ), vbox, TRUE, TRUE, 5 ); - - count_label = gtk_label_new( "" ); - gtk_box_pack_start( GTK_BOX( vbox ), count_label, TRUE, TRUE, 5 ); - - location_list = create_location_list(); - gtk_box_pack_start( GTK_BOX( vbox ), location_list, TRUE, TRUE, 5 ); - - { - static gtkstock_button btn[] = { - { "Incremented", G_CALLBACK( gtkui_pokefinder_incremented ), NULL, NULL, 0, 0, 0, 0, GTK_RESPONSE_NONE }, - { "Decremented", G_CALLBACK( gtkui_pokefinder_decremented ), NULL, NULL, 0, 0, 0, 0, GTK_RESPONSE_NONE }, - { "!Search", G_CALLBACK( gtkui_pokefinder_search ), NULL, NULL, GDK_KEY_Return, 0, 0, 0, GTK_RESPONSE_NONE }, - { "Reset", G_CALLBACK( gtkui_pokefinder_reset ), NULL, NULL, 0, 0, 0, 0, GTK_RESPONSE_NONE } - }; - btn[2].actiondata = G_OBJECT( entry ); - accel_group = gtkstock_create_buttons( dialog, NULL, btn, - ARRAY_SIZE( btn ) ); - gtkstock_create_close( dialog, accel_group, - G_CALLBACK( gtkui_pokefinder_close ), TRUE ); - } - - /* Users shouldn't be able to resize this window */ - gtk_window_set_resizable( GTK_WINDOW( dialog ), FALSE ); - - dialog_created = 1; - - return 0; -} - -static void -gtkui_pokefinder_incremented( GtkWidget *widget GCC_UNUSED, - gpointer user_data GCC_UNUSED ) -{ - pokefinder_incremented(); - update_pokefinder(); -} - -static void -gtkui_pokefinder_decremented( GtkWidget *widget GCC_UNUSED, - gpointer user_data GCC_UNUSED ) -{ - pokefinder_decremented(); - update_pokefinder(); -} - -static void -gtkui_pokefinder_search( GtkWidget *widget, gpointer user_data GCC_UNUSED ) -{ - long value; - const gchar *entry; - char *endptr; - int base; - - errno = 0; - entry = gtk_entry_get_text( GTK_ENTRY( widget ) ); - base = ( g_str_has_prefix( entry, "0x" ) )? 16 : 10; - value = strtol( entry, &endptr, base ); - - if( errno != 0 || value < 0 || value > 255 || endptr == entry ) { - ui_error( UI_ERROR_ERROR, "Invalid value: use an integer from 0 to 255" ); - return; - } - - pokefinder_search( value ); - update_pokefinder(); -} - -static void -gtkui_pokefinder_reset( GtkWidget *widget GCC_UNUSED, - gpointer user_data GCC_UNUSED) -{ - pokefinder_clear(); - update_pokefinder(); -} - -static gboolean -delete_dialog( GtkWidget *widget, GdkEvent *event GCC_UNUSED, - gpointer user_data ) -{ - gtkui_pokefinder_close( widget, user_data ); - return TRUE; -} - -static void -gtkui_pokefinder_close( GtkWidget *widget, gpointer user_data GCC_UNUSED ) -{ - gtk_widget_hide( widget ); -} - -static gboolean -widget_delayed_show( GtkWidget *item ) -{ - gtk_widget_show( item ); - - return FALSE; -} - -static void -update_pokefinder( void ) -{ - size_t page, offset, bank, bank_offset; - gchar buffer[256], *possible_text[2] = { &buffer[0], &buffer[128] }; - GtkTreeIter iter; - - gtk_list_store_clear( GTK_LIST_STORE( location_model ) ); - - if( pokefinder_count && pokefinder_count <= MAX_POSSIBLE ) { - - size_t which; - - which = 0; - - for( page = 0; page < MEMORY_PAGES_IN_16K * SPECTRUM_RAM_PAGES; page++ ) { - memory_page *mapping = &memory_map_ram[page]; - bank = mapping->page_num; - - for( offset = 0; offset < MEMORY_PAGE_SIZE; offset++ ) - if( ! (pokefinder_impossible[page][offset/8] & 1 << (offset & 7)) ) { - bank_offset = mapping->offset + offset; - - possible_page[ which ] = bank; - possible_offset[ which ] = bank_offset; - which++; - - snprintf( possible_text[0], 128, "%lu", (unsigned long)bank ); - snprintf( possible_text[1], 128, "0x%04X", (unsigned)bank_offset ); - - /* Append a new row and fill data */ - gtk_list_store_append( GTK_LIST_STORE( location_model ), &iter ); - gtk_list_store_set( GTK_LIST_STORE( location_model ), &iter, - COL_PAGE, possible_text[0], - COL_OFFSET, possible_text[1], - -1 ); - } - } - - /* Show widget when the GtkTreeView has been filled with data. Fix an empty - list on GTK 3.10 (and maybe other versions) */ - g_idle_add( (GSourceFunc)widget_delayed_show, location_list ); - - } else { - gtk_widget_hide( location_list ); - } - - snprintf( buffer, 256, "Possible locations: %lu", - (unsigned long)pokefinder_count ); - gtk_label_set_text( GTK_LABEL( count_label ), buffer ); -} - -static void -possible_click( GtkTreeView *treeview GCC_UNUSED, GtkTreePath *path, - GtkTreeViewColumn *col GCC_UNUSED, - gpointer user_data GCC_UNUSED ) -{ - int error, *indices, row; - - /* Get selected row via double-clicks or keyboard */ - indices = gtk_tree_path_get_indices( path ); - if( !indices ) return; - row = indices[0]; - - error = debugger_breakpoint_add_address( - DEBUGGER_BREAKPOINT_TYPE_WRITE, memory_source_ram, possible_page[ row ], - possible_offset[ row ], 0, DEBUGGER_BREAKPOINT_LIFE_PERMANENT, NULL - ); - if( error ) return; - - ui_debugger_update(); -} - -void -gtkui_pokefinder_clear( void ) -{ - pokefinder_clear(); - if( dialog_created ) update_pokefinder(); -} diff --git a/fuse/ui/gtk/pokemem.c b/fuse/ui/gtk/pokemem.c deleted file mode 100644 index f2cc630..0000000 --- a/fuse/ui/gtk/pokemem.c +++ /dev/null @@ -1,599 +0,0 @@ -/* pokemem.c: GTK interface that handles pok files - Copyright (c) 2011-2015 Philip Kendall, Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include -#include -#include -#include - -#include -#include - -#include "fuse.h" -#include "gtkcompat.h" -#include "gtkinternals.h" -#include "menu.h" -#include "pokefinder/pokemem.h" -#include "ui/ui.h" - -enum -{ - COL_CHECK = 0, - COL_NAME, - COL_VALUE, - COL_TRAINER, - COL_ENABLED, - COL_EDITABLE, - COL_INCONSISTENT, - NUM_COLS -}; - -static GtkWidget - *dialog, /* The dialog box itself */ - *poke_list, /* The list of possible pokes */ - *bank, /* Entries for custom poke */ - *address, - *value; - -void create_dialog( void ); -void create_and_fill_treeview( void ); -static void pokemem_close( GtkWidget *widget, gpointer user_data ); -static void pokemem_update_list( GtkWidget *widget, gpointer user_data ); -gboolean pokemem_update_trainer( GtkTreeModel *model, GtkTreePath *path, - GtkTreeIter *iter, gpointer data ); -static void pokemem_add_custom_poke( GtkWidget *widget, gpointer user_data ); -static void trainer_add( gpointer data, gpointer user_data ); - -void entry_validate_digit( GtkEntry *entry, const gchar *text, gint length, - gint *position, gpointer data ); -void entry_validate_address( GtkEntry *entry, const gchar *text, gint length, - gint *position, gpointer data ); - -void row_toggled_callback( GtkCellRendererToggle *cell, gchar *path_string, - gpointer user_data ); - -static gboolean custom_value_edit( GtkTreeView *tree ); -void custom_value_changed( GtkCellRendererText *cell, gchar *path_string, - gchar *new_text, gpointer user_data ); - -void -menu_machine_pokememory( GtkAction *gtk_action GCC_UNUSED, - gpointer data GCC_UNUSED ) -{ - fuse_emulation_pause(); - - pokemem_autoload_pokfile(); - create_dialog(); - - fuse_emulation_unpause(); -} - -void -ui_pokemem_selector( const char *filename ) -{ - fuse_emulation_pause(); - - pokemem_read_from_file( filename ); - create_dialog(); - - fuse_emulation_unpause(); -} - -void -create_dialog( void ) -{ - GtkWidget *hbox, *vbox, *label, *scroll; - GtkAccelGroup *accel_group; - - dialog = gtkstock_dialog_new( "Fuse - Poke Memory", - G_CALLBACK( pokemem_close ) ); - - vbox = gtk_dialog_get_content_area( GTK_DIALOG( dialog ) ); - - /* Keyboard shortcuts */ - accel_group = gtk_accel_group_new(); - gtk_window_add_accel_group( GTK_WINDOW( dialog ), accel_group ); - - hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ); - gtk_box_pack_start( GTK_BOX( vbox ), hbox, TRUE, TRUE, 5 ); - - /* Bank */ - label = gtk_label_new( "Bank:" ); - bank = gtk_entry_new(); - gtk_entry_set_width_chars( GTK_ENTRY( bank ), 7 ); - gtk_entry_set_max_length( GTK_ENTRY( bank ), 1 ); - g_signal_connect( G_OBJECT( bank ), "activate", - G_CALLBACK( pokemem_add_custom_poke ), NULL ); - g_signal_connect( G_OBJECT( bank ), "insert_text", - G_CALLBACK( entry_validate_digit ), NULL ); - gtk_box_pack_start( GTK_BOX( hbox ), label, TRUE, TRUE, 5 ); - gtk_box_pack_start( GTK_BOX( hbox ), bank, TRUE, TRUE, 5 ); - - /* Address */ - label = gtk_label_new( "Address:" ); - address = gtk_entry_new(); - gtk_entry_set_width_chars( GTK_ENTRY( address ), 7 ); - gtk_entry_set_max_length( GTK_ENTRY( address ), 6 ); - g_signal_connect( G_OBJECT( address ), "activate", - G_CALLBACK( pokemem_add_custom_poke ), NULL ); - g_signal_connect( G_OBJECT( address ), "insert_text", - G_CALLBACK( entry_validate_address ), NULL ); - gtk_box_pack_start( GTK_BOX( hbox ), label, TRUE, TRUE, 5 ); - gtk_box_pack_start( GTK_BOX( hbox ), address, TRUE, TRUE, 5 ); - - /* Value */ - label = gtk_label_new( "Value:" ); - value = gtk_entry_new(); - gtk_entry_set_width_chars( GTK_ENTRY( value ), 7 ); - gtk_entry_set_max_length( GTK_ENTRY( value ), 3 ); - g_signal_connect( G_OBJECT( value ), "activate", - G_CALLBACK( pokemem_add_custom_poke ), NULL ); - g_signal_connect( G_OBJECT( value ), "insert_text", - G_CALLBACK( entry_validate_digit ), NULL ); - gtk_box_pack_start( GTK_BOX( hbox ), label, TRUE, TRUE, 5 ); - gtk_box_pack_start( GTK_BOX( hbox ), value, TRUE, TRUE, 5 ); - - /* Create Add button for custom pokes */ - static const gtkstock_button - add = { "_Add", G_CALLBACK( pokemem_add_custom_poke ), NULL, NULL, - 0, 0, 0, 0, GTK_RESPONSE_NONE }; - gtkstock_create_button( GTK_WIDGET( hbox ), accel_group, &add ); - - label = gtk_label_new( "Choose active POKES:" ); - gtk_box_pack_start( GTK_BOX( vbox ), label, TRUE, TRUE, 5 ); - - /* Create list widget */ - create_and_fill_treeview(); - scroll = gtk_scrolled_window_new( NULL, NULL ); - - /* Adjust size for list */ -#if !GTK_CHECK_VERSION( 3, 0, 0 ) - gtk_widget_set_size_request( GTK_WIDGET( poke_list ), -1, 250 ); -#else - gtk_scrolled_window_set_min_content_height( GTK_SCROLLED_WINDOW( scroll ), 250 ); -#endif /* #if !GTK_CHECK_VERSION( 3, 0, 0 ) */ - - gtk_container_add( GTK_CONTAINER( scroll ), GTK_WIDGET( poke_list ) ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( scroll ), TRUE, TRUE, 5 ); - - /* Create and add the actions buttons to the dialog box */ - gtkstock_create_ok_cancel( dialog, accel_group, - G_CALLBACK( pokemem_update_list ), - (gpointer) &dialog, - G_CALLBACK( pokemem_close ), - G_CALLBACK( pokemem_close ) ); - - /* Users shouldn't be able to resize this window */ - gtk_window_set_resizable( GTK_WINDOW( dialog ), FALSE ); - - /* Process the dialog */ - gtk_widget_show_all( dialog ); - gtk_main(); -} - -void -create_and_fill_treeview( void ) -{ - GtkListStore *store; - GtkCellRenderer *renderer; - GtkTreeModel *model; - - poke_list = gtk_tree_view_new(); - -#if !GTK_CHECK_VERSION( 3, 0, 0 ) - gtk_tree_view_set_rules_hint( GTK_TREE_VIEW( poke_list ), TRUE ); -#endif - - store = gtk_list_store_new( NUM_COLS, G_TYPE_BOOLEAN, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN, - G_TYPE_BOOLEAN, G_TYPE_BOOLEAN ); - - renderer = gtk_cell_renderer_toggle_new(); - - /* First column, checkbox */ - g_signal_connect( renderer, "toggled", - (GCallback) row_toggled_callback, - (gpointer) GTK_TREE_MODEL( store ) ); - - gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( poke_list ), - -1, - "Active", - renderer, - "active", COL_CHECK, - "activatable", COL_ENABLED, - "inconsistent", COL_INCONSISTENT, - NULL ); - - /* Second column, name */ - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( poke_list ), - -1, - "Trainer", - renderer, - "text", COL_NAME, - NULL ); - - /* Third column, optional value */ - renderer = gtk_cell_renderer_text_new(); - g_signal_connect( renderer, "edited", (GCallback)custom_value_changed, - (gpointer) GTK_TREE_MODEL( store ) ); - - gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( poke_list ), - -1, - "Value", - renderer, - "text", COL_VALUE, - "editable", COL_EDITABLE, - NULL); - - /* Create and fill model */ - if( trainer_list ) { - g_slist_foreach( trainer_list, trainer_add, store ); - } - model = GTK_TREE_MODEL( store ); - - gtk_tree_view_set_model( GTK_TREE_VIEW( poke_list ), model ); - - g_object_unref( model ); -} - -static void -trainer_add( gpointer data, gpointer user_data ) -{ - gchar *val = NULL; - GtkListStore *store = user_data; - GtkTreeIter iter; - trainer_t *trainer = data; - - if( !trainer ) return; - - if( trainer->ask_value ) - val = g_strdup_printf( "%d", trainer->value ); - - /* Append a new row and fill data */ - gtk_list_store_append( store, &iter ); - gtk_list_store_set( store, &iter, - COL_CHECK, trainer->active, - COL_NAME, trainer->name, - COL_VALUE, ( trainer->ask_value )? val : NULL, - COL_TRAINER, trainer, - COL_ENABLED, !trainer->disabled, - COL_EDITABLE, ( !trainer->disabled && !trainer->active - && trainer->ask_value ), - COL_INCONSISTENT, ( trainer->disabled && !trainer->active ), - -1); - - g_free( val ); -} - -static void -pokemem_close( GtkWidget *widget, gpointer user_data GCC_UNUSED ) -{ - gtkui_destroy_widget_and_quit( widget, NULL ); -} - -static void -pokemem_update_list( GtkWidget *widget GCC_UNUSED, - gpointer user_data GCC_UNUSED ) -{ - GtkTreeModel *model; - - model = gtk_tree_view_get_model( GTK_TREE_VIEW( poke_list ) ); - if( model ) { - gtk_tree_model_foreach( model, pokemem_update_trainer, NULL ); - } - - gtkui_destroy_widget_and_quit( dialog, NULL ); -} - -gboolean -pokemem_update_trainer( GtkTreeModel *model, GtkTreePath *path GCC_UNUSED, - GtkTreeIter *iter, gpointer data GCC_UNUSED ) -{ - gboolean selected; - trainer_t *trainer; - - gtk_tree_model_get( model, iter, - COL_CHECK, &selected, - COL_TRAINER, &trainer, - -1); - - if( selected ) { - pokemem_trainer_activate( trainer ); - } else { - pokemem_trainer_deactivate( trainer ); - } - - return FALSE; -} - -static void -pokemem_add_custom_poke( GtkWidget *widget GCC_UNUSED, - gpointer user_data GCC_UNUSED ) -{ - long b, a, v; - const gchar *entry; - char *endptr; - int base; - trainer_t *trainer; - GtkListStore *store; - - if( gtk_entry_get_text_length( GTK_ENTRY( address ) ) == 0 && - gtk_entry_get_text_length( GTK_ENTRY( value ) ) == 0 ) { - return; - } - - /* Parse bank */ - entry = gtk_entry_get_text( GTK_ENTRY( bank ) ); - errno = 0; - b = strtol( entry, &endptr, 10 ); - if( errno || b < 0 || b > 8 ) { - ui_error( UI_ERROR_ERROR, "Invalid bank: use an integer from 0 to 8" ); - gtk_widget_grab_focus( bank ); - return; - } - - if( endptr == entry ) b = 8; /* ignore bank by default */ - - /* Parse address */ - entry = gtk_entry_get_text( GTK_ENTRY( address ) ); - errno = 0; - base = ( g_str_has_prefix( entry, "0x" ) )? 16 : 10; - a = strtol( entry, &endptr, base ); - - if( errno || a < 0 || a > 65535 || endptr == entry ) { - ui_error( UI_ERROR_ERROR, - "Invalid address: use an integer from 0 to 65535" ); - gtk_widget_grab_focus( address ); - return; - } - - if( b == 8 && a < 16384 ) { - ui_error( UI_ERROR_ERROR, - "Invalid address: use an integer from 16384 to 65535" ); - gtk_widget_grab_focus( address ); - return; - } - - /* Parse value */ - entry = gtk_entry_get_text( GTK_ENTRY( value ) ); - errno = 0; - v = strtol( entry, &endptr, 10 ); - - if( errno || v < 0 || v > 256 || endptr == entry ) { - ui_error( UI_ERROR_ERROR, "Invalid value: use an integer from 0 to 256" ); - gtk_widget_grab_focus( value ); - return; - } - - /* Update store and view */ - trainer = pokemem_trainer_list_add( b, a, v ); - if( !trainer ) { - ui_error( UI_ERROR_ERROR, "Cannot add trainer" ); - return; - } - - store = GTK_LIST_STORE( gtk_tree_view_get_model( - GTK_TREE_VIEW( poke_list ) ) ); - trainer_add( trainer, store ); - - /* Mark custom trainer for activate */ - GtkTreeModel *model; - GtkTreePath *path; - GtkTreeIter iter; - int rows; - - if( !trainer->active && !trainer->disabled ) { - model = gtk_tree_view_get_model( GTK_TREE_VIEW( poke_list ) ); - rows = gtk_tree_model_iter_n_children( model, NULL ); - path = gtk_tree_path_new_from_indices( rows - 1, -1 ); - gtk_tree_model_get_iter( model, &iter, path ); - gtk_list_store_set( GTK_LIST_STORE( model ), &iter, COL_CHECK, TRUE, -1 ); - gtk_tree_path_free( path ); - } - - /* Clear custom fields */ - gtk_editable_delete_text( GTK_EDITABLE( bank ), 0, -1 ); - gtk_editable_delete_text( GTK_EDITABLE( address ), 0, -1 ); - gtk_editable_delete_text( GTK_EDITABLE( value ), 0, -1 ); - gtk_widget_grab_focus( address ); -} - -void -entry_validate_digit( GtkEntry *entry, const gchar *text, gint length, - gint *position, gpointer data ) -{ - int i, count = 0; - GtkEditable *editable = GTK_EDITABLE( entry ); - gchar *result = g_new( gchar, length ); - - /* Validate decimal and fill buffer to insert */ - for( i = 0; i < length; i++ ) { - if( !isdigit( text[i] ) ) continue; - - result[ count++ ] = text[i]; - } - - /* Insert only validated text */ - if( count > 0 ) { - g_signal_handlers_block_by_func( G_OBJECT( editable ), - G_CALLBACK( entry_validate_digit ), - data ); - gtk_editable_insert_text( editable, result, count, position ); - g_signal_handlers_unblock_by_func( G_OBJECT( editable ), - G_CALLBACK( entry_validate_digit ), - data ); - } - g_signal_stop_emission_by_name( G_OBJECT( editable ), "insert_text" ); - - g_free( result ); -} - -void -entry_validate_address( GtkEntry *entry, const gchar *text, gint length, - gint *position, gpointer data ) -{ - int i, is_valid, is_hex; - size_t n, prev_length, max_length, count = 0; - GtkEditable *editable = GTK_EDITABLE( entry ); - GString *full_text; - gchar *result = NULL; - - /* Validate hex or decimal number */ - full_text = g_string_new( gtk_entry_get_text( entry ) ); - prev_length = full_text->len; - full_text = g_string_insert_len( full_text, *position, text, length ); - is_valid = 1; - is_hex = 0; - - for( n = 0; n < full_text->len && is_valid; n++ ) { - - switch( n ) { - case 0: - is_valid = isdigit( full_text->str[n] ); - break; - - case 1: - if( full_text->str[n] == 'x' ) { - if( full_text->str[0] == '0' ) is_hex = 1; - is_valid = is_hex; - } else { - is_valid = isdigit( full_text->str[n] ); - } - break; - - default: - is_valid = ( is_hex )? isxdigit( full_text->str[n] ) : - isdigit( full_text->str[n] ); - } - - } - g_string_free( full_text, TRUE ); - - /* Fill buffer to insert */ - if( is_valid ) { - max_length = ( is_hex )? 6 : 5; - result = g_new( gchar, length ); - - for( i = 0; i < length && i + prev_length < max_length; i++ ) { - result[ count++ ] = text[i]; - } - } - - /* Insert only validated text */ - if( count > 0 ) { - g_signal_handlers_block_by_func( G_OBJECT( editable ), - G_CALLBACK( entry_validate_address ), - data ); - gtk_editable_insert_text( editable, result, count, position ); - g_signal_handlers_unblock_by_func( G_OBJECT( editable ), - G_CALLBACK( entry_validate_address ), - data ); - } - - g_signal_stop_emission_by_name( G_OBJECT( editable ), "insert_text" ); - g_free( result ); -} - -void -row_toggled_callback( GtkCellRendererToggle *cell GCC_UNUSED, - gchar *path_string, gpointer user_data ) -{ - GtkTreeIter iter; - GtkTreeModel *model = user_data; - GValue val, gtrainer; - trainer_t *trainer; - gboolean flag; - - /* Toggle current selection */ - gtk_tree_model_get_iter_from_string( model, &iter, path_string ); - memset( &val, 0, sizeof( val ) ); - gtk_tree_model_get_value( model, &iter, COL_CHECK, &val ); - flag = !g_value_get_boolean( &val ); - g_value_unset( &val ); - gtk_list_store_set( GTK_LIST_STORE( model ), &iter, COL_CHECK, flag, -1 ); - - /* Request user for custom value */ - if( flag ) { - memset( >rainer, 0, sizeof( gtrainer ) ); - gtk_tree_model_get_value( model, &iter, COL_TRAINER, >rainer ); - trainer = (trainer_t *)g_value_get_pointer( >rainer ); - g_value_unset( >rainer ); - - if( trainer->ask_value ) { - g_idle_add( (GSourceFunc)custom_value_edit, GTK_TREE_VIEW( poke_list ) ); - } - } -} - -static gboolean -custom_value_edit( GtkTreeView *tree ) -{ - GtkTreePath *path; - GtkTreeViewColumn *col, *col_current; - - gtk_tree_view_get_cursor( tree, &path, &col_current ); - if( !path || !col_current ) return FALSE; - - col = gtk_tree_view_get_column( tree, COL_VALUE ); - gtk_tree_view_set_cursor( tree, path, col, TRUE ); - gtk_tree_path_free( path ); - - return FALSE; -} - -void -custom_value_changed( GtkCellRendererText *cell GCC_UNUSED, gchar *path_string, - gchar *new_text, gpointer user_data ) -{ - GtkTreeModel *model = (GtkTreeModel *)user_data; - GtkTreeIter iter; - GValue val; - gchar *str_value; - trainer_t *trainer; - long v; - char *endptr; - - if( gtk_tree_model_get_iter_from_string( model, &iter, path_string ) ) { - memset( &val, 0, sizeof( val ) ); - - gtk_tree_model_get_value( model, &iter, COL_TRAINER, &val ); - trainer = (trainer_t *)g_value_get_pointer( &val ); - g_value_unset( &val ); - - errno = 0; - v = strtol( new_text, &endptr, 10 ); - - if( errno || v < 0 || v > 255 || endptr == new_text ) { - ui_error( UI_ERROR_ERROR, "Invalid value: use an integer from 0 to 255" ); - return; - } - - trainer->value = v; - str_value = g_strdup_printf( "%d", trainer->value ); - - gtk_list_store_set( GTK_LIST_STORE( model ), &iter, - COL_VALUE, str_value, -1); - g_free( str_value ); - } -} diff --git a/fuse/ui/gtk/rollback.c b/fuse/ui/gtk/rollback.c deleted file mode 100644 index 68cbf9b..0000000 --- a/fuse/ui/gtk/rollback.c +++ /dev/null @@ -1,155 +0,0 @@ -/* rollback.c: select a rollback point - Copyright (c) 2004 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include - -#include "fuse.h" -#include "gtkinternals.h" -#include "ui/ui.h" - -GtkWidget *dialog, *list; - -static int dialog_created = 0; -static int current_block; - -/* List columns */ -enum -{ - COL_SECONDS = 0, - NUM_COLS -}; - -static void -select_row( GtkButton *button GCC_UNUSED, gpointer user_data ) -{ - GtkTreePath *path; - GtkTreeView *view = user_data; - GtkTreeViewColumn *focus_column; - - current_block = -1; - - /* Get selected row */ - gtk_tree_view_get_cursor( GTK_TREE_VIEW( view ), &path, &focus_column ); - if( path ) { - int *indices = gtk_tree_path_get_indices( path ); - if( indices ) current_block = indices[0]; - gtk_tree_path_free( path ); - } -} - -static GtkWidget * -create_rollback_list( void ) -{ - GtkWidget *view; - GtkCellRenderer *renderer; - GtkTreeModel *model; - GtkListStore *store; - - view = gtk_tree_view_new(); - - /* Add columns */ - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( view ), - -1, - "Seconds", - renderer, - "text", COL_SECONDS, - NULL ); - - /* Create data model */ - store = gtk_list_store_new( NUM_COLS, G_TYPE_STRING ); - - model = GTK_TREE_MODEL( store ); - gtk_tree_view_set_model( GTK_TREE_VIEW( view ), model ); - g_object_unref( model ); - - return view; -} - -static int -create_dialog( void ) -{ - GtkWidget *content_area; - - dialog = gtkstock_dialog_new( "Fuse - Select Rollback Point", NULL ); - - list = create_rollback_list(); - - gtkstock_create_ok_cancel( dialog, NULL, G_CALLBACK( select_row ), list, - DEFAULT_DESTROY, DEFAULT_DESTROY ); - - content_area = gtk_dialog_get_content_area( GTK_DIALOG( dialog ) ); - gtk_box_pack_start( GTK_BOX( content_area ), list, TRUE, TRUE, 0 ); - - return 0; -} - -static int -update_list( GSList *points ) -{ - GtkTreeIter iter; - GtkTreeModel *model; - - model = gtk_tree_view_get_model( GTK_TREE_VIEW( list ) ); - - gtk_list_store_clear( GTK_LIST_STORE( model ) ); - - while( points ) { - gchar buffer[256]; - - snprintf( buffer, 256, "%.2f", GPOINTER_TO_INT( points->data ) / 50.0 ); - - /* Append a new row and fill data */ - gtk_list_store_append( GTK_LIST_STORE( model ), &iter ); - gtk_list_store_set( GTK_LIST_STORE( model ), &iter, - COL_SECONDS, buffer, - -1 ); - - points = points->next; - } - - return 0; -} - -int -ui_get_rollback_point( GSList *points ) -{ - fuse_emulation_pause(); - - if( !dialog_created ) - if( create_dialog() ) { fuse_emulation_unpause(); return -1; } - - if( update_list( points ) ) { fuse_emulation_unpause(); return -1; } - - current_block = -1; - - gtk_widget_show_all( dialog ); - - gtk_main(); - - fuse_emulation_unpause(); - - return current_block; -} diff --git a/fuse/ui/gtk/roms.c b/fuse/ui/gtk/roms.c deleted file mode 100644 index 700beb2..0000000 --- a/fuse/ui/gtk/roms.c +++ /dev/null @@ -1,161 +0,0 @@ -/* roms.c: ROM selector dialog box - Copyright (c) 2003-2004 Philip Kendall - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include -#include - -#include "compat.h" -#include "fuse.h" -#include "gtkcompat.h" -#include "gtkinternals.h" -#include "menu.h" -#include "settings.h" -#include "ui/ui.h" - -static void add_rom( GtkBox *parent, size_t start, gint row, - int is_peripheral ); -static void select_new_rom( GtkWidget *widget, gpointer data ); -static void roms_done( GtkButton *button, gpointer data ); - -/* The labels used to display the current ROMs */ -static GtkWidget *rom[ SETTINGS_ROM_COUNT ]; - -struct callback_info { - - size_t start, n; - int is_peripheral; - -}; - -int -menu_select_roms_with_title( const char *title, size_t start, size_t n, - int is_peripheral ) -{ - GtkWidget *dialog; - GtkBox *vbox; - - struct callback_info info; - - char buffer[ 256 ]; - size_t i; - - /* Firstly, stop emulation */ - fuse_emulation_pause(); - - /* Give me a new dialog box */ - snprintf( buffer, 256, "Fuse - Select ROMs - %s", title ); - dialog = gtkstock_dialog_new( buffer, NULL ); - - info.start = start; - info.n = n; - info.is_peripheral = is_peripheral; - - /* Create the OK and Cancel buttons */ - gtkstock_create_ok_cancel( dialog, NULL, G_CALLBACK( roms_done ), &info, - DEFAULT_DESTROY, DEFAULT_DESTROY ); - - /* And the current values of each of the ROMs */ - vbox = GTK_BOX( gtk_dialog_get_content_area( GTK_DIALOG( dialog ) ) ); - - gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - for( i = 0; i < n; i++ ) add_rom( vbox, start, i, is_peripheral ); - - /* Users shouldn't be able to resize this window */ - gtk_window_set_resizable( GTK_WINDOW( dialog ), FALSE ); - - /* Display the window */ - gtk_widget_show_all( dialog ); - - /* Process events until the window is done with */ - gtk_main(); - - /* And then carry on with emulation again */ - fuse_emulation_unpause(); - - return 0; -} - -static void -add_rom( GtkBox *parent, size_t start, gint row, int is_peripheral ) -{ - GtkWidget *frame, *hbox, *change_button; - char buffer[ 80 ], **setting; - - snprintf( buffer, 80, "ROM %d", row ); - frame = gtk_frame_new( buffer ); - gtk_box_pack_start( parent, frame, FALSE, FALSE, 2 ); - - hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 4 ); - gtk_container_set_border_width( GTK_CONTAINER( hbox ), 4 ); - gtk_container_add( GTK_CONTAINER( frame ), hbox ); - - setting = settings_get_rom_setting( &settings_current, start + row, - is_peripheral ); - rom[ row ] = gtk_entry_new(); - gtk_entry_set_text( GTK_ENTRY( rom[ row ] ), *setting ); - gtk_box_pack_start( GTK_BOX( hbox ), rom[ row ], FALSE, FALSE, 2 ); - - change_button = gtk_button_new_with_label( "Select..." ); - g_signal_connect( G_OBJECT( change_button ), "clicked", - G_CALLBACK( select_new_rom ), - rom[ row ] ); - gtk_box_pack_start( GTK_BOX( hbox ), change_button, FALSE, FALSE, 2 ); -} - -static void -select_new_rom( GtkWidget *widget GCC_UNUSED, gpointer data ) -{ - char *filename; - - GtkWidget *entry = data; - - filename = ui_get_open_filename( "Fuse - Select ROM" ); - if( !filename ) return; - - gtk_entry_set_text( GTK_ENTRY( entry ), filename ); -} - -static void -roms_done( GtkButton *button GCC_UNUSED, gpointer data ) -{ - size_t i; - - char **setting; const char *string; - - struct callback_info *info = data; - - for( i = 0; i < info->n; i++ ) { - - setting = settings_get_rom_setting( &settings_current, info->start + i, - info->is_peripheral ); - string = gtk_entry_get_text( GTK_ENTRY( rom[i] ) ); - - settings_set_string( setting, string ); - } -} diff --git a/fuse/ui/gtk/statusbar.c b/fuse/ui/gtk/statusbar.c deleted file mode 100644 index 36be3c7..0000000 --- a/fuse/ui/gtk/statusbar.c +++ /dev/null @@ -1,223 +0,0 @@ -/* statusbar.c: routines for updating the status bar - Copyright (c) 2003-2004 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include - -#include - -#include "gtkcompat.h" -#include "gtkinternals.h" -#include "ui/ui.h" - -static GtkWidget *status_bar; - -static GdkPixbuf - *pixbuf_tape_inactive, *pixbuf_tape_active, - *pixbuf_mdr_inactive, *pixbuf_mdr_active, - *pixbuf_disk_inactive, *pixbuf_disk_active, - *pixbuf_pause_inactive, *pixbuf_pause_active, - *pixbuf_mouse_inactive, *pixbuf_mouse_active; - -static GtkWidget - *microdrive_status, /* Is any microdrive motor running? */ - *disk_status, /* Is the disk motor running? */ - *mouse_status, /* Have we grabbed the mouse? */ - *pause_status, /* Is emulation paused (via the menu option)? */ - *tape_status, /* Is the tape running? */ - *speed_status, /* How fast are we running? */ - *machine_name; /* What machine is being emulated? */ - -int -gtkstatusbar_create( GtkBox *parent ) -{ - GtkWidget *separator; - - status_bar = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 5 ); - gtk_box_pack_start( parent, status_bar, FALSE, FALSE, 3 ); - - /* FIXME: unref these pixbuf on statusbar destroy */ - pixbuf_tape_inactive = - gdk_pixbuf_new_from_xpm_data( gtkpixmap_tape_inactive ); - pixbuf_tape_active = - gdk_pixbuf_new_from_xpm_data( gtkpixmap_tape_active ); - - pixbuf_mdr_inactive = - gdk_pixbuf_new_from_xpm_data( gtkpixmap_mdr_inactive ); - pixbuf_mdr_active = - gdk_pixbuf_new_from_xpm_data( gtkpixmap_mdr_active ); - - pixbuf_disk_inactive = - gdk_pixbuf_new_from_xpm_data( gtkpixmap_disk_inactive ); - pixbuf_disk_active = - gdk_pixbuf_new_from_xpm_data( gtkpixmap_disk_active ); - - pixbuf_pause_inactive = - gdk_pixbuf_new_from_xpm_data( gtkpixmap_pause_inactive ); - pixbuf_pause_active = - gdk_pixbuf_new_from_xpm_data( gtkpixmap_pause_active ); - - pixbuf_mouse_inactive = - gdk_pixbuf_new_from_xpm_data( gtkpixmap_mouse_inactive ); - pixbuf_mouse_active = - gdk_pixbuf_new_from_xpm_data( gtkpixmap_mouse_active ); - - speed_status = gtk_label_new( "100%" ); - gtk_label_set_width_chars( GTK_LABEL( speed_status ), 8 ); - gtk_box_pack_end( GTK_BOX( status_bar ), speed_status, FALSE, FALSE, 0 ); - - separator = gtk_separator_new( GTK_ORIENTATION_VERTICAL ); - gtk_box_pack_end( GTK_BOX( status_bar ), separator, FALSE, FALSE, 0 ); - - tape_status = gtk_image_new_from_pixbuf( pixbuf_tape_inactive ); - gtk_box_pack_end( GTK_BOX( status_bar ), tape_status, FALSE, FALSE, 0 ); - - microdrive_status = gtk_image_new_from_pixbuf( pixbuf_mdr_inactive ); - gtk_box_pack_end( GTK_BOX( status_bar ), microdrive_status, FALSE, FALSE, - 0 ); - - disk_status = gtk_image_new_from_pixbuf( pixbuf_disk_inactive ); - gtk_box_pack_end( GTK_BOX( status_bar ), disk_status, FALSE, FALSE, 0 ); - - pause_status = gtk_image_new_from_pixbuf( pixbuf_pause_inactive ); - gtk_box_pack_end( GTK_BOX( status_bar ), pause_status, FALSE, FALSE, 0 ); - - mouse_status = gtk_image_new_from_pixbuf( pixbuf_mouse_inactive ); - gtk_box_pack_end( GTK_BOX( status_bar ), mouse_status, FALSE, FALSE, 0 ); - - separator = gtk_separator_new( GTK_ORIENTATION_VERTICAL ); - gtk_box_pack_end( GTK_BOX( status_bar ), separator, FALSE, FALSE, 0 ); - - machine_name = gtk_label_new( NULL ); - gtk_box_pack_start( GTK_BOX( status_bar ), machine_name, FALSE, FALSE, 0 ); - - return 0; -} - -int -gtkstatusbar_get_height( void ) -{ - GtkAllocation alloc; - - gtk_widget_get_allocation( status_bar, &alloc ); - - return alloc.height + 6; /* status bar + vbox padding */ -} - -int -gtkstatusbar_set_visibility( int visible ) -{ - gtkdisplay_update_geometry(); - - if( visible ) { - gtk_widget_show( status_bar ); - } else { - gtk_widget_hide( status_bar ); - } - - return 0; -} - -void -gtkstatusbar_update_machine( const char *name ) -{ - gtk_label_set_text( GTK_LABEL( machine_name ), name ); -} - -int -ui_statusbar_update( ui_statusbar_item item, ui_statusbar_state state ) -{ - GdkPixbuf *which; - - switch( item ) { - - case UI_STATUSBAR_ITEM_DISK: - switch( state ) { - case UI_STATUSBAR_STATE_NOT_AVAILABLE: - gtk_widget_hide( disk_status ); break; - case UI_STATUSBAR_STATE_ACTIVE: - gtk_widget_show( disk_status ); - gtk_image_set_from_pixbuf( GTK_IMAGE( disk_status ), pixbuf_disk_active ); - break; - default: - gtk_widget_show( disk_status ); - gtk_image_set_from_pixbuf( GTK_IMAGE( disk_status ), - pixbuf_disk_inactive ); - break; - } - return 0; - - case UI_STATUSBAR_ITEM_MOUSE: - which = ( state == UI_STATUSBAR_STATE_ACTIVE ? - pixbuf_mouse_active : pixbuf_mouse_inactive ); - gtk_image_set_from_pixbuf( GTK_IMAGE( mouse_status ), which ); - return 0; - - case UI_STATUSBAR_ITEM_PAUSED: - which = ( state == UI_STATUSBAR_STATE_ACTIVE ? - pixbuf_pause_active : pixbuf_pause_inactive ); - gtk_image_set_from_pixbuf( GTK_IMAGE( pause_status ), which ); - return 0; - - case UI_STATUSBAR_ITEM_MICRODRIVE: - switch( state ) { - case UI_STATUSBAR_STATE_NOT_AVAILABLE: - gtk_widget_hide( microdrive_status ); break; - case UI_STATUSBAR_STATE_ACTIVE: - gtk_widget_show( microdrive_status ); - gtk_image_set_from_pixbuf( GTK_IMAGE( microdrive_status ), - pixbuf_mdr_active ); - break; - default: - gtk_widget_show( microdrive_status ); - gtk_image_set_from_pixbuf( GTK_IMAGE( microdrive_status ), - pixbuf_mdr_inactive ); - break; - } - return 0; - - case UI_STATUSBAR_ITEM_TAPE: - which = ( state == UI_STATUSBAR_STATE_ACTIVE ? - pixbuf_tape_active : pixbuf_tape_inactive ); - gtk_image_set_from_pixbuf( GTK_IMAGE( tape_status ), which ); - - return 0; - - } - - ui_error( UI_ERROR_ERROR, "Attempt to update unknown statusbar item %d", - item ); - return 1; -} - -int -ui_statusbar_update_speed( float speed ) -{ - char buffer[8]; - - snprintf( buffer, 8, "%3.0f%%", speed ); - gtk_label_set_text( GTK_LABEL( speed_status ), buffer ); - - return 0; -} diff --git a/fuse/ui/gtk/stock.c b/fuse/ui/gtk/stock.c deleted file mode 100644 index 201b2d2..0000000 --- a/fuse/ui/gtk/stock.c +++ /dev/null @@ -1,187 +0,0 @@ -/* stock.c: 'standard' GTK widgets etc - Copyright (c) 2004 Darren Salt, Philip Kendall - Copyright (c) 2015 Stuart Brady - Copyright (c) 2015 Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - Philip Kendall - -*/ - -#include - -#include - -#include -#include - -#include "compat.h" -#include "gtkcompat.h" -#include "gtkinternals.h" - -GtkAccelGroup* -gtkstock_add_accel_group( GtkWidget *widget ) -{ - GtkAccelGroup *accel = gtk_accel_group_new(); - gtk_window_add_accel_group( GTK_WINDOW( widget ), accel ); - return accel; -} - -static void -add_click( GtkWidget *btn, const gtkstock_button *button, GtkAccelGroup *accel, - guint key1, GdkModifierType mod1, guint key2, GdkModifierType mod2 ) -{ - if( button->shortcut ) { - if( button->shortcut != GDK_KEY_VoidSymbol ) - gtk_widget_add_accelerator( btn, "clicked", accel, button->shortcut, - button->modifier, 0 ); - } else if( key1 ) { - gtk_widget_add_accelerator( btn, "clicked", accel, key1, mod1, 0 ); - } - - if( button->shortcut_alt ) { - if( button->shortcut_alt != GDK_KEY_VoidSymbol ) - gtk_widget_add_accelerator( btn, "clicked", accel, button->shortcut_alt, - button->modifier_alt, 0 ); - } - else if( key2 ) { - gtk_widget_add_accelerator( btn, "clicked", accel, key2, mod2, 0 ); - } - -} - -GtkWidget* -gtkstock_create_button( GtkWidget *widget, GtkAccelGroup *accel, - const gtkstock_button *button ) -{ - GtkWidget *btn; - gboolean link_object = ( button->label[0] == '!' ); - const gchar *button_label = button->label + link_object; - - if( !accel ) accel = gtkstock_add_accel_group (widget); - - if( GTK_IS_DIALOG( widget ) ) { - btn = gtk_dialog_add_button( GTK_DIALOG( widget ), button_label, - button->response_id ); - } else { - btn = gtk_button_new_with_mnemonic( button_label ); - gtk_container_add( GTK_CONTAINER( widget ), btn ); - } - - if( button->action ) { - if( link_object ) { - g_signal_connect_swapped( G_OBJECT( btn ), "clicked", - button->action, - G_OBJECT( button->actiondata ) ); - } else { - g_signal_connect( G_OBJECT( btn ), "clicked", button->action, - button->actiondata ); - } - } - - if( button->destroy ) - g_signal_connect_swapped( G_OBJECT( btn ), "clicked", button->destroy, - G_OBJECT( widget ) ); - - GtkWidget *icon = NULL; - if( !strcmp( button->label, "_Close" ) ) - icon = gtk_image_new_from_icon_name( "window-close", GTK_ICON_SIZE_BUTTON ); - else if( !strcmp( button->label, "_Open" ) ) - icon = gtk_image_new_from_icon_name( "document-open",GTK_ICON_SIZE_BUTTON ); - else if( !strcmp( button->label, "_Save" ) ) - icon = gtk_image_new_from_icon_name( "document-save",GTK_ICON_SIZE_BUTTON ); - else if( !strcmp( button->label, "_Add" ) ) - icon = gtk_image_new_from_icon_name( "list-add", GTK_ICON_SIZE_BUTTON ); - -#if !GTK_CHECK_VERSION( 3, 0, 0 ) - /* Note: ok/cancel/yes/no icons are not covered by freedesktop's Icon Naming - Specification 0.8.90 */ - else if( !strcmp( button->label, "_OK" ) ) - icon = gtk_image_new_from_icon_name( GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON ); - else if( !strcmp( button->label, "_Cancel" ) ) - icon = gtk_image_new_from_icon_name( GTK_STOCK_CANCEL, - GTK_ICON_SIZE_BUTTON ); - else if( !strcmp( button->label, "_Yes" ) ) - icon = gtk_image_new_from_icon_name( GTK_STOCK_YES, GTK_ICON_SIZE_BUTTON ); - else if( !strcmp( button->label, "_No" ) ) - icon = gtk_image_new_from_icon_name( GTK_STOCK_NO, GTK_ICON_SIZE_BUTTON ); -#endif - - if( icon ) gtk_button_set_image( GTK_BUTTON( btn ), icon ); - - add_click( btn, button, accel, 0, 0, 0, 0 ); - - return btn; -} - -GtkAccelGroup* -gtkstock_create_buttons( GtkWidget *widget, GtkAccelGroup *accel, - const gtkstock_button *buttons, size_t count ) -{ - if( !accel ) accel = gtkstock_add_accel_group( widget ); - - for( ; count; buttons++, count-- ) - gtkstock_create_button( widget, accel, buttons ); - - return accel; -} - -GtkAccelGroup* -gtkstock_create_ok_cancel( GtkWidget *widget, GtkAccelGroup *accel, - GCallback action, gpointer actiondata, - GCallback destroy_ok, GCallback destroy_cancel ) -{ - gtkstock_button btn[] = { - { "_Cancel", NULL, NULL, NULL, GDK_KEY_Escape, 0, 0, 0, GTK_RESPONSE_CANCEL}, - { "_OK", NULL, NULL, NULL, 0, 0, 0, 0, GTK_RESPONSE_OK}, - }; - btn[0].destroy = destroy_cancel ? destroy_cancel : NULL; - btn[1].destroy = destroy_ok ? destroy_ok : NULL; - btn[1].action = action; - btn[1].actiondata = actiondata; - - return gtkstock_create_buttons( widget, accel, btn, - ARRAY_SIZE( btn ) ); -} - -GtkAccelGroup* -gtkstock_create_close( GtkWidget *widget, GtkAccelGroup *accel, - GCallback destroy, gboolean esconly ) -{ - gtkstock_button btn = { - "_Close", NULL, NULL, (destroy ? destroy : DEFAULT_DESTROY), - (esconly ? GDK_KEY_VoidSymbol : GDK_KEY_Return), 0, GDK_KEY_Escape, 0, - GTK_RESPONSE_CLOSE - }; - return gtkstock_create_buttons( widget, accel, &btn, 1 ); -} - -GtkWidget* -gtkstock_dialog_new( const gchar *title, GCallback destroy ) -{ - GtkWidget *dialog = gtk_dialog_new(); - if( title ) gtk_window_set_title( GTK_WINDOW( dialog ), title ); - /* TODO: allow to keep the dialog after closing for gtk_dialog_run() */ - g_signal_connect( G_OBJECT( dialog ), "delete-event", - destroy ? destroy : DEFAULT_DESTROY, NULL ); - if( destroy == NULL ) gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE ); - gtk_window_set_transient_for( GTK_WINDOW( dialog ), - GTK_WINDOW( gtkui_window ) ); - - return dialog; -} diff --git a/fuse/ui/null/Makefile.am b/fuse/ui/null/Makefile.am deleted file mode 100644 index 72db106..0000000 --- a/fuse/ui/null/Makefile.am +++ /dev/null @@ -1,45 +0,0 @@ -## Process this file with automake to produce Makefile.in -## Copyright (c) 2001-2017 Philip Kendall, Sergio Baldoví - -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -## -## Author contact information: -## -## E-mail: philip-fuse@shadowmagic.org.uk - -if UI_NULL - -fuse_SOURCES += $(ui_null_files) - -BUILT_SOURCES += $(ui_null_built) - -endif - -CLEANFILES += $(ui_null_built) - -ui_null_files = \ - ui/null/null_ui.c \ - ui/null/options.c - -ui_null_built = \ - ui/null/options.c - -EXTRA_DIST += \ - ui/null/options.pl \ - ui/null/options-header.pl - -ui/null/options.c: $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/ui/null/options.pl $(srcdir)/ui/options.dat $(srcdir)/perl/Fuse.pm $(srcdir)/perl/Fuse/Dialog.pm - @$(MKDIR_P) ui/null - $(AM_V_GEN)$(PERL) $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/ui/options.dat | $(PERL) -I$(srcdir)/perl $(srcdir)/ui/null/options.pl - > $@.tmp && mv $@.tmp $@ diff --git a/fuse/ui/null/null_ui.c b/fuse/ui/null/null_ui.c deleted file mode 100644 index 416fe02..0000000 --- a/fuse/ui/null/null_ui.c +++ /dev/null @@ -1,259 +0,0 @@ -/* null_ui.c: Routines for dealing with the null user interface - Copyright (c) 2017 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include "keyboard.h" -#include "ui/ui.h" - -#include "../uijoystick.c" - -keysyms_map_t keysyms_map[] = { - { 0, 0 } /* End marker */ -}; - -scaler_type -menu_get_scaler( scaler_available_fn selector ) -{ - /* No scaler selected */ - return SCALER_NUM; -} - -int -menu_select_roms_with_title( const char *title, size_t start, size_t count, - int is_peripheral ) -{ - /* No error */ - return 0; -} - -void -ui_breakpoints_updated( void ) -{ - /* Do nothing */ -} - -ui_confirm_save_t -ui_confirm_save_specific( const char *message ) -{ - return UI_CONFIRM_SAVE_DONTSAVE; -} - -ui_confirm_joystick_t -ui_confirm_joystick( libspectrum_joystick libspectrum_type, int inputs ) -{ - return UI_CONFIRM_JOYSTICK_NONE; -} - -int -ui_debugger_activate( void ) -{ - /* No error */ - return 0; -} - -int -ui_debugger_deactivate( int interruptable ) -{ - /* No error */ - return 0; -} - -int -ui_debugger_disassemble( libspectrum_word addr ) -{ - /* No error */ - return 0; -} - -int -ui_debugger_update( void ) -{ - /* No error */ - return 0; -} - -int -ui_end( void ) -{ - /* No error */ - return 0; -} - -int -ui_error_specific( ui_error_level severity, const char *message ) -{ - /* No error */ - return 0; -} - -int -ui_event( void ) -{ - /* No error */ - return 0; -} - -char* -ui_get_open_filename( const char *title ) -{ - /* No filename */ - return NULL; -} - -int -ui_get_rollback_point( GSList *points ) -{ - /* No rollback point */ - return -1; -} - -char* -ui_get_save_filename( const char *title ) -{ - /* No filename */ - return NULL; -} - -int -ui_init( int *argc, char ***argv ) -{ - /* No error */ - return 0; -} - -int -ui_menu_item_set_active( const char *path, int active ) -{ - /* No error */ - return 0; -} - -int -ui_mouse_grab( int startup ) -{ - /* Successful grab */ - return 1; -} - -int -ui_mouse_release( int suspend ) -{ - /* No error */ - return 0; -} - -void -ui_pokemem_selector( const char *filename ) -{ - /* Do nothing */ -} - -int -ui_query( const char *message ) -{ - /* Query confirmed */ - return 1; -} - -int -ui_statusbar_update( ui_statusbar_item item, ui_statusbar_state state ) -{ - /* No error */ - return 0; -} - -int -ui_statusbar_update_speed( float speed ) -{ - /* No error */ - return 0; -} - -int -ui_tape_browser_update( ui_tape_browser_update_type change, - libspectrum_tape_block *block ) -{ - /* No error */ - return 0; -} - -int -ui_widgets_reset( void ) -{ - /* No error */ - return 0; -} - -void -uidisplay_area( int x, int y, int w, int h ) -{ - /* Do nothing */ -} - -int -uidisplay_end( void ) -{ - /* No error */ - return 0; -} - -void -uidisplay_frame_end( void ) -{ - /* Do nothing */ -} - -int -uidisplay_hotswap_gfx_mode( void ) -{ - /* No error */ - return 0; -} - -int -uidisplay_init( int width, int height ) -{ - /* No error */ - return 0; -} - -void -uidisplay_plot16( int x, int y, libspectrum_word data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - /* Do nothing */ -} - -void -uidisplay_plot8( int x, int y, libspectrum_byte data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - /* Do nothing */ -} - -void -uidisplay_putpixel( int x, int y, int colour ) -{ - /* Do nothing */ -} diff --git a/fuse/ui/null/options-header.pl b/fuse/ui/null/options-header.pl deleted file mode 100644 index 01c0bc7..0000000 --- a/fuse/ui/null/options-header.pl +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/perl -w - -# options-header.pl: generate options dialog boxes -# Copyright (c) 2001-2017 Philip Kendall - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Author contact information: - -# E-mail: philip-fuse@shadowmagic.org.uk - -use strict; - -use Fuse; -use Fuse::Dialog; - -die "No data file specified" unless @ARGV; - -my @dialogs = Fuse::Dialog::read( shift @ARGV ); - -print Fuse::GPL( 'options.h: options dialog boxes public declarations', - '2001-2017 Philip Kendall' ); - -print << "CODE"; - -/* This file is autogenerated from options.dat by options-header.pl. - Do not edit unless you know what you\'re doing! */ - -#ifndef FUSE_OPTIONS_H -#define FUSE_OPTIONS_H - -CODE - -foreach( @dialogs ) { - foreach my $widget ( @{ $_->{widgets} } ) { - if( $widget->{type} eq "Combo" ) { - print <<"CODE"; -int option_enumerate_$_->{name}_$widget->{value}( void ); - -CODE - } - } -} - -print << "CODE"; -#endif /* #ifndef FUSE_OPTIONS_H */ -CODE diff --git a/fuse/ui/null/options.pl b/fuse/ui/null/options.pl deleted file mode 100755 index 64e5404..0000000 --- a/fuse/ui/null/options.pl +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/perl -w - -# options.pl: generate options dialog boxes -# Copyright (c) 2001-2015 Philip Kendall, Fredrick Meunier - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Author contact information: - -# E-mail: philip-fuse@shadowmagic.org.uk - -use strict; - -use lib '../perl'; - -use Fuse; -use Fuse::Dialog; - -die "No data file specified" unless @ARGV; - -my %combo_sets; -my %combo_default; -my @dialogs = Fuse::Dialog::read( shift @ARGV ); - -print Fuse::GPL( 'options.c: options dialog boxes', - '2001-2017 Philip Kendall' ) . << "CODE"; - -/* This file is autogenerated from options.dat by options.pl. - Do not edit unless you know what you\'re doing! */ - -#include -CODE - -foreach( @dialogs ) { - foreach my $widget ( @{ $_->{widgets} } ) { - if( $widget->{type} eq "Combo" ) { - print << "CODE"; - -int -option_enumerate_$_->{name}_$widget->{value}( void ) -{ - return 0; -} -CODE - } - } -} diff --git a/fuse/ui/scaler/Makefile.am b/fuse/ui/scaler/Makefile.am deleted file mode 100644 index b8784c8..0000000 --- a/fuse/ui/scaler/Makefile.am +++ /dev/null @@ -1,51 +0,0 @@ -## Process this file with automake to produce Makefile.in -## Copyright (c) 2001 Philip Kendall -## Copyright (c) 2015 Sergio Baldoví - -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -## -## Author contact information: -## -## E-mail: philip-fuse@shadowmagic.org.uk - -fuse_SOURCES += ui/scaler/scaler.c - -fuse_LDADD += \ - ui/scaler/scalers16.o \ - ui/scaler/scalers32.o - -fuse_DEPENDENCIES += \ - ui/scaler/scalers16.o \ - ui/scaler/scalers32.o - -ui/scaler/scalers16.o: $(srcdir)/ui/scaler/scalers.c - $(AM_V_CC)$(COMPILE) -DSCALER_DATA_SIZE=2 -c $(srcdir)/ui/scaler/scalers.c -o $@ - -ui/scaler/scalers32.o: $(srcdir)/ui/scaler/scalers.c - $(AM_V_CC)$(COMPILE) -DSCALER_DATA_SIZE=4 -c $(srcdir)/ui/scaler/scalers.c -o $@ - -noinst_HEADERS += \ - ui/scaler/scaler.h \ - ui/scaler/scaler_internals.h - -EXTRA_DIST += \ - ui/scaler/scalers.c \ - ui/scaler/scaler_hq2x.c \ - ui/scaler/scaler_hq3x.c \ - ui/scaler/scaler_hq4x.c - -CLEANFILES += \ - ui/scaler/scalers16.o \ - ui/scaler/scalers32.o diff --git a/fuse/ui/scaler/scaler.c b/fuse/ui/scaler/scaler.c deleted file mode 100644 index d479a08..0000000 --- a/fuse/ui/scaler/scaler.c +++ /dev/null @@ -1,284 +0,0 @@ -/* scaler.c: code for selecting (etc) scalers - * Copyright (C) 2003 Fredrick Meunier, Philip Kendall - * Copyright (c) 2015 Sergio Baldoví - * - * Originally taken from ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001/2002 The ScummVM project - * - * HQ2x and HQ3x scalers taken from HiEnd3D Demos (http://www.hiend3d.com) - * Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include - -#include - -#include - -#include "scaler.h" -#include "scaler_internals.h" -#include "settings.h" -#include "ui/ui.h" -#include "ui/uidisplay.h" -#include "utils.h" - -static int scaler_supported[ SCALER_NUM ] = {0}; - -int scalers_registered = 0; - -struct scaler_info { - - const char *name; - const char *id; - enum scaler_flags_t flags; - float scaling_factor; - ScalerProc *scaler16, *scaler32; - scaler_expand_fn *expander; - -}; - -/* The expander functions */ - -/* Clip back to screen size after expansion */ -static void clip( int *x, int *y, int *w, int *h, - int image_width, int image_height ); - -static void expand_1( int *x, int *y, int *w, int *h, - int image_width, int image_height ); -static void expand_sai( int *x, int *y, int *w, int *h, - int image_width, int image_height ); -static void expand_pal1( int *x, int *y, int *w, int *h, - int image_width, int image_height ); -static void expand_pal( int *x, int *y, int *w, int *h, - int image_width, int image_height ); -static void expand_dotmatrix( int *x, int *y, int *w, int *h, - int image_width, int image_height ); - -/* Information on each of the available scalers. Make sure this array stays - in the same order as scaler.h:scaler_type */ -static const struct scaler_info available_scalers[] = { - - { "Timex Half (smoothed)", "half", SCALER_FLAGS_NONE, 0.5, - scaler_Half_16, scaler_Half_32, NULL }, - { "Timex Half (skipping)", "halfskip", SCALER_FLAGS_NONE, 0.5, - scaler_HalfSkip_16, scaler_HalfSkip_32, NULL }, - { "Normal", "normal", SCALER_FLAGS_NONE, 1.0, - scaler_Normal1x_16, scaler_Normal1x_32, NULL }, - { "Double size", "2x", SCALER_FLAGS_NONE, 2.0, - scaler_Normal2x_16, scaler_Normal2x_32, NULL }, - { "Triple size", "3x", SCALER_FLAGS_NONE, 3.0, - scaler_Normal3x_16, scaler_Normal3x_32, NULL }, - { "Quadruple size", "4x", SCALER_FLAGS_NONE, 4.0, - scaler_Normal4x_16, scaler_Normal4x_32, NULL }, - { "2xSaI", "2xsai", SCALER_FLAGS_EXPAND, 2.0, - scaler_2xSaI_16, scaler_2xSaI_32, expand_sai }, - { "Super 2xSaI", "super2xsai", SCALER_FLAGS_EXPAND, 2.0, - scaler_Super2xSaI_16, scaler_Super2xSaI_32, expand_sai }, - { "SuperEagle", "supereagle", SCALER_FLAGS_EXPAND, 2.0, - scaler_SuperEagle_16, scaler_SuperEagle_32, expand_sai }, - { "AdvMAME 2x", "advmame2x", SCALER_FLAGS_EXPAND, 2.0, - scaler_AdvMame2x_16, scaler_AdvMame2x_32, expand_1 }, - { "AdvMAME 3x", "advmame3x", SCALER_FLAGS_EXPAND, 3.0, - scaler_AdvMame3x_16, scaler_AdvMame3x_32, expand_1 }, - { "TV 2x", "tv2x", SCALER_FLAGS_NONE, 2.0, - scaler_TV2x_16, scaler_TV2x_32, NULL }, - { "TV 3x", "tv3x", SCALER_FLAGS_NONE, 3.0, - scaler_TV3x_16, scaler_TV3x_32, NULL }, - { "TV 4x", "tv4x", SCALER_FLAGS_NONE, 4.0, - scaler_TV4x_16, scaler_TV4x_32, NULL }, - { "Timex TV", "timextv", SCALER_FLAGS_NONE, 1.0, - scaler_TimexTV_16, scaler_TimexTV_32, NULL }, - { "Dot Matrix", "dotmatrix", SCALER_FLAGS_EXPAND, 2.0, - scaler_DotMatrix_16, scaler_DotMatrix_32, expand_dotmatrix }, - { "Timex 1.5x", "timex15x", SCALER_FLAGS_NONE, 1.5, - scaler_Timex1_5x_16, scaler_Timex1_5x_32, NULL }, - { "Timex 2x", "timex2x", SCALER_FLAGS_NONE, 2.0, - scaler_Normal2x_16, scaler_Normal2x_32, NULL }, - { "PAL TV", "paltv", SCALER_FLAGS_EXPAND, 1.0, - scaler_PalTV_16, scaler_PalTV_32, expand_pal1 }, - { "PAL TV 2x", "paltv2x", SCALER_FLAGS_EXPAND, 2.0, - scaler_PalTV2x_16, scaler_PalTV2x_32, expand_pal }, - { "PAL TV 3x", "paltv3x", SCALER_FLAGS_EXPAND, 3.0, - scaler_PalTV3x_16, scaler_PalTV3x_32, expand_pal }, - { "PAL TV 4x", "paltv4x", SCALER_FLAGS_EXPAND, 4.0, - scaler_PalTV4x_16, scaler_PalTV4x_32, expand_pal }, - { "HQ 2x", "hq2x", SCALER_FLAGS_EXPAND, 2.0, - scaler_HQ2x_16, scaler_HQ2x_32, expand_1 }, - { "HQ 3x", "hq3x", SCALER_FLAGS_EXPAND, 3.0, - scaler_HQ3x_16, scaler_HQ3x_32, expand_1 }, - { "HQ 4x", "hq4x", SCALER_FLAGS_EXPAND, 4.0, - scaler_HQ4x_16, scaler_HQ4x_32, expand_1 }, -}; - -scaler_type current_scaler = SCALER_NUM; -ScalerProc *scaler_proc16, *scaler_proc32; -scaler_flags_t scaler_flags; -scaler_expand_fn *scaler_expander; - -int -scaler_select_scaler( scaler_type scaler ) -{ - if( !scaler_is_supported( scaler ) ) return 1; - - if( current_scaler == scaler ) return 0; - - current_scaler = scaler; - - if( settings_current.start_scaler_mode ) libspectrum_free( settings_current.start_scaler_mode ); - settings_current.start_scaler_mode = - utils_safe_strdup( available_scalers[current_scaler].id ); - - scaler_proc16 = scaler_get_proc16( current_scaler ); - scaler_proc32 = scaler_get_proc32( current_scaler ); - scaler_flags = scaler_get_flags( current_scaler ); - scaler_expander = scaler_get_expander( current_scaler ); - - return uidisplay_hotswap_gfx_mode(); -} - -int -scaler_select_id( const char *id ) -{ - scaler_type i; - - for( i=0; i < SCALER_NUM; i++ ) { - if( ! strcmp( available_scalers[i].id, id ) ) { - scaler_select_scaler( i ); - return 0; - } - } - - ui_error( UI_ERROR_ERROR, "Scaler id '%s' unknown", id ); - return 1; -} - -void -scaler_register_clear( void ) -{ - scalers_registered = 0; - memset( scaler_supported, 0, sizeof(int) * SCALER_NUM ); -} - -void -scaler_register( scaler_type scaler ) -{ - if( scaler_supported[scaler] == 1 ) return; - scalers_registered++; - scaler_supported[scaler] = 1; -} - -int -scaler_is_supported( scaler_type scaler ) -{ - return ( scaler >= SCALER_NUM ? 0 : scaler_supported[scaler] ); -} - -const char * -scaler_name( scaler_type scaler ) -{ - return available_scalers[scaler].name; -} - -ScalerProc* -scaler_get_proc16( scaler_type scaler ) -{ - return available_scalers[scaler].scaler16; -} - -ScalerProc* -scaler_get_proc32( scaler_type scaler ) -{ - return available_scalers[scaler].scaler32; -} - -scaler_flags_t -scaler_get_flags( scaler_type scaler ) -{ - return available_scalers[scaler].flags; -} - -float -scaler_get_scaling_factor( scaler_type scaler ) -{ - return available_scalers[scaler].scaling_factor; -} - -scaler_expand_fn* -scaler_get_expander( scaler_type scaler ) -{ - return available_scalers[scaler].expander; -} - -/* The expansion functions */ - -/* Clip after expansion */ -static inline void -clip( int *x, int *y, int *w, int *h, int image_width, int image_height ) -{ - if ( *x < 0 ) { *w += *x; *x=0; } - if ( *y < 0 ) { *h += *y; *y=0; } - if ( *w > image_width - *x ) *w = image_width - *x; - if ( *h > image_height - *y ) *h = image_height - *y; -} - -/* Expand one pixel in all directions */ -static void -expand_1( int *x, int *y, int *w, int *h, int image_width, int image_height ) -{ - (*x)--; (*y)--; (*w)+=2; (*h)+=2; - clip( x, y, w, h, image_width, image_height ); -} - -/* Expand two pixels up and left and one pixel down and right */ -static void -expand_sai( int *x, int *y, int *w, int *h, int image_width, int image_height ) -{ - (*x)-=2; (*y)-=2; (*w)+=3; (*h)+=3; - clip( x, y, w, h, image_width, image_height ); -} - -/* Expand two pixels left and right */ -static void -expand_pal1( int *x, int *y, int *w, int *h, int image_width, int image_height ) -{ - int w_mod = (*w) % 2; - (*x)-=2; (*w)+=4; - (*w)+=w_mod; /* expand to even*/ - clip( x, y, w, h, image_width, image_height ); -} - -/* Expand one pixels left and right */ -static void -expand_pal( int *x, int *y, int *w, int *h, int image_width, int image_height ) -{ - (*x)-=1; (*w)+=2; - clip( x, y, w, h, image_width, image_height ); -} - -/* Expand to a even y co-ord */ -static void -expand_dotmatrix( int *x GCC_UNUSED, int *y GCC_UNUSED, int *w GCC_UNUSED, - int *h, int image_width GCC_UNUSED, - int image_height GCC_UNUSED ) -{ - int y_mod = (*y) % 2; - - (*y)-=y_mod; - (*h)+=y_mod; -} diff --git a/fuse/ui/scaler/scaler.h b/fuse/ui/scaler/scaler.h deleted file mode 100644 index 8b587a2..0000000 --- a/fuse/ui/scaler/scaler.h +++ /dev/null @@ -1,96 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2002-2003 The ScummVM project, Fredrick Meunier and - * Philip Kendall - * - * HQ2x and HQ3x scalers taken from HiEnd3D Demos (http://www.hiend3d.com) - * Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * $Header$ - */ - -#ifndef SCALER_H -#define SCALER_H - -#include - -typedef enum scaler_type { - SCALER_HALF = 0, - SCALER_HALFSKIP, - SCALER_NORMAL, - SCALER_DOUBLESIZE, - SCALER_TRIPLESIZE, - SCALER_QUADSIZE, - SCALER_2XSAI, - SCALER_SUPER2XSAI, - SCALER_SUPEREAGLE, - SCALER_ADVMAME2X, - SCALER_ADVMAME3X, - SCALER_TV2X, - SCALER_TV3X, - SCALER_TV4X, - SCALER_TIMEXTV, - SCALER_DOTMATRIX, - SCALER_TIMEX1_5X, - SCALER_TIMEX2X, - SCALER_PALTV, - SCALER_PALTV2X, - SCALER_PALTV3X, - SCALER_PALTV4X, - SCALER_HQ2X, - SCALER_HQ3X, - SCALER_HQ4X, - - SCALER_NUM /* End marker; do not remove */ -} scaler_type; - -typedef enum scaler_flags_t { - SCALER_FLAGS_NONE = 0, - SCALER_FLAGS_EXPAND = 1 << 0, -} scaler_flags_t; - -typedef void ScalerProc( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, libspectrum_dword dstPitch, - int width, int height ); - -/* The type of function used to expand the area dirtied by a scaler */ -typedef void scaler_expand_fn( int *x, int *y, int *w, int *h, - int image_width, int image_height ); - -extern scaler_type current_scaler; -extern ScalerProc *scaler_proc16, *scaler_proc32; -extern scaler_flags_t scaler_flags; -extern scaler_expand_fn *scaler_expander; -extern int scalers_registered; - -typedef int (*scaler_available_fn)( scaler_type scaler ); - -int scaler_select_id( const char *scaler_mode ); -void scaler_register_clear( void ); -int scaler_select_scaler( scaler_type scaler ); -void scaler_register( scaler_type scaler ); -int scaler_is_supported( scaler_type scaler ); -const char *scaler_name( scaler_type scaler ); -ScalerProc *scaler_get_proc16( scaler_type scaler ); -ScalerProc *scaler_get_proc32( scaler_type scaler ); -scaler_flags_t scaler_get_flags( scaler_type scaler ); -float scaler_get_scaling_factor( scaler_type scaler ); -scaler_expand_fn* scaler_get_expander( scaler_type scaler ); - -int scaler_select_bitformat( libspectrum_dword BitFormat ); - -#endif diff --git a/fuse/ui/scaler/scaler_hq2x.c b/fuse/ui/scaler/scaler_hq2x.c deleted file mode 100644 index 62669dd..0000000 --- a/fuse/ui/scaler/scaler_hq2x.c +++ /dev/null @@ -1,2134 +0,0 @@ -/* scaler_hq2x.c: included into scalers.c - * Copyright (C) 2008 Gergely Szasz - * - * HQ2x, HQ3x and HQ4x scalers taken from HiEnd3D Demos (http://www.hiend3d.com) - * Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - switch( pattern ) { - case 0: - case 1: - case 4: - case 32: - case 128: - case 5: - case 132: - case 160: - case 33: - case 129: - case 36: - case 133: - case 164: - case 161: - case 37: - case 165: - { - *q = HQ_PIXEL00_20; - *q1 = HQ_PIXEL01_20; - *qN = HQ_PIXEL10_20; - *qN1 = HQ_PIXEL11_20; - break; - } - case 2: - case 34: - case 130: - case 162: - { - *q = HQ_PIXEL00_22; - *q1 = HQ_PIXEL01_21; - *qN = HQ_PIXEL10_20; - *qN1 = HQ_PIXEL11_20; - break; - } - case 16: - case 17: - case 48: - case 49: - { - *q = HQ_PIXEL00_20; - *q1 = HQ_PIXEL01_22; - *qN = HQ_PIXEL10_20; - *qN1 = HQ_PIXEL11_21; - break; - } - case 64: - case 65: - case 68: - case 69: - { - *q = HQ_PIXEL00_20; - *q1 = HQ_PIXEL01_20; - *qN = HQ_PIXEL10_21; - *qN1 = HQ_PIXEL11_22; - break; - } - case 8: - case 12: - case 136: - case 140: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_20; - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_20; - break; - } - case 3: - case 35: - case 131: - case 163: - { - *q = HQ_PIXEL00_11; - *q1 = HQ_PIXEL01_21; - *qN = HQ_PIXEL10_20; - *qN1 = HQ_PIXEL11_20; - break; - } - case 6: - case 38: - case 134: - case 166: - { - *q = HQ_PIXEL00_22; - *q1 = HQ_PIXEL01_12; - *qN = HQ_PIXEL10_20; - *qN1 = HQ_PIXEL11_20; - break; - } - case 20: - case 21: - case 52: - case 53: - { - *q = HQ_PIXEL00_20; - *q1 = HQ_PIXEL01_11; - *qN = HQ_PIXEL10_20; - *qN1 = HQ_PIXEL11_21; - break; - } - case 144: - case 145: - case 176: - case 177: - { - *q = HQ_PIXEL00_20; - *q1 = HQ_PIXEL01_22; - *qN = HQ_PIXEL10_20; - *qN1 = HQ_PIXEL11_12; - break; - } - case 192: - case 193: - case 196: - case 197: - { - *q = HQ_PIXEL00_20; - *q1 = HQ_PIXEL01_20; - *qN = HQ_PIXEL10_21; - *qN1 = HQ_PIXEL11_11; - break; - } - case 96: - case 97: - case 100: - case 101: - { - *q = HQ_PIXEL00_20; - *q1 = HQ_PIXEL01_20; - *qN = HQ_PIXEL10_12; - *qN1 = HQ_PIXEL11_22; - break; - } - case 40: - case 44: - case 168: - case 172: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_20; - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_20; - break; - } - case 9: - case 13: - case 137: - case 141: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_20; - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_20; - break; - } - case 18: - case 50: - { - *q = HQ_PIXEL00_22; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_10; - } else { - *q1 = HQ_PIXEL01_20; - } - *qN = HQ_PIXEL10_20; - *qN1 = HQ_PIXEL11_21; - break; - } - case 80: - case 81: - { - *q = HQ_PIXEL00_20; - *q1 = HQ_PIXEL01_22; - *qN = HQ_PIXEL10_21; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_10; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 72: - case 76: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_20; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_10; - } else { - *qN = HQ_PIXEL10_20; - } - *qN1 = HQ_PIXEL11_22; - break; - } - case 10: - case 138: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_10; - } else { - *q = HQ_PIXEL00_20; - } - *q1 = HQ_PIXEL01_21; - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_20; - break; - } - case 66: - { - *q = HQ_PIXEL00_22; - *q1 = HQ_PIXEL01_21; - *qN = HQ_PIXEL10_21; - *qN1 = HQ_PIXEL11_22; - break; - } - case 24: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_22; - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_21; - break; - } - case 7: - case 39: - case 135: - { - *q = HQ_PIXEL00_11; - *q1 = HQ_PIXEL01_12; - *qN = HQ_PIXEL10_20; - *qN1 = HQ_PIXEL11_20; - break; - } - case 148: - case 149: - case 180: - { - *q = HQ_PIXEL00_20; - *q1 = HQ_PIXEL01_11; - *qN = HQ_PIXEL10_20; - *qN1 = HQ_PIXEL11_12; - break; - } - case 224: - case 228: - case 225: - { - *q = HQ_PIXEL00_20; - *q1 = HQ_PIXEL01_20; - *qN = HQ_PIXEL10_12; - *qN1 = HQ_PIXEL11_11; - break; - } - case 41: - case 169: - case 45: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_20; - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_20; - break; - } - case 22: - case 54: - { - *q = HQ_PIXEL00_22; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_20; - } - *qN = HQ_PIXEL10_20; - *qN1 = HQ_PIXEL11_21; - break; - } - case 208: - case 209: - { - *q = HQ_PIXEL00_20; - *q1 = HQ_PIXEL01_22; - *qN = HQ_PIXEL10_21; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 104: - case 108: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_20; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_20; - } - *qN1 = HQ_PIXEL11_22; - break; - } - case 11: - case 139: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_20; - } - *q1 = HQ_PIXEL01_21; - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_20; - break; - } - case 19: - case 51: - { - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q = HQ_PIXEL00_11; - *q1 = HQ_PIXEL01_10; - } else { - *q = HQ_PIXEL00_60; - *q1 = HQ_PIXEL01_90; - } - *qN = HQ_PIXEL10_20; - *qN1 = HQ_PIXEL11_21; - break; - } - case 146: - case 178: - { - *q = HQ_PIXEL00_22; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_10; - *qN1 = HQ_PIXEL11_12; - } else { - *q1 = HQ_PIXEL01_90; - *qN1 = HQ_PIXEL11_61; - } - *qN = HQ_PIXEL10_20; - break; - } - case 84: - case 85: - { - *q = HQ_PIXEL00_20; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *q1 = HQ_PIXEL01_11; - *qN1 = HQ_PIXEL11_10; - } else { - *q1 = HQ_PIXEL01_60; - *qN1 = HQ_PIXEL11_90; - } - *qN = HQ_PIXEL10_21; - break; - } - case 112: - case 113: - { - *q = HQ_PIXEL00_20; - *q1 = HQ_PIXEL01_22; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN = HQ_PIXEL10_12; - *qN1 = HQ_PIXEL11_10; - } else { - *qN = HQ_PIXEL10_61; - *qN1 = HQ_PIXEL11_90; - } - break; - } - case 200: - case 204: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_20; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_10; - *qN1 = HQ_PIXEL11_11; - } else { - *qN = HQ_PIXEL10_90; - *qN1 = HQ_PIXEL11_60; - } - break; - } - case 73: - case 77: - { - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *q = HQ_PIXEL00_12; - *qN = HQ_PIXEL10_10; - } else { - *q = HQ_PIXEL00_61; - *qN = HQ_PIXEL10_90; - } - *q1 = HQ_PIXEL01_20; - *qN1 = HQ_PIXEL11_22; - break; - } - case 42: - case 170: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_10; - *qN = HQ_PIXEL10_11; - } else { - *q = HQ_PIXEL00_90; - *qN = HQ_PIXEL10_60; - } - *q1 = HQ_PIXEL01_21; - *qN1 = HQ_PIXEL11_20; - break; - } - case 14: - case 142: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_10; - *q1 = HQ_PIXEL01_12; - } else { - *q = HQ_PIXEL00_90; - *q1 = HQ_PIXEL01_61; - } - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_20; - break; - } - case 67: - { - *q = HQ_PIXEL00_11; - *q1 = HQ_PIXEL01_21; - *qN = HQ_PIXEL10_21; - *qN1 = HQ_PIXEL11_22; - break; - } - case 70: - { - *q = HQ_PIXEL00_22; - *q1 = HQ_PIXEL01_12; - *qN = HQ_PIXEL10_21; - *qN1 = HQ_PIXEL11_22; - break; - } - case 28: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_11; - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_21; - break; - } - case 152: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_22; - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_12; - break; - } - case 194: - { - *q = HQ_PIXEL00_22; - *q1 = HQ_PIXEL01_21; - *qN = HQ_PIXEL10_21; - *qN1 = HQ_PIXEL11_11; - break; - } - case 98: - { - *q = HQ_PIXEL00_22; - *q1 = HQ_PIXEL01_21; - *qN = HQ_PIXEL10_12; - *qN1 = HQ_PIXEL11_22; - break; - } - case 56: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_22; - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_21; - break; - } - case 25: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_22; - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_21; - break; - } - case 26: - case 31: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_20; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_20; - } - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_21; - break; - } - case 82: - case 214: - { - *q = HQ_PIXEL00_22; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_20; - } - *qN = HQ_PIXEL10_21; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 88: - case 248: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_22; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_20; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 74: - case 107: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_20; - } - *q1 = HQ_PIXEL01_21; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_20; - } - *qN1 = HQ_PIXEL11_22; - break; - } - case 27: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_20; - } - *q1 = HQ_PIXEL01_10; - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_21; - break; - } - case 86: - { - *q = HQ_PIXEL00_22; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_20; - } - *qN = HQ_PIXEL10_21; - *qN1 = HQ_PIXEL11_10; - break; - } - case 216: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_22; - *qN = HQ_PIXEL10_10; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 106: - { - *q = HQ_PIXEL00_10; - *q1 = HQ_PIXEL01_21; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_20; - } - *qN1 = HQ_PIXEL11_22; - break; - } - case 30: - { - *q = HQ_PIXEL00_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_20; - } - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_21; - break; - } - case 210: - { - *q = HQ_PIXEL00_22; - *q1 = HQ_PIXEL01_10; - *qN = HQ_PIXEL10_21; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 120: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_22; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_20; - } - *qN1 = HQ_PIXEL11_10; - break; - } - case 75: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_20; - } - *q1 = HQ_PIXEL01_21; - *qN = HQ_PIXEL10_10; - *qN1 = HQ_PIXEL11_22; - break; - } - case 29: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_11; - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_21; - break; - } - case 198: - { - *q = HQ_PIXEL00_22; - *q1 = HQ_PIXEL01_12; - *qN = HQ_PIXEL10_21; - *qN1 = HQ_PIXEL11_11; - break; - } - case 184: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_22; - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_12; - break; - } - case 99: - { - *q = HQ_PIXEL00_11; - *q1 = HQ_PIXEL01_21; - *qN = HQ_PIXEL10_12; - *qN1 = HQ_PIXEL11_22; - break; - } - case 57: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_22; - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_21; - break; - } - case 71: - { - *q = HQ_PIXEL00_11; - *q1 = HQ_PIXEL01_12; - *qN = HQ_PIXEL10_21; - *qN1 = HQ_PIXEL11_22; - break; - } - case 156: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_11; - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_12; - break; - } - case 226: - { - *q = HQ_PIXEL00_22; - *q1 = HQ_PIXEL01_21; - *qN = HQ_PIXEL10_12; - *qN1 = HQ_PIXEL11_11; - break; - } - case 60: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_11; - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_21; - break; - } - case 195: - { - *q = HQ_PIXEL00_11; - *q1 = HQ_PIXEL01_21; - *qN = HQ_PIXEL10_21; - *qN1 = HQ_PIXEL11_11; - break; - } - case 102: - { - *q = HQ_PIXEL00_22; - *q1 = HQ_PIXEL01_12; - *qN = HQ_PIXEL10_12; - *qN1 = HQ_PIXEL11_22; - break; - } - case 153: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_22; - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_12; - break; - } - case 58: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_10; - } else { - *q = HQ_PIXEL00_70; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_10; - } else { - *q1 = HQ_PIXEL01_70; - } - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_21; - break; - } - case 83: - { - *q = HQ_PIXEL00_11; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_10; - } else { - *q1 = HQ_PIXEL01_70; - } - *qN = HQ_PIXEL10_21; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_10; - } else { - *qN1 = HQ_PIXEL11_70; - } - break; - } - case 92: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_11; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_10; - } else { - *qN = HQ_PIXEL10_70; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_10; - } else { - *qN1 = HQ_PIXEL11_70; - } - break; - } - case 202: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_10; - } else { - *q = HQ_PIXEL00_70; - } - *q1 = HQ_PIXEL01_21; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_10; - } else { - *qN = HQ_PIXEL10_70; - } - *qN1 = HQ_PIXEL11_11; - break; - } - case 78: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_10; - } else { - *q = HQ_PIXEL00_70; - } - *q1 = HQ_PIXEL01_12; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_10; - } else { - *qN = HQ_PIXEL10_70; - } - *qN1 = HQ_PIXEL11_22; - break; - } - case 154: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_10; - } else { - *q = HQ_PIXEL00_70; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_10; - } else { - *q1 = HQ_PIXEL01_70; - } - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_12; - break; - } - case 114: - { - *q = HQ_PIXEL00_22; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_10; - } else { - *q1 = HQ_PIXEL01_70; - } - *qN = HQ_PIXEL10_12; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_10; - } else { - *qN1 = HQ_PIXEL11_70; - } - break; - } - case 89: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_22; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_10; - } else { - *qN = HQ_PIXEL10_70; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_10; - } else { - *qN1 = HQ_PIXEL11_70; - } - break; - } - case 90: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_10; - } else { - *q = HQ_PIXEL00_70; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_10; - } else { - *q1 = HQ_PIXEL01_70; - } - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_10; - } else { - *qN = HQ_PIXEL10_70; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_10; - } else { - *qN1 = HQ_PIXEL11_70; - } - break; - } - case 55: - case 23: - { - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q = HQ_PIXEL00_11; - *q1 = HQ_PIXEL01_0; - } else { - *q = HQ_PIXEL00_60; - *q1 = HQ_PIXEL01_90; - } - *qN = HQ_PIXEL10_20; - *qN1 = HQ_PIXEL11_21; - break; - } - case 182: - case 150: - { - *q = HQ_PIXEL00_22; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - *qN1 = HQ_PIXEL11_12; - } else { - *q1 = HQ_PIXEL01_90; - *qN1 = HQ_PIXEL11_61; - } - *qN = HQ_PIXEL10_20; - break; - } - case 213: - case 212: - { - *q = HQ_PIXEL00_20; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *q1 = HQ_PIXEL01_11; - *qN1 = HQ_PIXEL11_0; - } else { - *q1 = HQ_PIXEL01_60; - *qN1 = HQ_PIXEL11_90; - } - *qN = HQ_PIXEL10_21; - break; - } - case 241: - case 240: - { - *q = HQ_PIXEL00_20; - *q1 = HQ_PIXEL01_22; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN = HQ_PIXEL10_12; - *qN1 = HQ_PIXEL11_0; - } else { - *qN = HQ_PIXEL10_61; - *qN1 = HQ_PIXEL11_90; - } - break; - } - case 236: - case 232: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_20; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - *qN1 = HQ_PIXEL11_11; - } else { - *qN = HQ_PIXEL10_90; - *qN1 = HQ_PIXEL11_60; - } - break; - } - case 109: - case 105: - { - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *q = HQ_PIXEL00_12; - *qN = HQ_PIXEL10_0; - } else { - *q = HQ_PIXEL00_61; - *qN = HQ_PIXEL10_90; - } - *q1 = HQ_PIXEL01_20; - *qN1 = HQ_PIXEL11_22; - break; - } - case 171: - case 43: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - *qN = HQ_PIXEL10_11; - } else { - *q = HQ_PIXEL00_90; - *qN = HQ_PIXEL10_60; - } - *q1 = HQ_PIXEL01_21; - *qN1 = HQ_PIXEL11_20; - break; - } - case 143: - case 15: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - *q1 = HQ_PIXEL01_12; - } else { - *q = HQ_PIXEL00_90; - *q1 = HQ_PIXEL01_61; - } - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_20; - break; - } - case 124: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_11; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_20; - } - *qN1 = HQ_PIXEL11_10; - break; - } - case 203: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_20; - } - *q1 = HQ_PIXEL01_21; - *qN = HQ_PIXEL10_10; - *qN1 = HQ_PIXEL11_11; - break; - } - case 62: - { - *q = HQ_PIXEL00_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_20; - } - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_21; - break; - } - case 211: - { - *q = HQ_PIXEL00_11; - *q1 = HQ_PIXEL01_10; - *qN = HQ_PIXEL10_21; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 118: - { - *q = HQ_PIXEL00_22; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_20; - } - *qN = HQ_PIXEL10_12; - *qN1 = HQ_PIXEL11_10; - break; - } - case 217: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_22; - *qN = HQ_PIXEL10_10; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 110: - { - *q = HQ_PIXEL00_10; - *q1 = HQ_PIXEL01_12; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_20; - } - *qN1 = HQ_PIXEL11_22; - break; - } - case 155: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_20; - } - *q1 = HQ_PIXEL01_10; - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_12; - break; - } - case 188: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_11; - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_12; - break; - } - case 185: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_22; - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_12; - break; - } - case 61: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_11; - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_21; - break; - } - case 157: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_11; - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_12; - break; - } - case 103: - { - *q = HQ_PIXEL00_11; - *q1 = HQ_PIXEL01_12; - *qN = HQ_PIXEL10_12; - *qN1 = HQ_PIXEL11_22; - break; - } - case 227: - { - *q = HQ_PIXEL00_11; - *q1 = HQ_PIXEL01_21; - *qN = HQ_PIXEL10_12; - *qN1 = HQ_PIXEL11_11; - break; - } - case 230: - { - *q = HQ_PIXEL00_22; - *q1 = HQ_PIXEL01_12; - *qN = HQ_PIXEL10_12; - *qN1 = HQ_PIXEL11_11; - break; - } - case 199: - { - *q = HQ_PIXEL00_11; - *q1 = HQ_PIXEL01_12; - *qN = HQ_PIXEL10_21; - *qN1 = HQ_PIXEL11_11; - break; - } - case 220: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_11; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_10; - } else { - *qN = HQ_PIXEL10_70; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 158: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_10; - } else { - *q = HQ_PIXEL00_70; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_20; - } - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_12; - break; - } - case 234: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_10; - } else { - *q = HQ_PIXEL00_70; - } - *q1 = HQ_PIXEL01_21; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_20; - } - *qN1 = HQ_PIXEL11_11; - break; - } - case 242: - { - *q = HQ_PIXEL00_22; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_10; - } else { - *q1 = HQ_PIXEL01_70; - } - *qN = HQ_PIXEL10_12; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 59: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_20; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_10; - } else { - *q1 = HQ_PIXEL01_70; - } - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_21; - break; - } - case 121: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_22; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_20; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_10; - } else { - *qN1 = HQ_PIXEL11_70; - } - break; - } - case 87: - { - *q = HQ_PIXEL00_11; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_20; - } - *qN = HQ_PIXEL10_21; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_10; - } else { - *qN1 = HQ_PIXEL11_70; - } - break; - } - case 79: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_20; - } - *q1 = HQ_PIXEL01_12; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_10; - } else { - *qN = HQ_PIXEL10_70; - } - *qN1 = HQ_PIXEL11_22; - break; - } - case 122: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_10; - } else { - *q = HQ_PIXEL00_70; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_10; - } else { - *q1 = HQ_PIXEL01_70; - } - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_20; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_10; - } else { - *qN1 = HQ_PIXEL11_70; - } - break; - } - case 94: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_10; - } else { - *q = HQ_PIXEL00_70; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_20; - } - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_10; - } else { - *qN = HQ_PIXEL10_70; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_10; - } else { - *qN1 = HQ_PIXEL11_70; - } - break; - } - case 218: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_10; - } else { - *q = HQ_PIXEL00_70; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_10; - } else { - *q1 = HQ_PIXEL01_70; - } - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_10; - } else { - *qN = HQ_PIXEL10_70; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 91: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_20; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_10; - } else { - *q1 = HQ_PIXEL01_70; - } - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_10; - } else { - *qN = HQ_PIXEL10_70; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_10; - } else { - *qN1 = HQ_PIXEL11_70; - } - break; - } - case 229: - { - *q = HQ_PIXEL00_20; - *q1 = HQ_PIXEL01_20; - *qN = HQ_PIXEL10_12; - *qN1 = HQ_PIXEL11_11; - break; - } - case 167: - { - *q = HQ_PIXEL00_11; - *q1 = HQ_PIXEL01_12; - *qN = HQ_PIXEL10_20; - *qN1 = HQ_PIXEL11_20; - break; - } - case 173: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_20; - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_20; - break; - } - case 181: - { - *q = HQ_PIXEL00_20; - *q1 = HQ_PIXEL01_11; - *qN = HQ_PIXEL10_20; - *qN1 = HQ_PIXEL11_12; - break; - } - case 186: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_10; - } else { - *q = HQ_PIXEL00_70; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_10; - } else { - *q1 = HQ_PIXEL01_70; - } - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_12; - break; - } - case 115: - { - *q = HQ_PIXEL00_11; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_10; - } else { - *q1 = HQ_PIXEL01_70; - } - *qN = HQ_PIXEL10_12; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_10; - } else { - *qN1 = HQ_PIXEL11_70; - } - break; - } - case 93: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_11; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_10; - } else { - *qN = HQ_PIXEL10_70; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_10; - } else { - *qN1 = HQ_PIXEL11_70; - } - break; - } - case 206: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_10; - } else { - *q = HQ_PIXEL00_70; - } - *q1 = HQ_PIXEL01_12; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_10; - } else { - *qN = HQ_PIXEL10_70; - } - *qN1 = HQ_PIXEL11_11; - break; - } - case 205: - case 201: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_20; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_10; - } else { - *qN = HQ_PIXEL10_70; - } - *qN1 = HQ_PIXEL11_11; - break; - } - case 174: - case 46: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_10; - } else { - *q = HQ_PIXEL00_70; - } - *q1 = HQ_PIXEL01_12; - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_20; - break; - } - case 179: - case 147: - { - *q = HQ_PIXEL00_11; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_10; - } else { - *q1 = HQ_PIXEL01_70; - } - *qN = HQ_PIXEL10_20; - *qN1 = HQ_PIXEL11_12; - break; - } - case 117: - case 116: - { - *q = HQ_PIXEL00_20; - *q1 = HQ_PIXEL01_11; - *qN = HQ_PIXEL10_12; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_10; - } else { - *qN1 = HQ_PIXEL11_70; - } - break; - } - case 189: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_11; - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_12; - break; - } - case 231: - { - *q = HQ_PIXEL00_11; - *q1 = HQ_PIXEL01_12; - *qN = HQ_PIXEL10_12; - *qN1 = HQ_PIXEL11_11; - break; - } - case 126: - { - *q = HQ_PIXEL00_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_20; - } - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_20; - } - *qN1 = HQ_PIXEL11_10; - break; - } - case 219: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_20; - } - *q1 = HQ_PIXEL01_10; - *qN = HQ_PIXEL10_10; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 125: - { - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *q = HQ_PIXEL00_12; - *qN = HQ_PIXEL10_0; - } else { - *q = HQ_PIXEL00_61; - *qN = HQ_PIXEL10_90; - } - *q1 = HQ_PIXEL01_11; - *qN1 = HQ_PIXEL11_10; - break; - } - case 221: - { - *q = HQ_PIXEL00_12; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *q1 = HQ_PIXEL01_11; - *qN1 = HQ_PIXEL11_0; - } else { - *q1 = HQ_PIXEL01_60; - *qN1 = HQ_PIXEL11_90; - } - *qN = HQ_PIXEL10_10; - break; - } - case 207: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - *q1 = HQ_PIXEL01_12; - } else { - *q = HQ_PIXEL00_90; - *q1 = HQ_PIXEL01_61; - } - *qN = HQ_PIXEL10_10; - *qN1 = HQ_PIXEL11_11; - break; - } - case 238: - { - *q = HQ_PIXEL00_10; - *q1 = HQ_PIXEL01_12; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - *qN1 = HQ_PIXEL11_11; - } else { - *qN = HQ_PIXEL10_90; - *qN1 = HQ_PIXEL11_60; - } - break; - } - case 190: - { - *q = HQ_PIXEL00_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - *qN1 = HQ_PIXEL11_12; - } else { - *q1 = HQ_PIXEL01_90; - *qN1 = HQ_PIXEL11_61; - } - *qN = HQ_PIXEL10_11; - break; - } - case 187: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - *qN = HQ_PIXEL10_11; - } else { - *q = HQ_PIXEL00_90; - *qN = HQ_PIXEL10_60; - } - *q1 = HQ_PIXEL01_10; - *qN1 = HQ_PIXEL11_12; - break; - } - case 243: - { - *q = HQ_PIXEL00_11; - *q1 = HQ_PIXEL01_10; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN = HQ_PIXEL10_12; - *qN1 = HQ_PIXEL11_0; - } else { - *qN = HQ_PIXEL10_61; - *qN1 = HQ_PIXEL11_90; - } - break; - } - case 119: - { - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q = HQ_PIXEL00_11; - *q1 = HQ_PIXEL01_0; - } else { - *q = HQ_PIXEL00_60; - *q1 = HQ_PIXEL01_90; - } - *qN = HQ_PIXEL10_12; - *qN1 = HQ_PIXEL11_10; - break; - } - case 237: - case 233: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_20; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_100; - } - *qN1 = HQ_PIXEL11_11; - break; - } - case 175: - case 47: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_100; - } - *q1 = HQ_PIXEL01_12; - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_20; - break; - } - case 183: - case 151: - { - *q = HQ_PIXEL00_11; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_100; - } - *qN = HQ_PIXEL10_20; - *qN1 = HQ_PIXEL11_12; - break; - } - case 245: - case 244: - { - *q = HQ_PIXEL00_20; - *q1 = HQ_PIXEL01_11; - *qN = HQ_PIXEL10_12; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_100; - } - break; - } - case 250: - { - *q = HQ_PIXEL00_10; - *q1 = HQ_PIXEL01_10; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_20; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 123: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_20; - } - *q1 = HQ_PIXEL01_10; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_20; - } - *qN1 = HQ_PIXEL11_10; - break; - } - case 95: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_20; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_20; - } - *qN = HQ_PIXEL10_10; - *qN1 = HQ_PIXEL11_10; - break; - } - case 222: - { - *q = HQ_PIXEL00_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_20; - } - *qN = HQ_PIXEL10_10; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 252: - { - *q = HQ_PIXEL00_21; - *q1 = HQ_PIXEL01_11; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_20; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_100; - } - break; - } - case 249: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_22; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_100; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 235: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_20; - } - *q1 = HQ_PIXEL01_21; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_100; - } - *qN1 = HQ_PIXEL11_11; - break; - } - case 111: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_100; - } - *q1 = HQ_PIXEL01_12; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_20; - } - *qN1 = HQ_PIXEL11_22; - break; - } - case 63: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_100; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_20; - } - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_21; - break; - } - case 159: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_20; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_100; - } - *qN = HQ_PIXEL10_22; - *qN1 = HQ_PIXEL11_12; - break; - } - case 215: - { - *q = HQ_PIXEL00_11; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_100; - } - *qN = HQ_PIXEL10_21; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 246: - { - *q = HQ_PIXEL00_22; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_20; - } - *qN = HQ_PIXEL10_12; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_100; - } - break; - } - case 254: - { - *q = HQ_PIXEL00_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_20; - } - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_20; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_100; - } - break; - } - case 253: - { - *q = HQ_PIXEL00_12; - *q1 = HQ_PIXEL01_11; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_100; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_100; - } - break; - } - case 251: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_20; - } - *q1 = HQ_PIXEL01_10; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_100; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 239: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_100; - } - *q1 = HQ_PIXEL01_12; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_100; - } - *qN1 = HQ_PIXEL11_11; - break; - } - case 127: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_100; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_20; - } - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_20; - } - *qN1 = HQ_PIXEL11_10; - break; - } - case 191: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_100; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_100; - } - *qN = HQ_PIXEL10_11; - *qN1 = HQ_PIXEL11_12; - break; - } - case 223: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_20; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_100; - } - *qN = HQ_PIXEL10_10; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_20; - } - break; - } - case 247: - { - *q = HQ_PIXEL00_11; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_100; - } - *qN = HQ_PIXEL10_12; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_100; - } - break; - } - case 255: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_0; - } else { - *q = HQ_PIXEL00_100; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_0; - } else { - *q1 = HQ_PIXEL01_100; - } - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_0; - } else { - *qN = HQ_PIXEL10_100; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN1 = HQ_PIXEL11_0; - } else { - *qN1 = HQ_PIXEL11_100; - } - break; - } - } diff --git a/fuse/ui/scaler/scaler_hq3x.c b/fuse/ui/scaler/scaler_hq3x.c deleted file mode 100644 index c9a51aa..0000000 --- a/fuse/ui/scaler/scaler_hq3x.c +++ /dev/null @@ -1,3107 +0,0 @@ -/* scaler_hq3x.c: included into scalers.c - * Copyright (C) 2008 Gergely Szasz - * - * HQ2x, HQ3x and HQ4x scalers taken from HiEnd3D Demos (http://www.hiend3d.com) - * Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - switch( pattern ) { - case 0: - case 1: - case 4: - case 32: - case 128: - case 5: - case 132: - case 160: - case 33: - case 129: - case 36: - case 133: - case 164: - case 161: - case 37: - case 165: - { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 2: - case 34: - case 130: - case 162: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 16: - case 17: - case 48: - case 49: - { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 64: - case 65: - case 68: - case 69: - { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 8: - case 12: - case 136: - case 140: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 3: - case 35: - case 131: - case 163: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 6: - case 38: - case 134: - case 166: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 20: - case 21: - case 52: - case 53: - { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 144: - case 145: - case 176: - case 177: - { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 192: - case 193: - case 196: - case 197: - { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 96: - case 97: - case 100: - case 101: - { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 40: - case 44: - case 168: - case 172: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 9: - case 13: - case 137: - case 141: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 18: - case 50: - { - *q = HQ_PIXEL00_1M; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN2 = HQ_PIXEL12_C; - } else { - *q1 = HQ_PIXEL01_3; - *q2 = HQ_PIXEL02_4; - *qN2 = HQ_PIXEL12_3; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 80: - case 81: - { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1M; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - } else { - *qN2 = HQ_PIXEL12_3; - *qNN1 = HQ_PIXEL21_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 72: - case 76: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - } else { - *qN = HQ_PIXEL10_3; - *qNN = HQ_PIXEL20_4; - *qNN1 = HQ_PIXEL21_3; - } - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 10: - case 138: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_4; - *q1 = HQ_PIXEL01_3; - *qN = HQ_PIXEL10_3; - } - *q2 = HQ_PIXEL02_1M; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 66: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 24: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 7: - case 39: - case 135: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 148: - case 149: - case 180: - { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 224: - case 228: - case 225: - { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 41: - case 169: - case 45: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 22: - case 54: - { - *q = HQ_PIXEL00_1M; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - } else { - *q1 = HQ_PIXEL01_3; - *q2 = HQ_PIXEL02_4; - *qN2 = HQ_PIXEL12_3; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 208: - case 209: - { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1M; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qN2 = HQ_PIXEL12_3; - *qNN1 = HQ_PIXEL21_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 104: - case 108: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - } else { - *qN = HQ_PIXEL10_3; - *qNN = HQ_PIXEL20_4; - *qNN1 = HQ_PIXEL21_3; - } - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 11: - case 139: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_4; - *q1 = HQ_PIXEL01_3; - *qN = HQ_PIXEL10_3; - } - *q2 = HQ_PIXEL02_1M; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 19: - case 51: - { - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN2 = HQ_PIXEL12_C; - } else { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_6; - *q2 = HQ_PIXEL02_5; - *qN2 = HQ_PIXEL12_1; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 146: - case 178: - { - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN2 = HQ_PIXEL12_C; - *qNN2 = HQ_PIXEL22_1D; - } else { - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_5; - *qN2 = HQ_PIXEL12_6; - *qNN2 = HQ_PIXEL22_2; - } - *q = HQ_PIXEL00_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - break; - } - case 84: - case 85: - { - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *q2 = HQ_PIXEL02_1U; - *qN2 = HQ_PIXEL12_C; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - } else { - *q2 = HQ_PIXEL02_2; - *qN2 = HQ_PIXEL12_6; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_5; - } - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1M; - break; - } - case 112: - case 113: - { - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - } else { - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_6; - *qNN2 = HQ_PIXEL22_5; - } - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - break; - } - case 200: - case 204: - { - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - } else { - *qN = HQ_PIXEL10_1; - *qNN = HQ_PIXEL20_5; - *qNN1 = HQ_PIXEL21_6; - *qNN2 = HQ_PIXEL22_2; - } - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - break; - } - case 73: - case 77: - { - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *q = HQ_PIXEL00_1U; - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - } else { - *q = HQ_PIXEL00_2; - *qN = HQ_PIXEL10_6; - *qNN = HQ_PIXEL20_5; - *qNN1 = HQ_PIXEL21_1; - } - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 42: - case 170: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_1D; - } else { - *q = HQ_PIXEL00_5; - *q1 = HQ_PIXEL01_1; - *qN = HQ_PIXEL10_6; - *qNN = HQ_PIXEL20_2; - } - *q2 = HQ_PIXEL02_1M; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 14: - case 142: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_5; - *q1 = HQ_PIXEL01_6; - *q2 = HQ_PIXEL02_2; - *qN = HQ_PIXEL10_1; - } - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 67: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 70: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 28: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 152: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 194: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 98: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 56: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 25: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 26: - case 31: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_4; - *qN = HQ_PIXEL10_3; - } - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - } else { - *q2 = HQ_PIXEL02_4; - *qN2 = HQ_PIXEL12_3; - } - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 82: - case 214: - { - *q = HQ_PIXEL00_1M; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - } else { - *q1 = HQ_PIXEL01_3; - *q2 = HQ_PIXEL02_4; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1M; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qNN1 = HQ_PIXEL21_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 88: - case 248: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN1 = HQ_PIXEL11; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - } else { - *qN = HQ_PIXEL10_3; - *qNN = HQ_PIXEL20_4; - } - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qN2 = HQ_PIXEL12_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 74: - case 107: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - } else { - *q = HQ_PIXEL00_4; - *q1 = HQ_PIXEL01_3; - } - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - } else { - *qNN = HQ_PIXEL20_4; - *qNN1 = HQ_PIXEL21_3; - } - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 27: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_4; - *q1 = HQ_PIXEL01_3; - *qN = HQ_PIXEL10_3; - } - *q2 = HQ_PIXEL02_1M; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 86: - { - *q = HQ_PIXEL00_1M; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - } else { - *q1 = HQ_PIXEL01_3; - *q2 = HQ_PIXEL02_4; - *qN2 = HQ_PIXEL12_3; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 216: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1M; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qN2 = HQ_PIXEL12_3; - *qNN1 = HQ_PIXEL21_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 106: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - } else { - *qN = HQ_PIXEL10_3; - *qNN = HQ_PIXEL20_4; - *qNN1 = HQ_PIXEL21_3; - } - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 30: - { - *q = HQ_PIXEL00_1M; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - } else { - *q1 = HQ_PIXEL01_3; - *q2 = HQ_PIXEL02_4; - *qN2 = HQ_PIXEL12_3; - } - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 210: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1M; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qN2 = HQ_PIXEL12_3; - *qNN1 = HQ_PIXEL21_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 120: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - } else { - *qN = HQ_PIXEL10_3; - *qNN = HQ_PIXEL20_4; - *qNN1 = HQ_PIXEL21_3; - } - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 75: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_4; - *q1 = HQ_PIXEL01_3; - *qN = HQ_PIXEL10_3; - } - *q2 = HQ_PIXEL02_1M; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 29: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 198: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 184: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 99: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 57: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 71: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 156: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 226: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 60: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 195: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 102: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 153: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 58: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_1M; - } else { - *q = HQ_PIXEL00_2; - } - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_1M; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 83: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_1M; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_1M; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 92: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_1M; - } else { - *qNN = HQ_PIXEL20_2; - } - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_1M; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 202: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_1M; - } else { - *q = HQ_PIXEL00_2; - } - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_1M; - } else { - *qNN = HQ_PIXEL20_2; - } - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 78: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_1M; - } else { - *q = HQ_PIXEL00_2; - } - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_1M; - } else { - *qNN = HQ_PIXEL20_2; - } - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 154: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_1M; - } else { - *q = HQ_PIXEL00_2; - } - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_1M; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 114: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_1M; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_1M; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 89: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_1M; - } else { - *qNN = HQ_PIXEL20_2; - } - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_1M; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 90: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_1M; - } else { - *q = HQ_PIXEL00_2; - } - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_1M; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_1M; - } else { - *qNN = HQ_PIXEL20_2; - } - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_1M; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 55: - case 23: - { - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - } else { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_6; - *q2 = HQ_PIXEL02_5; - *qN2 = HQ_PIXEL12_1; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 182: - case 150: - { - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - *qNN2 = HQ_PIXEL22_1D; - } else { - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_5; - *qN2 = HQ_PIXEL12_6; - *qNN2 = HQ_PIXEL22_2; - } - *q = HQ_PIXEL00_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - break; - } - case 213: - case 212: - { - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *q2 = HQ_PIXEL02_1U; - *qN2 = HQ_PIXEL12_C; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *q2 = HQ_PIXEL02_2; - *qN2 = HQ_PIXEL12_6; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_5; - } - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1M; - break; - } - case 241: - case 240: - { - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_6; - *qNN2 = HQ_PIXEL22_5; - } - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - break; - } - case 236: - case 232: - { - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - } else { - *qN = HQ_PIXEL10_1; - *qNN = HQ_PIXEL20_5; - *qNN1 = HQ_PIXEL21_6; - *qNN2 = HQ_PIXEL22_2; - } - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - break; - } - case 109: - case 105: - { - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *q = HQ_PIXEL00_1U; - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - } else { - *q = HQ_PIXEL00_2; - *qN = HQ_PIXEL10_6; - *qNN = HQ_PIXEL20_5; - *qNN1 = HQ_PIXEL21_1; - } - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 171: - case 43: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_1D; - } else { - *q = HQ_PIXEL00_5; - *q1 = HQ_PIXEL01_1; - *qN = HQ_PIXEL10_6; - *qNN = HQ_PIXEL20_2; - } - *q2 = HQ_PIXEL02_1M; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 143: - case 15: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_5; - *q1 = HQ_PIXEL01_6; - *q2 = HQ_PIXEL02_2; - *qN = HQ_PIXEL10_1; - } - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 124: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - } else { - *qN = HQ_PIXEL10_3; - *qNN = HQ_PIXEL20_4; - *qNN1 = HQ_PIXEL21_3; - } - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 203: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_4; - *q1 = HQ_PIXEL01_3; - *qN = HQ_PIXEL10_3; - } - *q2 = HQ_PIXEL02_1M; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 62: - { - *q = HQ_PIXEL00_1M; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - } else { - *q1 = HQ_PIXEL01_3; - *q2 = HQ_PIXEL02_4; - *qN2 = HQ_PIXEL12_3; - } - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 211: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1M; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qN2 = HQ_PIXEL12_3; - *qNN1 = HQ_PIXEL21_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 118: - { - *q = HQ_PIXEL00_1M; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - } else { - *q1 = HQ_PIXEL01_3; - *q2 = HQ_PIXEL02_4; - *qN2 = HQ_PIXEL12_3; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 217: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1M; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qN2 = HQ_PIXEL12_3; - *qNN1 = HQ_PIXEL21_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 110: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - } else { - *qN = HQ_PIXEL10_3; - *qNN = HQ_PIXEL20_4; - *qNN1 = HQ_PIXEL21_3; - } - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 155: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_4; - *q1 = HQ_PIXEL01_3; - *qN = HQ_PIXEL10_3; - } - *q2 = HQ_PIXEL02_1M; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 188: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 185: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 61: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 157: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 103: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 227: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 230: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 199: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 220: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_1M; - } else { - *qNN = HQ_PIXEL20_2; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qN2 = HQ_PIXEL12_3; - *qNN1 = HQ_PIXEL21_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 158: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_1M; - } else { - *q = HQ_PIXEL00_2; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - } else { - *q1 = HQ_PIXEL01_3; - *q2 = HQ_PIXEL02_4; - *qN2 = HQ_PIXEL12_3; - } - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 234: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_1M; - } else { - *q = HQ_PIXEL00_2; - } - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - } else { - *qN = HQ_PIXEL10_3; - *qNN = HQ_PIXEL20_4; - *qNN1 = HQ_PIXEL21_3; - } - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 242: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_1M; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1L; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qN2 = HQ_PIXEL12_3; - *qNN1 = HQ_PIXEL21_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 59: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_4; - *q1 = HQ_PIXEL01_3; - *qN = HQ_PIXEL10_3; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_1M; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 121: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - } else { - *qN = HQ_PIXEL10_3; - *qNN = HQ_PIXEL20_4; - *qNN1 = HQ_PIXEL21_3; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_1M; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 87: - { - *q = HQ_PIXEL00_1L; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - } else { - *q1 = HQ_PIXEL01_3; - *q2 = HQ_PIXEL02_4; - *qN2 = HQ_PIXEL12_3; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_1M; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 79: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_4; - *q1 = HQ_PIXEL01_3; - *qN = HQ_PIXEL10_3; - } - *q2 = HQ_PIXEL02_1R; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_1M; - } else { - *qNN = HQ_PIXEL20_2; - } - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 122: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_1M; - } else { - *q = HQ_PIXEL00_2; - } - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_1M; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - } else { - *qN = HQ_PIXEL10_3; - *qNN = HQ_PIXEL20_4; - *qNN1 = HQ_PIXEL21_3; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_1M; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 94: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_1M; - } else { - *q = HQ_PIXEL00_2; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - } else { - *q1 = HQ_PIXEL01_3; - *q2 = HQ_PIXEL02_4; - *qN2 = HQ_PIXEL12_3; - } - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_1M; - } else { - *qNN = HQ_PIXEL20_2; - } - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_1M; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 218: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_1M; - } else { - *q = HQ_PIXEL00_2; - } - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_1M; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_1M; - } else { - *qNN = HQ_PIXEL20_2; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qN2 = HQ_PIXEL12_3; - *qNN1 = HQ_PIXEL21_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 91: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_4; - *q1 = HQ_PIXEL01_3; - *qN = HQ_PIXEL10_3; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_1M; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_1M; - } else { - *qNN = HQ_PIXEL20_2; - } - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_1M; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 229: - { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 167: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 173: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 181: - { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 186: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_1M; - } else { - *q = HQ_PIXEL00_2; - } - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_1M; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 115: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_1M; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_1M; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 93: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_1M; - } else { - *qNN = HQ_PIXEL20_2; - } - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_1M; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 206: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_1M; - } else { - *q = HQ_PIXEL00_2; - } - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_1M; - } else { - *qNN = HQ_PIXEL20_2; - } - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 205: - case 201: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_1M; - } else { - *qNN = HQ_PIXEL20_2; - } - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 174: - case 46: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_1M; - } else { - *q = HQ_PIXEL00_2; - } - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 179: - case 147: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_1M; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 117: - case 116: - { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_1M; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 189: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 231: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 126: - { - *q = HQ_PIXEL00_1M; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - } else { - *q1 = HQ_PIXEL01_3; - *q2 = HQ_PIXEL02_4; - *qN2 = HQ_PIXEL12_3; - } - *qN1 = HQ_PIXEL11; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - } else { - *qN = HQ_PIXEL10_3; - *qNN = HQ_PIXEL20_4; - *qNN1 = HQ_PIXEL21_3; - } - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 219: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_4; - *q1 = HQ_PIXEL01_3; - *qN = HQ_PIXEL10_3; - } - *q2 = HQ_PIXEL02_1M; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1M; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qN2 = HQ_PIXEL12_3; - *qNN1 = HQ_PIXEL21_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 125: - { - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *q = HQ_PIXEL00_1U; - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - } else { - *q = HQ_PIXEL00_2; - *qN = HQ_PIXEL10_6; - *qNN = HQ_PIXEL20_5; - *qNN1 = HQ_PIXEL21_1; - } - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 221: - { - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *q2 = HQ_PIXEL02_1U; - *qN2 = HQ_PIXEL12_C; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *q2 = HQ_PIXEL02_2; - *qN2 = HQ_PIXEL12_6; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_5; - } - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1M; - break; - } - case 207: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_5; - *q1 = HQ_PIXEL01_6; - *q2 = HQ_PIXEL02_2; - *qN = HQ_PIXEL10_1; - } - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 238: - { - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - } else { - *qN = HQ_PIXEL10_1; - *qNN = HQ_PIXEL20_5; - *qNN1 = HQ_PIXEL21_6; - *qNN2 = HQ_PIXEL22_2; - } - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - break; - } - case 190: - { - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - *qNN2 = HQ_PIXEL22_1D; - } else { - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_5; - *qN2 = HQ_PIXEL12_6; - *qNN2 = HQ_PIXEL22_2; - } - *q = HQ_PIXEL00_1M; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - break; - } - case 187: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_1D; - } else { - *q = HQ_PIXEL00_5; - *q1 = HQ_PIXEL01_1; - *qN = HQ_PIXEL10_6; - *qNN = HQ_PIXEL20_2; - } - *q2 = HQ_PIXEL02_1M; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 243: - { - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_6; - *qNN2 = HQ_PIXEL22_5; - } - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - break; - } - case 119: - { - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - } else { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_6; - *q2 = HQ_PIXEL02_5; - *qN2 = HQ_PIXEL12_1; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 237: - case 233: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_2; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_C; - } else { - *qNN = HQ_PIXEL20_2; - } - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 175: - case 47: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - } else { - *q = HQ_PIXEL00_2; - } - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_2; - break; - } - case 183: - case 151: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_C; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 245: - case 244: - { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_C; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 250: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1M; - *qN1 = HQ_PIXEL11; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - } else { - *qN = HQ_PIXEL10_3; - *qNN = HQ_PIXEL20_4; - } - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qN2 = HQ_PIXEL12_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 123: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - } else { - *q = HQ_PIXEL00_4; - *q1 = HQ_PIXEL01_3; - } - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - } else { - *qNN = HQ_PIXEL20_4; - *qNN1 = HQ_PIXEL21_3; - } - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 95: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_4; - *qN = HQ_PIXEL10_3; - } - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - } else { - *q2 = HQ_PIXEL02_4; - *qN2 = HQ_PIXEL12_3; - } - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 222: - { - *q = HQ_PIXEL00_1M; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - } else { - *q1 = HQ_PIXEL01_3; - *q2 = HQ_PIXEL02_4; - } - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1M; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qNN1 = HQ_PIXEL21_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 252: - { - *q = HQ_PIXEL00_1M; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - } else { - *qN = HQ_PIXEL10_3; - *qNN = HQ_PIXEL20_4; - } - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_C; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 249: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_C; - } else { - *qNN = HQ_PIXEL20_2; - } - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qN2 = HQ_PIXEL12_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 235: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - } else { - *q = HQ_PIXEL00_4; - *q1 = HQ_PIXEL01_3; - } - *q2 = HQ_PIXEL02_1M; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_C; - } else { - *qNN = HQ_PIXEL20_2; - } - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 111: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - } else { - *q = HQ_PIXEL00_2; - } - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - } else { - *qNN = HQ_PIXEL20_4; - *qNN1 = HQ_PIXEL21_3; - } - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 63: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - } else { - *q = HQ_PIXEL00_2; - } - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - } else { - *q2 = HQ_PIXEL02_4; - *qN2 = HQ_PIXEL12_3; - } - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 159: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_4; - *qN = HQ_PIXEL10_3; - } - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_C; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1M; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 215: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_C; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1M; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qNN1 = HQ_PIXEL21_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 246: - { - *q = HQ_PIXEL00_1M; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - } else { - *q1 = HQ_PIXEL01_3; - *q2 = HQ_PIXEL02_4; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_C; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 254: - { - *q = HQ_PIXEL00_1M; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - } else { - *q1 = HQ_PIXEL01_3; - *q2 = HQ_PIXEL02_4; - } - *qN1 = HQ_PIXEL11; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - } else { - *qN = HQ_PIXEL10_3; - *qNN = HQ_PIXEL20_4; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qN2 = HQ_PIXEL12_3; - *qNN1 = HQ_PIXEL21_3; - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 253: - { - *q = HQ_PIXEL00_1U; - *q1 = HQ_PIXEL01_1; - *q2 = HQ_PIXEL02_1U; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_C; - } else { - *qNN = HQ_PIXEL20_2; - } - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_C; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 251: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - } else { - *q = HQ_PIXEL00_4; - *q1 = HQ_PIXEL01_3; - } - *q2 = HQ_PIXEL02_1M; - *qN1 = HQ_PIXEL11; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qN = HQ_PIXEL10_C; - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - } else { - *qN = HQ_PIXEL10_3; - *qNN = HQ_PIXEL20_2; - *qNN1 = HQ_PIXEL21_3; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qN2 = HQ_PIXEL12_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qN2 = HQ_PIXEL12_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 239: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - } else { - *q = HQ_PIXEL00_2; - } - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_1R; - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_1; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_C; - } else { - *qNN = HQ_PIXEL20_2; - } - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_1R; - break; - } - case 127: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *q1 = HQ_PIXEL01_C; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_2; - *q1 = HQ_PIXEL01_3; - *qN = HQ_PIXEL10_3; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - } else { - *q2 = HQ_PIXEL02_4; - *qN2 = HQ_PIXEL12_3; - } - *qN1 = HQ_PIXEL11; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_C; - *qNN1 = HQ_PIXEL21_C; - } else { - *qNN = HQ_PIXEL20_4; - *qNN1 = HQ_PIXEL21_3; - } - *qNN2 = HQ_PIXEL22_1M; - break; - } - case 191: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - } else { - *q = HQ_PIXEL00_2; - } - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_C; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1D; - *qNN1 = HQ_PIXEL21_1; - *qNN2 = HQ_PIXEL22_1D; - break; - } - case 223: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - *qN = HQ_PIXEL10_C; - } else { - *q = HQ_PIXEL00_4; - *qN = HQ_PIXEL10_3; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q1 = HQ_PIXEL01_C; - *q2 = HQ_PIXEL02_C; - *qN2 = HQ_PIXEL12_C; - } else { - *q1 = HQ_PIXEL01_3; - *q2 = HQ_PIXEL02_2; - *qN2 = HQ_PIXEL12_3; - } - *qN1 = HQ_PIXEL11; - *qNN = HQ_PIXEL20_1M; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN1 = HQ_PIXEL21_C; - *qNN2 = HQ_PIXEL22_C; - } else { - *qNN1 = HQ_PIXEL21_3; - *qNN2 = HQ_PIXEL22_4; - } - break; - } - case 247: - { - *q = HQ_PIXEL00_1L; - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_C; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN = HQ_PIXEL10_1; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - *qNN = HQ_PIXEL20_1L; - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_C; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - case 255: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ_PIXEL00_C; - } else { - *q = HQ_PIXEL00_2; - } - *q1 = HQ_PIXEL01_C; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ_PIXEL02_C; - } else { - *q2 = HQ_PIXEL02_2; - } - *qN = HQ_PIXEL10_C; - *qN1 = HQ_PIXEL11; - *qN2 = HQ_PIXEL12_C; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ_PIXEL20_C; - } else { - *qNN = HQ_PIXEL20_2; - } - *qNN1 = HQ_PIXEL21_C; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ_PIXEL22_C; - } else { - *qNN2 = HQ_PIXEL22_2; - } - break; - } - } diff --git a/fuse/ui/scaler/scaler_hq4x.c b/fuse/ui/scaler/scaler_hq4x.c deleted file mode 100644 index 067c84d..0000000 --- a/fuse/ui/scaler/scaler_hq4x.c +++ /dev/null @@ -1,4470 +0,0 @@ -/* scaler_hq4x.c: included into scalers.c - * Copyright (C) 2008 Gergely Szasz - * Copyright (C) 2019 Sergio Baldoví - * - * HQ2x, HQ3x and HQ4x scalers taken from HiEnd3D Demos (http://www.hiend3d.com) - * Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2; - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - - switch( pattern ) { - - case 0: - case 1: - case 4: - case 32: - case 128: - case 5: - case 132: - case 160: - case 33: - case 129: - case 36: - case 133: - case 164: - case 161: - case 37: - case 165: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 2: - case 34: - case 130: - case 162: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 16: - case 17: - case 48: - case 49: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 64: - case 65: - case 68: - case 69: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 8: - case 12: - case 136: - case 140: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 3: - case 35: - case 131: - case 163: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 6: - case 38: - case 134: - case 166: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 20: - case 21: - case 52: - case 53: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 144: - case 145: - case 176: - case 177: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 192: - case 193: - case 196: - case 197: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 96: - case 97: - case 100: - case 101: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 40: - case 44: - case 168: - case 172: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 9: - case 13: - case 137: - case 141: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 18: - case 50: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_50; - } - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 80: - case 81: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - } else { - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - break; - } - case 72: - case 76: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 10: - case 138: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - *qN1 = HQ4X_PIXEL11_0; - } - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 66: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 24: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 7: - case 39: - case 135: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 148: - case 149: - case 180: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 224: - case 228: - case 225: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 41: - case 169: - case 45: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 22: - case 54: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN3 = HQ4X_PIXEL13_50; - } - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_0; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 208: - case 209: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - break; - } - case 104: - case 108: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 11: - case 139: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - } - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 19: - case 51: - { - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - } else { - *q = HQ4X_PIXEL00_12; - *q1 = HQ4X_PIXEL01_14; - *q2 = HQ4X_PIXEL02_83; - *q3 = HQ4X_PIXEL03_50; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_21; - } - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 146: - case 178: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN3 = HQ4X_PIXEL33_82; - } else { - *q2 = HQ4X_PIXEL02_21; - *q3 = HQ4X_PIXEL03_50; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_83; - *qNN3 = HQ4X_PIXEL23_13; - *qNNN3 = HQ4X_PIXEL33_11; - } - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_32; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_82; - break; - } - case 84: - case 85: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_81; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *q3 = HQ4X_PIXEL03_81; - *qN3 = HQ4X_PIXEL13_31; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - } else { - *q3 = HQ4X_PIXEL03_12; - *qN3 = HQ4X_PIXEL13_14; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_83; - *qNNN2 = HQ4X_PIXEL32_21; - *qNNN3 = HQ4X_PIXEL33_50; - } - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_31; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - break; - } - case 112: - case 113: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - } else { - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_21; - *qNNN = HQ4X_PIXEL30_11; - *qNNN1 = HQ4X_PIXEL31_13; - *qNNN2 = HQ4X_PIXEL32_83; - *qNNN3 = HQ4X_PIXEL33_50; - } - break; - } - case 200: - case 204: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - } else { - *qNN = HQ4X_PIXEL20_21; - *qNN1 = HQ4X_PIXEL21_70; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_83; - *qNNN2 = HQ4X_PIXEL32_14; - *qNNN3 = HQ4X_PIXEL33_12; - } - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - break; - } - case 73: - case 77: - { - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *q = HQ4X_PIXEL00_82; - *qN = HQ4X_PIXEL10_32; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - } else { - *q = HQ4X_PIXEL00_11; - *qN = HQ4X_PIXEL10_13; - *qNN = HQ4X_PIXEL20_83; - *qNN1 = HQ4X_PIXEL21_70; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_21; - } - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 42: - case 170: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qNN = HQ4X_PIXEL20_31; - *qNNN = HQ4X_PIXEL30_81; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_21; - *qN = HQ4X_PIXEL10_83; - *qN1 = HQ4X_PIXEL11_70; - *qNN = HQ4X_PIXEL20_14; - *qNNN = HQ4X_PIXEL30_12; - } - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 14: - case 142: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_83; - *q2 = HQ4X_PIXEL02_13; - *q3 = HQ4X_PIXEL03_11; - *qN = HQ4X_PIXEL10_21; - *qN1 = HQ4X_PIXEL11_70; - } - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 67: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 70: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 28: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 152: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 194: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 98: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 56: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 25: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 26: - case 31: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN3 = HQ4X_PIXEL13_50; - } - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_0; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 82: - case 214: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN3 = HQ4X_PIXEL13_50; - } - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_0; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - break; - } - case 88: - case 248: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - break; - } - case 74: - case 107: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - } - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 27: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - } - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 86: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN3 = HQ4X_PIXEL13_50; - } - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_0; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 216: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - break; - } - case 106: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 30: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN3 = HQ4X_PIXEL13_50; - } - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_0; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 210: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - break; - } - case 120: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 75: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - } - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 29: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 198: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 184: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 99: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 57: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 71: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 156: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 226: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 60: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 195: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 102: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 153: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 58: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - } else { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_12; - *qN = HQ4X_PIXEL10_11; - *qN1 = HQ4X_PIXEL11_0; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - } else { - *q2 = HQ4X_PIXEL02_11; - *q3 = HQ4X_PIXEL03_20; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_12; - } - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 83: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - } else { - *q2 = HQ4X_PIXEL02_11; - *q3 = HQ4X_PIXEL03_20; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_12; - } - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - } else { - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_11; - *qNNN2 = HQ4X_PIXEL32_12; - *qNNN3 = HQ4X_PIXEL33_20; - } - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - break; - } - case 92: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - } else { - *qNN = HQ4X_PIXEL20_12; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_11; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - } else { - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_11; - *qNNN2 = HQ4X_PIXEL32_12; - *qNNN3 = HQ4X_PIXEL33_20; - } - break; - } - case 202: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - } else { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_12; - *qN = HQ4X_PIXEL10_11; - *qN1 = HQ4X_PIXEL11_0; - } - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - } else { - *qNN = HQ4X_PIXEL20_12; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_11; - } - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 78: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - } else { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_12; - *qN = HQ4X_PIXEL10_11; - *qN1 = HQ4X_PIXEL11_0; - } - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - } else { - *qNN = HQ4X_PIXEL20_12; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_11; - } - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 154: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - } else { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_12; - *qN = HQ4X_PIXEL10_11; - *qN1 = HQ4X_PIXEL11_0; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - } else { - *q2 = HQ4X_PIXEL02_11; - *q3 = HQ4X_PIXEL03_20; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_12; - } - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 114: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - } else { - *q2 = HQ4X_PIXEL02_11; - *q3 = HQ4X_PIXEL03_20; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_12; - } - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - } else { - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_11; - *qNNN2 = HQ4X_PIXEL32_12; - *qNNN3 = HQ4X_PIXEL33_20; - } - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - break; - } - case 89: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - } else { - *qNN = HQ4X_PIXEL20_12; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_11; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - } else { - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_11; - *qNNN2 = HQ4X_PIXEL32_12; - *qNNN3 = HQ4X_PIXEL33_20; - } - break; - } - case 90: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - } else { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_12; - *qN = HQ4X_PIXEL10_11; - *qN1 = HQ4X_PIXEL11_0; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - } else { - *q2 = HQ4X_PIXEL02_11; - *q3 = HQ4X_PIXEL03_20; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_12; - } - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - } else { - *qNN = HQ4X_PIXEL20_12; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_11; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - } else { - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_11; - *qNNN2 = HQ4X_PIXEL32_12; - *qNNN3 = HQ4X_PIXEL33_20; - } - break; - } - case 55: - case 23: - { - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q = HQ4X_PIXEL00_12; - *q1 = HQ4X_PIXEL01_14; - *q2 = HQ4X_PIXEL02_83; - *q3 = HQ4X_PIXEL03_50; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_21; - } - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 182: - case 150: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_0; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN3 = HQ4X_PIXEL33_82; - } else { - *q2 = HQ4X_PIXEL02_21; - *q3 = HQ4X_PIXEL03_50; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_83; - *qNN3 = HQ4X_PIXEL23_13; - *qNNN3 = HQ4X_PIXEL33_11; - } - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_32; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_82; - break; - } - case 213: - case 212: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_81; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *q3 = HQ4X_PIXEL03_81; - *qN3 = HQ4X_PIXEL13_31; - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *q3 = HQ4X_PIXEL03_12; - *qN3 = HQ4X_PIXEL13_14; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_83; - *qNNN2 = HQ4X_PIXEL32_21; - *qNNN3 = HQ4X_PIXEL33_50; - } - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_31; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - break; - } - case 241: - case 240: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_0; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_21; - *qNNN = HQ4X_PIXEL30_11; - *qNNN1 = HQ4X_PIXEL31_13; - *qNNN2 = HQ4X_PIXEL32_83; - *qNNN3 = HQ4X_PIXEL33_50; - } - break; - } - case 236: - case 232: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - } else { - *qNN = HQ4X_PIXEL20_21; - *qNN1 = HQ4X_PIXEL21_70; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_83; - *qNNN2 = HQ4X_PIXEL32_14; - *qNNN3 = HQ4X_PIXEL33_12; - } - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - break; - } - case 109: - case 105: - { - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *q = HQ4X_PIXEL00_82; - *qN = HQ4X_PIXEL10_32; - *qNN = HQ4X_PIXEL20_0; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *q = HQ4X_PIXEL00_11; - *qN = HQ4X_PIXEL10_13; - *qNN = HQ4X_PIXEL20_83; - *qNN1 = HQ4X_PIXEL21_70; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_21; - } - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 171: - case 43: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - *qN1 = HQ4X_PIXEL11_0; - *qNN = HQ4X_PIXEL20_31; - *qNNN = HQ4X_PIXEL30_81; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_21; - *qN = HQ4X_PIXEL10_83; - *qN1 = HQ4X_PIXEL11_70; - *qNN = HQ4X_PIXEL20_14; - *qNNN = HQ4X_PIXEL30_12; - } - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 143: - case 15: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_0; - *qN1 = HQ4X_PIXEL11_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_83; - *q2 = HQ4X_PIXEL02_13; - *q3 = HQ4X_PIXEL03_11; - *qN = HQ4X_PIXEL10_21; - *qN1 = HQ4X_PIXEL11_70; - } - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 124: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 203: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - } - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 62: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN3 = HQ4X_PIXEL13_50; - } - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_0; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 211: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - break; - } - case 118: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN3 = HQ4X_PIXEL13_50; - } - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_0; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 217: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - break; - } - case 110: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 155: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - } - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 188: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 185: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 61: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 157: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 103: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 227: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 230: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 199: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 220: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - } else { - *qNN = HQ4X_PIXEL20_12; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_11; - } - *qNN2 = HQ4X_PIXEL22_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - break; - } - case 158: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - } else { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_12; - *qN = HQ4X_PIXEL10_11; - *qN1 = HQ4X_PIXEL11_0; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN3 = HQ4X_PIXEL13_50; - } - *qN2 = HQ4X_PIXEL12_0; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 234: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - } else { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_12; - *qN = HQ4X_PIXEL10_11; - *qN1 = HQ4X_PIXEL11_0; - } - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 242: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - } else { - *q2 = HQ4X_PIXEL02_11; - *q3 = HQ4X_PIXEL03_20; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_12; - } - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - *qNN2 = HQ4X_PIXEL22_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - break; - } - case 59: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - } else { - *q2 = HQ4X_PIXEL02_11; - *q3 = HQ4X_PIXEL03_20; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_12; - } - *qN1 = HQ4X_PIXEL11_0; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 121: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN1 = HQ4X_PIXEL21_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - } else { - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_11; - *qNNN2 = HQ4X_PIXEL32_12; - *qNNN3 = HQ4X_PIXEL33_20; - } - break; - } - case 87: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN3 = HQ4X_PIXEL13_50; - } - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qN2 = HQ4X_PIXEL12_0; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - } else { - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_11; - *qNNN2 = HQ4X_PIXEL32_12; - *qNNN3 = HQ4X_PIXEL33_20; - } - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - break; - } - case 79: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - } - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - } else { - *qNN = HQ4X_PIXEL20_12; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_11; - } - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 122: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - } else { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_12; - *qN = HQ4X_PIXEL10_11; - *qN1 = HQ4X_PIXEL11_0; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - } else { - *q2 = HQ4X_PIXEL02_11; - *q3 = HQ4X_PIXEL03_20; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_12; - } - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN1 = HQ4X_PIXEL21_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - } else { - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_11; - *qNNN2 = HQ4X_PIXEL32_12; - *qNNN3 = HQ4X_PIXEL33_20; - } - break; - } - case 94: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - } else { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_12; - *qN = HQ4X_PIXEL10_11; - *qN1 = HQ4X_PIXEL11_0; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN3 = HQ4X_PIXEL13_50; - } - *qN2 = HQ4X_PIXEL12_0; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - } else { - *qNN = HQ4X_PIXEL20_12; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_11; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - } else { - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_11; - *qNNN2 = HQ4X_PIXEL32_12; - *qNNN3 = HQ4X_PIXEL33_20; - } - break; - } - case 218: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - } else { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_12; - *qN = HQ4X_PIXEL10_11; - *qN1 = HQ4X_PIXEL11_0; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - } else { - *q2 = HQ4X_PIXEL02_11; - *q3 = HQ4X_PIXEL03_20; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_12; - } - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - } else { - *qNN = HQ4X_PIXEL20_12; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_11; - } - *qNN2 = HQ4X_PIXEL22_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - break; - } - case 91: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - } else { - *q2 = HQ4X_PIXEL02_11; - *q3 = HQ4X_PIXEL03_20; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_12; - } - *qN1 = HQ4X_PIXEL11_0; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - } else { - *qNN = HQ4X_PIXEL20_12; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_11; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - } else { - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_11; - *qNNN2 = HQ4X_PIXEL32_12; - *qNNN3 = HQ4X_PIXEL33_20; - } - break; - } - case 229: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 167: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 173: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 181: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 186: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - } else { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_12; - *qN = HQ4X_PIXEL10_11; - *qN1 = HQ4X_PIXEL11_0; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - } else { - *q2 = HQ4X_PIXEL02_11; - *q3 = HQ4X_PIXEL03_20; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_12; - } - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 115: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - } else { - *q2 = HQ4X_PIXEL02_11; - *q3 = HQ4X_PIXEL03_20; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_12; - } - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - } else { - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_11; - *qNNN2 = HQ4X_PIXEL32_12; - *qNNN3 = HQ4X_PIXEL33_20; - } - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - break; - } - case 93: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - } else { - *qNN = HQ4X_PIXEL20_12; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_11; - } - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - } else { - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_11; - *qNNN2 = HQ4X_PIXEL32_12; - *qNNN3 = HQ4X_PIXEL33_20; - } - break; - } - case 206: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - } else { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_12; - *qN = HQ4X_PIXEL10_11; - *qN1 = HQ4X_PIXEL11_0; - } - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - } else { - *qNN = HQ4X_PIXEL20_12; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_11; - } - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 205: - case 201: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - } else { - *qNN = HQ4X_PIXEL20_12; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_11; - } - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 174: - case 46: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - } else { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_12; - *qN = HQ4X_PIXEL10_11; - *qN1 = HQ4X_PIXEL11_0; - } - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 179: - case 147: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - } else { - *q2 = HQ4X_PIXEL02_11; - *q3 = HQ4X_PIXEL03_20; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_12; - } - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 117: - case 116: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - } else { - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_11; - *qNNN2 = HQ4X_PIXEL32_12; - *qNNN3 = HQ4X_PIXEL33_20; - } - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - break; - } - case 189: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 231: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 126: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN3 = HQ4X_PIXEL13_50; - } - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_0; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 219: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - } - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - break; - } - case 125: - { - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *q = HQ4X_PIXEL00_82; - *qN = HQ4X_PIXEL10_32; - *qNN = HQ4X_PIXEL20_0; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *q = HQ4X_PIXEL00_11; - *qN = HQ4X_PIXEL10_13; - *qNN = HQ4X_PIXEL20_83; - *qNN1 = HQ4X_PIXEL21_70; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_21; - } - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 221: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_81; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *q3 = HQ4X_PIXEL03_81; - *qN3 = HQ4X_PIXEL13_31; - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *q3 = HQ4X_PIXEL03_12; - *qN3 = HQ4X_PIXEL13_14; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_83; - *qNNN2 = HQ4X_PIXEL32_21; - *qNNN3 = HQ4X_PIXEL33_50; - } - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_31; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - break; - } - case 207: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_0; - *qN1 = HQ4X_PIXEL11_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_83; - *q2 = HQ4X_PIXEL02_13; - *q3 = HQ4X_PIXEL03_11; - *qN = HQ4X_PIXEL10_21; - *qN1 = HQ4X_PIXEL11_70; - } - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 238: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNN1 = HQ4X_PIXEL21_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - } else { - *qNN = HQ4X_PIXEL20_21; - *qNN1 = HQ4X_PIXEL21_70; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_83; - *qNNN2 = HQ4X_PIXEL32_14; - *qNNN3 = HQ4X_PIXEL33_12; - } - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - break; - } - case 190: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_0; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN3 = HQ4X_PIXEL33_82; - } else { - *q2 = HQ4X_PIXEL02_21; - *q3 = HQ4X_PIXEL03_50; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_83; - *qNN3 = HQ4X_PIXEL23_13; - *qNNN3 = HQ4X_PIXEL33_11; - } - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_32; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_82; - break; - } - case 187: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - *qN1 = HQ4X_PIXEL11_0; - *qNN = HQ4X_PIXEL20_31; - *qNNN = HQ4X_PIXEL30_81; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_21; - *qN = HQ4X_PIXEL10_83; - *qN1 = HQ4X_PIXEL11_70; - *qNN = HQ4X_PIXEL20_14; - *qNNN = HQ4X_PIXEL30_12; - } - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 243: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_0; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_21; - *qNNN = HQ4X_PIXEL30_11; - *qNNN1 = HQ4X_PIXEL31_13; - *qNNN2 = HQ4X_PIXEL32_83; - *qNNN3 = HQ4X_PIXEL33_50; - } - break; - } - case 119: - { - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q = HQ4X_PIXEL00_12; - *q1 = HQ4X_PIXEL01_14; - *q2 = HQ4X_PIXEL02_83; - *q3 = HQ4X_PIXEL03_50; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_21; - } - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 237: - case 233: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_60; - *q3 = HQ4X_PIXEL03_20; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_70; - *qN3 = HQ4X_PIXEL13_60; - *qNN = HQ4X_PIXEL20_0; - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNNN = HQ4X_PIXEL30_0; - } else { - *qNNN = HQ4X_PIXEL30_20; - } - *qNNN1 = HQ4X_PIXEL31_0; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 175: - case 47: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - } else { - *q = HQ4X_PIXEL00_20; - } - *q1 = HQ4X_PIXEL01_0; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_0; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_70; - *qNN3 = HQ4X_PIXEL23_60; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_60; - *qNNN3 = HQ4X_PIXEL33_20; - break; - } - case 183: - case 151: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_0; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q3 = HQ4X_PIXEL03_0; - } else { - *q3 = HQ4X_PIXEL03_20; - } - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_0; - *qNN = HQ4X_PIXEL20_60; - *qNN1 = HQ4X_PIXEL21_70; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_20; - *qNNN1 = HQ4X_PIXEL31_60; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 245: - case 244: - { - *q = HQ4X_PIXEL00_20; - *q1 = HQ4X_PIXEL01_60; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_60; - *qN1 = HQ4X_PIXEL11_70; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_0; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNNN3 = HQ4X_PIXEL33_20; - } - break; - } - case 250: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - break; - } - case 123: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - } - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 95: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - } - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN3 = HQ4X_PIXEL13_50; - } - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_0; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 222: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN3 = HQ4X_PIXEL13_50; - } - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_0; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - break; - } - case 252: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_61; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNNN3 = HQ4X_PIXEL33_20; - } - break; - } - case 249: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_61; - *q3 = HQ4X_PIXEL03_80; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_0; - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNNN = HQ4X_PIXEL30_0; - } else { - *qNNN = HQ4X_PIXEL30_20; - } - *qNNN1 = HQ4X_PIXEL31_0; - break; - } - case 235: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - } - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_61; - *qNN = HQ4X_PIXEL20_0; - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNNN = HQ4X_PIXEL30_0; - } else { - *qNNN = HQ4X_PIXEL30_20; - } - *qNNN1 = HQ4X_PIXEL31_0; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 111: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - } else { - *q = HQ4X_PIXEL00_20; - } - *q1 = HQ4X_PIXEL01_0; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_0; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_61; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 63: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - } else { - *q = HQ4X_PIXEL00_20; - } - *q1 = HQ4X_PIXEL01_0; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN3 = HQ4X_PIXEL13_50; - } - *qN = HQ4X_PIXEL10_0; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_0; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_61; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 159: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - } - *q2 = HQ4X_PIXEL02_0; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q3 = HQ4X_PIXEL03_0; - } else { - *q3 = HQ4X_PIXEL03_20; - } - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_0; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_61; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 215: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_0; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q3 = HQ4X_PIXEL03_0; - } else { - *q3 = HQ4X_PIXEL03_20; - } - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_0; - *qNN = HQ4X_PIXEL20_61; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - break; - } - case 246: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN3 = HQ4X_PIXEL13_50; - } - *qN = HQ4X_PIXEL10_61; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_0; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_0; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNNN3 = HQ4X_PIXEL33_20; - } - break; - } - case 254: - { - *q = HQ4X_PIXEL00_80; - *q1 = HQ4X_PIXEL01_10; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN3 = HQ4X_PIXEL13_50; - } - *qN = HQ4X_PIXEL10_10; - *qN1 = HQ4X_PIXEL11_30; - *qN2 = HQ4X_PIXEL12_0; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNNN3 = HQ4X_PIXEL33_20; - } - break; - } - case 253: - { - *q = HQ4X_PIXEL00_82; - *q1 = HQ4X_PIXEL01_82; - *q2 = HQ4X_PIXEL02_81; - *q3 = HQ4X_PIXEL03_81; - *qN = HQ4X_PIXEL10_32; - *qN1 = HQ4X_PIXEL11_32; - *qN2 = HQ4X_PIXEL12_31; - *qN3 = HQ4X_PIXEL13_31; - *qNN = HQ4X_PIXEL20_0; - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_0; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNNN = HQ4X_PIXEL30_0; - } else { - *qNNN = HQ4X_PIXEL30_20; - } - *qNNN1 = HQ4X_PIXEL31_0; - *qNNN2 = HQ4X_PIXEL32_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNNN3 = HQ4X_PIXEL33_20; - } - break; - } - case 251: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - } - *q2 = HQ4X_PIXEL02_10; - *q3 = HQ4X_PIXEL03_80; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_30; - *qN3 = HQ4X_PIXEL13_10; - *qNN = HQ4X_PIXEL20_0; - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNNN = HQ4X_PIXEL30_0; - } else { - *qNNN = HQ4X_PIXEL30_20; - } - *qNNN1 = HQ4X_PIXEL31_0; - break; - } - case 239: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - } else { - *q = HQ4X_PIXEL00_20; - } - *q1 = HQ4X_PIXEL01_0; - *q2 = HQ4X_PIXEL02_32; - *q3 = HQ4X_PIXEL03_82; - *qN = HQ4X_PIXEL10_0; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_32; - *qN3 = HQ4X_PIXEL13_82; - *qNN = HQ4X_PIXEL20_0; - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_31; - *qNN3 = HQ4X_PIXEL23_81; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNNN = HQ4X_PIXEL30_0; - } else { - *qNNN = HQ4X_PIXEL30_20; - } - *qNNN1 = HQ4X_PIXEL31_0; - *qNNN2 = HQ4X_PIXEL32_31; - *qNNN3 = HQ4X_PIXEL33_81; - break; - } - case 127: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - } else { - *q = HQ4X_PIXEL00_20; - } - *q1 = HQ4X_PIXEL01_0; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q2 = HQ4X_PIXEL02_0; - *q3 = HQ4X_PIXEL03_0; - *qN3 = HQ4X_PIXEL13_0; - } else { - *q2 = HQ4X_PIXEL02_50; - *q3 = HQ4X_PIXEL03_50; - *qN3 = HQ4X_PIXEL13_50; - } - *qN = HQ4X_PIXEL10_0; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_0; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNN = HQ4X_PIXEL20_0; - *qNNN = HQ4X_PIXEL30_0; - *qNNN1 = HQ4X_PIXEL31_0; - } else { - *qNN = HQ4X_PIXEL20_50; - *qNNN = HQ4X_PIXEL30_50; - *qNNN1 = HQ4X_PIXEL31_50; - } - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_30; - *qNN3 = HQ4X_PIXEL23_10; - *qNNN2 = HQ4X_PIXEL32_10; - *qNNN3 = HQ4X_PIXEL33_80; - break; - } - case 191: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - } else { - *q = HQ4X_PIXEL00_20; - } - *q1 = HQ4X_PIXEL01_0; - *q2 = HQ4X_PIXEL02_0; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q3 = HQ4X_PIXEL03_0; - } else { - *q3 = HQ4X_PIXEL03_20; - } - *qN = HQ4X_PIXEL10_0; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_0; - *qNN = HQ4X_PIXEL20_31; - *qNN1 = HQ4X_PIXEL21_31; - *qNN2 = HQ4X_PIXEL22_32; - *qNN3 = HQ4X_PIXEL23_32; - *qNNN = HQ4X_PIXEL30_81; - *qNNN1 = HQ4X_PIXEL31_81; - *qNNN2 = HQ4X_PIXEL32_82; - *qNNN3 = HQ4X_PIXEL33_82; - break; - } - case 223: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - *q1 = HQ4X_PIXEL01_0; - *qN = HQ4X_PIXEL10_0; - } else { - *q = HQ4X_PIXEL00_50; - *q1 = HQ4X_PIXEL01_50; - *qN = HQ4X_PIXEL10_50; - } - *q2 = HQ4X_PIXEL02_0; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q3 = HQ4X_PIXEL03_0; - } else { - *q3 = HQ4X_PIXEL03_20; - } - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_0; - *qNN = HQ4X_PIXEL20_10; - *qNN1 = HQ4X_PIXEL21_30; - *qNN2 = HQ4X_PIXEL22_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNN3 = HQ4X_PIXEL23_0; - *qNNN2 = HQ4X_PIXEL32_0; - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNN3 = HQ4X_PIXEL23_50; - *qNNN2 = HQ4X_PIXEL32_50; - *qNNN3 = HQ4X_PIXEL33_50; - } - *qNNN = HQ4X_PIXEL30_80; - *qNNN1 = HQ4X_PIXEL31_10; - break; - } - case 247: - { - *q = HQ4X_PIXEL00_81; - *q1 = HQ4X_PIXEL01_31; - *q2 = HQ4X_PIXEL02_0; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q3 = HQ4X_PIXEL03_0; - } else { - *q3 = HQ4X_PIXEL03_20; - } - *qN = HQ4X_PIXEL10_81; - *qN1 = HQ4X_PIXEL11_31; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_0; - *qNN = HQ4X_PIXEL20_82; - *qNN1 = HQ4X_PIXEL21_32; - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_0; - *qNNN = HQ4X_PIXEL30_82; - *qNNN1 = HQ4X_PIXEL31_32; - *qNNN2 = HQ4X_PIXEL32_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNNN3 = HQ4X_PIXEL33_20; - } - break; - } - case 255: - { - if( HQ_YUVDIFF( y[4], u[4], v[4], y[2], u[2], v[2] ) ) { - *q = HQ4X_PIXEL00_0; - } else { - *q = HQ4X_PIXEL00_20; - } - *q1 = HQ4X_PIXEL01_0; - *q2 = HQ4X_PIXEL02_0; - if( HQ_YUVDIFF( y[2], u[2], v[2], y[6], u[6], v[6] ) ) { - *q3 = HQ4X_PIXEL03_0; - } else { - *q3 = HQ4X_PIXEL03_20; - } - *qN = HQ4X_PIXEL10_0; - *qN1 = HQ4X_PIXEL11_0; - *qN2 = HQ4X_PIXEL12_0; - *qN3 = HQ4X_PIXEL13_0; - *qNN = HQ4X_PIXEL20_0; - *qNN1 = HQ4X_PIXEL21_0; - *qNN2 = HQ4X_PIXEL22_0; - *qNN3 = HQ4X_PIXEL23_0; - if( HQ_YUVDIFF( y[8], u[8], v[8], y[4], u[4], v[4] ) ) { - *qNNN = HQ4X_PIXEL30_0; - } else { - *qNNN = HQ4X_PIXEL30_20; - } - *qNNN1 = HQ4X_PIXEL31_0; - *qNNN2 = HQ4X_PIXEL32_0; - if( HQ_YUVDIFF( y[6], u[6], v[6], y[8], u[8], v[8] ) ) { - *qNNN3 = HQ4X_PIXEL33_0; - } else { - *qNNN3 = HQ4X_PIXEL33_20; - } - break; - } - - } diff --git a/fuse/ui/scaler/scaler_internals.h b/fuse/ui/scaler/scaler_internals.h deleted file mode 100644 index a9245e7..0000000 --- a/fuse/ui/scaler/scaler_internals.h +++ /dev/null @@ -1,71 +0,0 @@ -/* scaler_internals.h: functions internal to the scaler code - Copyright (c) 2003 Fredrick Meunier, Philip Kendall - - Originally taken from ScummVM - Scumm Interpreter - Copyright (C) 2001 Ludvig Strigeus - Copyright (C) 2001/2002 The ScummVM project - - HQ2x, HQ3x and HQ4x scalers taken from HiEnd3D Demos (http://www.hiend3d.com) - Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#ifndef FUSE_SCALER_INTERNALS_H -#define FUSE_SCALER_INTERNALS_H - -#define DECLARE_SCALER( name ) \ - extern void scaler_##name##_16( const libspectrum_byte *srcPtr, \ - libspectrum_dword srcPitch, \ - libspectrum_byte *dstPtr, \ - libspectrum_dword dstPitch, \ - int width, int height ); \ - extern void scaler_##name##_32( const libspectrum_byte *srcPtr, \ - libspectrum_dword srcPitch, \ - libspectrum_byte *dstPtr, \ - libspectrum_dword dstPitch, \ - int width, int height ); - -DECLARE_SCALER(2xSaI); -DECLARE_SCALER(Super2xSaI); -DECLARE_SCALER(SuperEagle); -DECLARE_SCALER(AdvMame2x); -DECLARE_SCALER(AdvMame3x); -DECLARE_SCALER(Half); -DECLARE_SCALER(HalfSkip); -DECLARE_SCALER(Normal1x); -DECLARE_SCALER(Normal2x); -DECLARE_SCALER(Normal3x); -DECLARE_SCALER(Normal4x); -DECLARE_SCALER(Timex1_5x); -DECLARE_SCALER(TV2x); -DECLARE_SCALER(TV3x); -DECLARE_SCALER(TV4x); -DECLARE_SCALER(TimexTV); -DECLARE_SCALER(DotMatrix); -DECLARE_SCALER(PalTV); -DECLARE_SCALER(PalTV2x); -DECLARE_SCALER(PalTV3x); -DECLARE_SCALER(PalTV4x); -DECLARE_SCALER(HQ2x); -DECLARE_SCALER(HQ3x); -DECLARE_SCALER(HQ4x); - -#endif /* #ifndef FUSE_SCALER_INTERNALS_H */ diff --git a/fuse/ui/scaler/scalers.c b/fuse/ui/scaler/scalers.c deleted file mode 100644 index 921cff1..0000000 --- a/fuse/ui/scaler/scalers.c +++ /dev/null @@ -1,2371 +0,0 @@ -/* scalers.c: the actual graphics scalers - * Copyright (C) 2003-2015 Fredrick Meunier, Philip Kendall, Gergely Szasz - * - * Originally taken from ScummVM - Scumm Interpreter - * Copyright (C) 2001 Ludvig Strigeus - * Copyright (C) 2001-2003 The ScummVM project - * - * HQ2x, HQ3x and HQ4x scalers taken from HiEnd3D Demos (http://www.hiend3d.com) - * Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include - -#include - -#include - -#include "scaler.h" -#include "scaler_internals.h" -#include "settings.h" -#include "ui/ui.h" -#include "ui/uidisplay.h" - -#ifndef MIN -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) -#endif - -#ifndef ABS -#define ABS(x) ((x)>=0?(x):-(x)) -#endif - -/* The actual code for the scalers starts here */ - -#if SCALER_DATA_SIZE == 2 - -typedef libspectrum_word scaler_data_type; -#define FUNCTION( name ) name##_16 - -static libspectrum_dword colorMask; -static libspectrum_dword lowPixelMask; -static libspectrum_dword qcolorMask; -static libspectrum_dword qlowpixelMask; -static libspectrum_dword redblueMask; -static libspectrum_dword redblue8_Mask; -static libspectrum_dword redblue16_Mask; -static libspectrum_dword redMask; -static libspectrum_dword greenMask; -static libspectrum_dword green8_Mask; -static libspectrum_dword green16_Mask; -static libspectrum_dword blueMask; -static int green6bit; - -static const libspectrum_word dotmatrix_565[16] = { - 0x01E0, 0x0007, 0x3800, 0x0000, - 0x39E7, 0x0000, 0x39E7, 0x0000, - 0x3800, 0x0000, 0x01E0, 0x0007, - 0x39E7, 0x0000, 0x39E7, 0x0000 -}; -static const libspectrum_word dotmatrix_555[16] = { - 0x00E0, 0x0007, 0x1C00, 0x0000, - 0x1CE7, 0x0000, 0x1CE7, 0x0000, - 0x1C00, 0x0000, 0x00E0, 0x0007, - 0x1CE7, 0x0000, 0x1CE7, 0x0000 -}; -static const libspectrum_word *dotmatrix; - -int -scaler_select_bitformat( libspectrum_dword BitFormat ) -{ - switch( BitFormat ) { - - /* FIXME(?): there is an assumption here that our colour fields - are (*) xxxx|xyyy|yyyz|zzzz for the 565 mode - and (*) xxxx|xyyy|yyzz|zzz0 for the 555 mode, where (*) is the - least significant bit on LSB machines and the most significant - bit on MSB machines. This is currently (April 2003) OK as the - only user interface to use this code is SDL, which hides all - variation in SDL_MapRGB(3), but be very careful (especially - about endianness) if we ever use the "interpolating" scalers - from another user interface */ - - case 565: - colorMask = 0x0000F7DE; - lowPixelMask = 0x00000821; - qcolorMask = 0x0000E79C; - qlowpixelMask = 0x00001863; - redblueMask = 0x0000F81F; - redblue8_Mask = 0x0007C0F8; - redblue16_Mask = 0x000F81F0; - green6bit = 1; - redMask = 0x0000001F; - greenMask = 0x000007E0; - green8_Mask = 0x00003F00; - green16_Mask = 0x00007E00; - blueMask = 0x0000F800; - dotmatrix = dotmatrix_565; - break; - - case 555: - colorMask = 0x00007BDE; - lowPixelMask = 0x00000421; - qcolorMask = 0x0000739C; - qlowpixelMask = 0x00000C63; - redblueMask = 0x00007C1F; - redblue8_Mask = 0x0003E0F8; - redblue16_Mask = 0x0007C1F0; - green6bit = 0; - redMask = 0x0000001F; - greenMask = 0x000003E0; - green8_Mask = 0x00001F00; - green16_Mask = 0x00003E00; - blueMask = 0x00007C00; - dotmatrix = dotmatrix_555; - break; - - default: - ui_error( UI_ERROR_ERROR, "unknown bitformat %d", BitFormat ); - return 1; - - } - - return 0; -} - -#elif SCALER_DATA_SIZE == 4 /* #if SCALER_DATA_SIZE == 2 */ - -typedef libspectrum_dword scaler_data_type; -#define FUNCTION( name ) name##_32 - -/* The assumption here is that the colour fields are laid out in - memory as (LSB) red|green|blue|padding (MSB). We wish to access - these as 32-bit entities, so make sure we get our masks the right - way round. */ - -#ifdef WORDS_BIGENDIAN - -static const libspectrum_dword colorMask = 0xFEFEFE00; -static const libspectrum_dword lowPixelMask = 0x01010100; -static const libspectrum_dword qcolorMask = 0xFCFCFC00; -static const libspectrum_dword qlowpixelMask = 0x03030300; -static const libspectrum_qword redblueMask = 0xFF00FF00; -static const libspectrum_dword redblue8_Mask = 0xF807F807; -static const libspectrum_dword redblue16_Mask = 0x0FF00FF0; -static const libspectrum_dword redMask = 0xFF000000; -static const libspectrum_dword greenMask = 0x00FF0000; -static const libspectrum_dword blueMask = 0x0000FF00; -static const libspectrum_dword green8_Mask = 0x008F0700; -static const libspectrum_dword green16_Mask = 0x000FF000; - -static const libspectrum_dword dotmatrix[16] = { - 0x003F0000, 0x00003F00, 0x3F000000, 0x00000000, - 0x3F3F3F00, 0x00000000, 0x3F3F3F00, 0x00000000, - 0x3F000000, 0x00000000, 0x003F0000, 0x00003F00, - 0x3F3F3F00, 0x00000000, 0x3F3F3F00, 0x00000000 -}; - -#else /* #ifdef WORDS_BIGENDIAN */ - -static const libspectrum_dword colorMask = 0x00FEFEFE; -static const libspectrum_dword lowPixelMask = 0x00010101; -static const libspectrum_dword qcolorMask = 0x00FCFCFC; -static const libspectrum_dword qlowpixelMask = 0x00030303; -static const libspectrum_qword redblueMask = 0x00FF00FF; -static const libspectrum_dword redblue8_Mask = 0x07F807F8; -static const libspectrum_dword redblue16_Mask = 0x0FF00FF0; -static const libspectrum_dword redMask = 0x000000FF; -static const libspectrum_dword greenMask = 0x0000FF00; -static const libspectrum_dword blueMask = 0x00FF0000; -static const libspectrum_dword green8_Mask = 0x0007F800; -static const libspectrum_dword green16_Mask = 0x000FF000; - -static const libspectrum_dword dotmatrix[16] = { - 0x00003F00, 0x003F0000, 0x0000003F, 0x00000000, - 0x003F3F3F, 0x00000000, 0x003F3F3F, 0x00000000, - 0x0000003F, 0x00000000, 0x00003F00, 0x003F0000, - 0x003F3F3F, 0x00000000, 0x003F3F3F, 0x00000000 -}; - -#endif /* #ifdef WORDS_BIGENDIAN */ - -#else /* #if SCALER_DATA_SIZE == 2 or 4 */ -#error Unknown SCALER_DATA_SIZE -#endif /* #if SCALER_DATA_SIZE == 2 or 4 */ - -static inline int -GetResult( libspectrum_dword A, libspectrum_dword B, libspectrum_dword C, - libspectrum_dword D ) -{ - const int ac = (A==C); - const int bc = (B==C); - const int x1 = ac; - const int y1 = (bc & !ac); - const int ad = (A==D); - const int bd = (B==D); - const int x2 = ad; - const int y2 = (bd & !ad); - const int x = x1+x2; - const int y = y1+y2; - static const int rmap[3][3] = { - {0, 0, -1}, - {0, 0, -1}, - {1, 1, 0} - }; - return rmap[y][x]; -} - -static inline libspectrum_dword -INTERPOLATE( libspectrum_dword A, libspectrum_dword B ) -{ - if (A != B) { - return (((A & colorMask) >> 1) + ((B & colorMask) >> 1) + (A & B & lowPixelMask)); - } else - return A; -} - -static inline libspectrum_dword -Q_INTERPOLATE( libspectrum_dword A, libspectrum_dword B, libspectrum_dword C, - libspectrum_dword D ) -{ - register libspectrum_dword x = ((A & qcolorMask) >> 2) + - ((B & qcolorMask) >> 2) + ((C & qcolorMask) >> 2) + ((D & qcolorMask) >> 2); - register libspectrum_dword y = (A & qlowpixelMask) + - (B & qlowpixelMask) + (C & qlowpixelMask) + (D & qlowpixelMask); - - y = (y >> 2) & qlowpixelMask; - return x + y; -} - -/* HQ scalers */ -#define HQ_INTERPOLATE_1(A,B) Q_INTERPOLATE(A,A,A,B) - -#define HQ_INTERPOLATE_2(A,B,C) Q_INTERPOLATE(A,A,B,C) - -static inline libspectrum_dword -HQ_INTERPOLATE_3( libspectrum_dword A, libspectrum_dword B ) -{ - return ( ( ( ( A & greenMask ) * 7 + ( B & greenMask) ) & green8_Mask ) + - ( ( ( A & redblueMask ) * 7 + ( B & redblueMask ) ) & redblue8_Mask ) - ) >> 3; -} - -static inline libspectrum_dword -HQ_INTERPOLATE_4( libspectrum_dword A, libspectrum_dword B, - libspectrum_dword C ) -{ - return ( ( ( ( A & greenMask ) * 2 + ( ( B & greenMask) + - ( C & greenMask ) ) * 7 ) & green16_Mask) + - ( ( ( A & redblueMask ) * 2 + ( ( B & redblueMask ) + - ( C & redblueMask ) ) * 7 ) & redblue16_Mask ) ) >> 4; -} - -#define HQ_INTERPOLATE_5(A,B) INTERPOLATE(A,B) - -static inline libspectrum_dword -HQ_INTERPOLATE_6( libspectrum_dword A, libspectrum_dword B, - libspectrum_dword C ) -{ - return ( ( ( ( A & greenMask ) * 5 + ( B & greenMask) * 2 + - ( C & greenMask ) ) & green8_Mask) + - ( ( ( A & redblueMask ) * 5 + ( B & redblueMask ) * 2 + - ( C & redblueMask ) ) & redblue8_Mask ) ) >> 3; -} - -static inline libspectrum_dword -HQ_INTERPOLATE_7( libspectrum_dword A, libspectrum_dword B, - libspectrum_dword C ) -{ - return ( ( ( ( A & greenMask ) * 6 + ( B & greenMask) + - ( C & greenMask ) ) & green8_Mask) + - ( ( ( A & redblueMask ) * 6 + ( B & redblueMask ) + - ( C & redblueMask ) ) & redblue8_Mask ) ) >> 3; -} - -static inline libspectrum_dword -HQ_INTERPOLATE_8( libspectrum_dword A, libspectrum_dword B ) -{ - return ( ( ( ( A & greenMask ) * 5 + ( B & greenMask) * 3 ) & green8_Mask ) + - ( ( ( A & redblueMask ) * 5 + ( B & redblueMask ) * 3 ) & redblue8_Mask ) - ) >> 3; -} - -static inline libspectrum_dword -HQ_INTERPOLATE_9( libspectrum_dword A, libspectrum_dword B, - libspectrum_dword C ) -{ - return ( ( ( ( A & greenMask ) * 2 + ( ( B & greenMask) + - ( C & greenMask ) ) * 3 ) & green8_Mask) + - ( ( ( A & redblueMask ) * 2 + ( ( B & redblueMask ) + - ( C & redblueMask ) ) * 3 ) & redblue8_Mask ) ) >> 3; -} - -static inline libspectrum_dword -HQ_INTERPOLATE_10( libspectrum_dword A, libspectrum_dword B, - libspectrum_dword C ) -{ - return ( ( ( ( A & greenMask ) * 14 + ( B & greenMask) + - ( C & greenMask ) ) & green16_Mask) + - ( ( ( A & redblueMask ) * 14 + ( B & redblueMask ) + - ( C & redblueMask ) ) & redblue16_Mask ) ) >> 4; -} - -/* dstPtr */ -#define HQ_PIXEL00_0 w[5] -#define HQ_PIXEL00_10 HQ_INTERPOLATE_1(w[5], w[1]) -#define HQ_PIXEL00_11 HQ_INTERPOLATE_1(w[5], w[4]) -#define HQ_PIXEL00_12 HQ_INTERPOLATE_1(w[5], w[2]) -#define HQ_PIXEL00_20 HQ_INTERPOLATE_2(w[5], w[4], w[2]) -#define HQ_PIXEL00_21 HQ_INTERPOLATE_2(w[5], w[1], w[2]) -#define HQ_PIXEL00_22 HQ_INTERPOLATE_2(w[5], w[1], w[4]) -#define HQ_PIXEL00_60 HQ_INTERPOLATE_6(w[5], w[2], w[4]) -#define HQ_PIXEL00_61 HQ_INTERPOLATE_6(w[5], w[4], w[2]) -#define HQ_PIXEL00_70 HQ_INTERPOLATE_7(w[5], w[4], w[2]) -#define HQ_PIXEL00_90 HQ_INTERPOLATE_9(w[5], w[4], w[2]) -#define HQ_PIXEL00_100 HQ_INTERPOLATE_10(w[5], w[4], w[2]) -/* +1 */ -#define HQ_PIXEL01_0 w[5] -#define HQ_PIXEL01_10 HQ_INTERPOLATE_1(w[5], w[3]) -#define HQ_PIXEL01_11 HQ_INTERPOLATE_1(w[5], w[2]) -#define HQ_PIXEL01_12 HQ_INTERPOLATE_1(w[5], w[6]) -#define HQ_PIXEL01_20 HQ_INTERPOLATE_2(w[5], w[2], w[6]) -#define HQ_PIXEL01_21 HQ_INTERPOLATE_2(w[5], w[3], w[6]) -#define HQ_PIXEL01_22 HQ_INTERPOLATE_2(w[5], w[3], w[2]) -#define HQ_PIXEL01_60 HQ_INTERPOLATE_6(w[5], w[6], w[2]) -#define HQ_PIXEL01_61 HQ_INTERPOLATE_6(w[5], w[2], w[6]) -#define HQ_PIXEL01_70 HQ_INTERPOLATE_7(w[5], w[2], w[6]) -#define HQ_PIXEL01_90 HQ_INTERPOLATE_9(w[5], w[2], w[6]) -#define HQ_PIXEL01_100 HQ_INTERPOLATE_10(w[5], w[2], w[6]) -/* +dstPitch */ -#define HQ_PIXEL10_0 w[5] -#define HQ_PIXEL10_10 HQ_INTERPOLATE_1(w[5], w[7]) -#define HQ_PIXEL10_11 HQ_INTERPOLATE_1(w[5], w[8]) -#define HQ_PIXEL10_12 HQ_INTERPOLATE_1(w[5], w[4]) -#define HQ_PIXEL10_20 HQ_INTERPOLATE_2(w[5], w[8], w[4]) -#define HQ_PIXEL10_21 HQ_INTERPOLATE_2(w[5], w[7], w[4]) -#define HQ_PIXEL10_22 HQ_INTERPOLATE_2(w[5], w[7], w[8]) -#define HQ_PIXEL10_60 HQ_INTERPOLATE_6(w[5], w[4], w[8]) -#define HQ_PIXEL10_61 HQ_INTERPOLATE_6(w[5], w[8], w[4]) -#define HQ_PIXEL10_70 HQ_INTERPOLATE_7(w[5], w[8], w[4]) -#define HQ_PIXEL10_90 HQ_INTERPOLATE_9(w[5], w[8], w[4]) -#define HQ_PIXEL10_100 HQ_INTERPOLATE_10(w[5], w[8], w[4]) -/* +dstPitch+1*/ -#define HQ_PIXEL11_0 w[5] -#define HQ_PIXEL11_10 HQ_INTERPOLATE_1(w[5], w[9]) -#define HQ_PIXEL11_11 HQ_INTERPOLATE_1(w[5], w[6]) -#define HQ_PIXEL11_12 HQ_INTERPOLATE_1(w[5], w[8]) -#define HQ_PIXEL11_20 HQ_INTERPOLATE_2(w[5], w[6], w[8]) -#define HQ_PIXEL11_21 HQ_INTERPOLATE_2(w[5], w[9], w[8]) -#define HQ_PIXEL11_22 HQ_INTERPOLATE_2(w[5], w[9], w[6]) -#define HQ_PIXEL11_60 HQ_INTERPOLATE_6(w[5], w[8], w[6]) -#define HQ_PIXEL11_61 HQ_INTERPOLATE_6(w[5], w[6], w[8]) -#define HQ_PIXEL11_70 HQ_INTERPOLATE_7(w[5], w[6], w[8]) -#define HQ_PIXEL11_90 HQ_INTERPOLATE_9(w[5], w[6], w[8]) -#define HQ_PIXEL11_100 HQ_INTERPOLATE_10(w[5], w[6], w[8]) - -/* dstPtr */ -#define HQ_PIXEL00_1M HQ_INTERPOLATE_1(w[5], w[1]) -#define HQ_PIXEL00_1U HQ_INTERPOLATE_1(w[5], w[2]) -#define HQ_PIXEL00_1L HQ_INTERPOLATE_1(w[5], w[4]) -#define HQ_PIXEL00_2 HQ_INTERPOLATE_2(w[5], w[4], w[2]) -#define HQ_PIXEL00_4 HQ_INTERPOLATE_4(w[5], w[4], w[2]) -#define HQ_PIXEL00_5 HQ_INTERPOLATE_5(w[4], w[2]) -#define HQ_PIXEL00_C w[5] -/* dstPtr+1*/ -#define HQ_PIXEL01_1 HQ_INTERPOLATE_1(w[5], w[2]) -#define HQ_PIXEL01_3 HQ_INTERPOLATE_3(w[5], w[2]) -#define HQ_PIXEL01_6 HQ_INTERPOLATE_1(w[2], w[5]) -#define HQ_PIXEL01_C w[5] -/* dstPtr+2*/ -#define HQ_PIXEL02_1M HQ_INTERPOLATE_1(w[5], w[3]) -#define HQ_PIXEL02_1U HQ_INTERPOLATE_1(w[5], w[2]) -#define HQ_PIXEL02_1R HQ_INTERPOLATE_1(w[5], w[6]) -#define HQ_PIXEL02_2 HQ_INTERPOLATE_2(w[5], w[2], w[6]) -#define HQ_PIXEL02_4 HQ_INTERPOLATE_4(w[5], w[2], w[6]) -#define HQ_PIXEL02_5 HQ_INTERPOLATE_5(w[2], w[6]) -#define HQ_PIXEL02_C w[5] -/* + dstPitch*/ -#define HQ_PIXEL10_1 HQ_INTERPOLATE_1(w[5], w[4]) -#define HQ_PIXEL10_3 HQ_INTERPOLATE_3(w[5], w[4]) -#define HQ_PIXEL10_6 HQ_INTERPOLATE_1(w[4], w[5]) -#define HQ_PIXEL10_C w[5] -/* + dstPitch + 1 */ -#define HQ_PIXEL11 w[5] -/* + dstPitch + 2 */ -#define HQ_PIXEL12_1 HQ_INTERPOLATE_1(w[5], w[6]) -#define HQ_PIXEL12_3 HQ_INTERPOLATE_3(w[5], w[6]) -#define HQ_PIXEL12_6 HQ_INTERPOLATE_1(w[6], w[5]) -#define HQ_PIXEL12_C w[5] -/* + 2*dstPitch */ -#define HQ_PIXEL20_1M HQ_INTERPOLATE_1(w[5], w[7]) -#define HQ_PIXEL20_1D HQ_INTERPOLATE_1(w[5], w[8]) -#define HQ_PIXEL20_1L HQ_INTERPOLATE_1(w[5], w[4]) -#define HQ_PIXEL20_2 HQ_INTERPOLATE_2(w[5], w[8], w[4]) -#define HQ_PIXEL20_4 HQ_INTERPOLATE_4(w[5], w[8], w[4]) -#define HQ_PIXEL20_5 HQ_INTERPOLATE_5(w[8], w[4]) -#define HQ_PIXEL20_C w[5] -/* + 2*dstPitch + 1 */ -#define HQ_PIXEL21_1 HQ_INTERPOLATE_1(w[5], w[8]) -#define HQ_PIXEL21_3 HQ_INTERPOLATE_3(w[5], w[8]) -#define HQ_PIXEL21_6 HQ_INTERPOLATE_1(w[8], w[5]) -#define HQ_PIXEL21_C w[5] -/* + 2*dstPitch + 2 */ -#define HQ_PIXEL22_1M HQ_INTERPOLATE_1(w[5], w[9]) -#define HQ_PIXEL22_1D HQ_INTERPOLATE_1(w[5], w[8]) -#define HQ_PIXEL22_1R HQ_INTERPOLATE_1(w[5], w[6]) -#define HQ_PIXEL22_2 HQ_INTERPOLATE_2(w[5], w[6], w[8]) -#define HQ_PIXEL22_4 HQ_INTERPOLATE_4(w[5], w[6], w[8]) -#define HQ_PIXEL22_5 HQ_INTERPOLATE_5(w[6], w[8]) -#define HQ_PIXEL22_C w[5] - -/* dstPtr */ -#define HQ4X_PIXEL00_0 w[5] -#define HQ4X_PIXEL00_11 HQ_INTERPOLATE_1(w[5], w[4]) -#define HQ4X_PIXEL00_12 HQ_INTERPOLATE_1(w[5], w[2]) -#define HQ4X_PIXEL00_20 HQ_INTERPOLATE_2(w[5], w[2], w[4]) -#define HQ4X_PIXEL00_50 HQ_INTERPOLATE_5(w[2], w[4]) -#define HQ4X_PIXEL00_80 HQ_INTERPOLATE_8(w[5], w[1]) -#define HQ4X_PIXEL00_81 HQ_INTERPOLATE_8(w[5], w[4]) -#define HQ4X_PIXEL00_82 HQ_INTERPOLATE_8(w[5], w[2]) -#define HQ4X_PIXEL01_0 w[5] -#define HQ4X_PIXEL01_10 HQ_INTERPOLATE_1(w[5], w[1]) -#define HQ4X_PIXEL01_12 HQ_INTERPOLATE_1(w[5], w[2]) -#define HQ4X_PIXEL01_14 HQ_INTERPOLATE_1(w[2], w[5]) -#define HQ4X_PIXEL01_21 HQ_INTERPOLATE_2(w[2], w[5], w[4]) -#define HQ4X_PIXEL01_31 HQ_INTERPOLATE_3(w[5], w[4]) -#define HQ4X_PIXEL01_50 HQ_INTERPOLATE_5(w[2], w[5]) -#define HQ4X_PIXEL01_60 HQ_INTERPOLATE_6(w[5], w[2], w[4]) -#define HQ4X_PIXEL01_61 HQ_INTERPOLATE_6(w[5], w[2], w[1]) -#define HQ4X_PIXEL01_82 HQ_INTERPOLATE_8(w[5], w[2]) -#define HQ4X_PIXEL01_83 HQ_INTERPOLATE_8(w[2], w[4]) -#define HQ4X_PIXEL02_0 w[5] -#define HQ4X_PIXEL02_10 HQ_INTERPOLATE_1(w[5], w[3]) -#define HQ4X_PIXEL02_11 HQ_INTERPOLATE_1(w[5], w[2]) -#define HQ4X_PIXEL02_13 HQ_INTERPOLATE_1(w[2], w[5]) -#define HQ4X_PIXEL02_21 HQ_INTERPOLATE_2(w[2], w[5], w[6]) -#define HQ4X_PIXEL02_32 HQ_INTERPOLATE_3(w[5], w[6]) -#define HQ4X_PIXEL02_50 HQ_INTERPOLATE_5(w[2], w[5]) -#define HQ4X_PIXEL02_60 HQ_INTERPOLATE_6(w[5], w[2], w[6]) -#define HQ4X_PIXEL02_61 HQ_INTERPOLATE_6(w[5], w[2], w[3]) -#define HQ4X_PIXEL02_81 HQ_INTERPOLATE_8(w[5], w[2]) -#define HQ4X_PIXEL02_83 HQ_INTERPOLATE_8(w[2], w[6]) -#define HQ4X_PIXEL03_0 w[5] -#define HQ4X_PIXEL03_11 HQ_INTERPOLATE_1(w[5], w[2]) -#define HQ4X_PIXEL03_12 HQ_INTERPOLATE_1(w[5], w[6]) -#define HQ4X_PIXEL03_20 HQ_INTERPOLATE_2(w[5], w[2], w[6]) -#define HQ4X_PIXEL03_50 HQ_INTERPOLATE_5(w[2], w[6]) -#define HQ4X_PIXEL03_80 HQ_INTERPOLATE_8(w[5], w[3]) -#define HQ4X_PIXEL03_81 HQ_INTERPOLATE_8(w[5], w[2]) -#define HQ4X_PIXEL03_82 HQ_INTERPOLATE_8(w[5], w[6]) -/* +dstPitch */ -#define HQ4X_PIXEL10_0 w[5] -#define HQ4X_PIXEL10_10 HQ_INTERPOLATE_1(w[5], w[1]) -#define HQ4X_PIXEL10_11 HQ_INTERPOLATE_1(w[5], w[4]) -#define HQ4X_PIXEL10_13 HQ_INTERPOLATE_1(w[4], w[5]) -#define HQ4X_PIXEL10_21 HQ_INTERPOLATE_2(w[4], w[5], w[2]) -#define HQ4X_PIXEL10_32 HQ_INTERPOLATE_3(w[5], w[2]) -#define HQ4X_PIXEL10_50 HQ_INTERPOLATE_5(w[4], w[5]) -#define HQ4X_PIXEL10_60 HQ_INTERPOLATE_6(w[5], w[4], w[2]) -#define HQ4X_PIXEL10_61 HQ_INTERPOLATE_6(w[5], w[4], w[1]) -#define HQ4X_PIXEL10_81 HQ_INTERPOLATE_8(w[5], w[4]) -#define HQ4X_PIXEL10_83 HQ_INTERPOLATE_8(w[4], w[2]) -#define HQ4X_PIXEL11_0 w[5] -#define HQ4X_PIXEL11_30 HQ_INTERPOLATE_3(w[5], w[1]) -#define HQ4X_PIXEL11_31 HQ_INTERPOLATE_3(w[5], w[4]) -#define HQ4X_PIXEL11_32 HQ_INTERPOLATE_3(w[5], w[2]) -#define HQ4X_PIXEL11_70 HQ_INTERPOLATE_7(w[5], w[4], w[2]) -#define HQ4X_PIXEL12_0 w[5] -#define HQ4X_PIXEL12_30 HQ_INTERPOLATE_3(w[5], w[3]) -#define HQ4X_PIXEL12_31 HQ_INTERPOLATE_3(w[5], w[2]) -#define HQ4X_PIXEL12_32 HQ_INTERPOLATE_3(w[5], w[6]) -#define HQ4X_PIXEL12_70 HQ_INTERPOLATE_7(w[5], w[6], w[2]) -#define HQ4X_PIXEL13_0 w[5] -#define HQ4X_PIXEL13_10 HQ_INTERPOLATE_1(w[5], w[3]) -#define HQ4X_PIXEL13_12 HQ_INTERPOLATE_1(w[5], w[6]) -#define HQ4X_PIXEL13_14 HQ_INTERPOLATE_1(w[6], w[5]) -#define HQ4X_PIXEL13_21 HQ_INTERPOLATE_2(w[6], w[5], w[2]) -#define HQ4X_PIXEL13_31 HQ_INTERPOLATE_3(w[5], w[2]) -#define HQ4X_PIXEL13_50 HQ_INTERPOLATE_5(w[6], w[5]) -#define HQ4X_PIXEL13_60 HQ_INTERPOLATE_6(w[5], w[6], w[2]) -#define HQ4X_PIXEL13_61 HQ_INTERPOLATE_6(w[5], w[6], w[3]) -#define HQ4X_PIXEL13_82 HQ_INTERPOLATE_8(w[5], w[6]) -#define HQ4X_PIXEL13_83 HQ_INTERPOLATE_8(w[6], w[2]) -/* +dstPitch +dstPitch */ -#define HQ4X_PIXEL20_0 w[5] -#define HQ4X_PIXEL20_10 HQ_INTERPOLATE_1(w[5], w[7]) -#define HQ4X_PIXEL20_12 HQ_INTERPOLATE_1(w[5], w[4]) -#define HQ4X_PIXEL20_14 HQ_INTERPOLATE_1(w[4], w[5]) -#define HQ4X_PIXEL20_21 HQ_INTERPOLATE_2(w[4], w[5], w[8]) -#define HQ4X_PIXEL20_31 HQ_INTERPOLATE_3(w[5], w[8]) -#define HQ4X_PIXEL20_50 HQ_INTERPOLATE_5(w[4], w[5]) -#define HQ4X_PIXEL20_60 HQ_INTERPOLATE_6(w[5], w[4], w[8]) -#define HQ4X_PIXEL20_61 HQ_INTERPOLATE_6(w[5], w[4], w[7]) -#define HQ4X_PIXEL20_82 HQ_INTERPOLATE_8(w[5], w[4]) -#define HQ4X_PIXEL20_83 HQ_INTERPOLATE_8(w[4], w[8]) -#define HQ4X_PIXEL21_0 w[5] -#define HQ4X_PIXEL21_30 HQ_INTERPOLATE_3(w[5], w[7]) -#define HQ4X_PIXEL21_31 HQ_INTERPOLATE_3(w[5], w[8]) -#define HQ4X_PIXEL21_32 HQ_INTERPOLATE_3(w[5], w[4]) -#define HQ4X_PIXEL21_70 HQ_INTERPOLATE_7(w[5], w[4], w[8]) -#define HQ4X_PIXEL22_0 w[5] -#define HQ4X_PIXEL22_30 HQ_INTERPOLATE_3(w[5], w[9]) -#define HQ4X_PIXEL22_31 HQ_INTERPOLATE_3(w[5], w[6]) -#define HQ4X_PIXEL22_32 HQ_INTERPOLATE_3(w[5], w[8]) -#define HQ4X_PIXEL22_70 HQ_INTERPOLATE_7(w[5], w[6], w[8]) -#define HQ4X_PIXEL23_0 w[5] -#define HQ4X_PIXEL23_10 HQ_INTERPOLATE_1(w[5], w[9]) -#define HQ4X_PIXEL23_11 HQ_INTERPOLATE_1(w[5], w[6]) -#define HQ4X_PIXEL23_13 HQ_INTERPOLATE_1(w[6], w[5]) -#define HQ4X_PIXEL23_21 HQ_INTERPOLATE_2(w[6], w[5], w[8]) -#define HQ4X_PIXEL23_32 HQ_INTERPOLATE_3(w[5], w[8]) -#define HQ4X_PIXEL23_50 HQ_INTERPOLATE_5(w[6], w[5]) -#define HQ4X_PIXEL23_60 HQ_INTERPOLATE_6(w[5], w[6], w[8]) -#define HQ4X_PIXEL23_61 HQ_INTERPOLATE_6(w[5], w[6], w[9]) -#define HQ4X_PIXEL23_81 HQ_INTERPOLATE_8(w[5], w[6]) -#define HQ4X_PIXEL23_83 HQ_INTERPOLATE_8(w[6], w[8]) -/* +dstPitch +dstPitch +dstPitch */ -#define HQ4X_PIXEL30_0 w[5] -#define HQ4X_PIXEL30_11 HQ_INTERPOLATE_1(w[5], w[8]) -#define HQ4X_PIXEL30_12 HQ_INTERPOLATE_1(w[5], w[4]) -#define HQ4X_PIXEL30_20 HQ_INTERPOLATE_2(w[5], w[8], w[4]) -#define HQ4X_PIXEL30_50 HQ_INTERPOLATE_5(w[8], w[4]) -#define HQ4X_PIXEL30_80 HQ_INTERPOLATE_8(w[5], w[7]) -#define HQ4X_PIXEL30_81 HQ_INTERPOLATE_8(w[5], w[8]) -#define HQ4X_PIXEL30_82 HQ_INTERPOLATE_8(w[5], w[4]) -#define HQ4X_PIXEL31_0 w[5] -#define HQ4X_PIXEL31_10 HQ_INTERPOLATE_1(w[5], w[7]) -#define HQ4X_PIXEL31_11 HQ_INTERPOLATE_1(w[5], w[8]) -#define HQ4X_PIXEL31_13 HQ_INTERPOLATE_1(w[8], w[5]) -#define HQ4X_PIXEL31_21 HQ_INTERPOLATE_2(w[8], w[5], w[4]) -#define HQ4X_PIXEL31_32 HQ_INTERPOLATE_3(w[5], w[4]) -#define HQ4X_PIXEL31_50 HQ_INTERPOLATE_5(w[8], w[5]) -#define HQ4X_PIXEL31_60 HQ_INTERPOLATE_6(w[5], w[8], w[4]) -#define HQ4X_PIXEL31_61 HQ_INTERPOLATE_6(w[5], w[8], w[7]) -#define HQ4X_PIXEL31_81 HQ_INTERPOLATE_8(w[5], w[8]) -#define HQ4X_PIXEL31_83 HQ_INTERPOLATE_8(w[8], w[4]) -#define HQ4X_PIXEL32_0 w[5] -#define HQ4X_PIXEL32_10 HQ_INTERPOLATE_1(w[5], w[9]) -#define HQ4X_PIXEL32_12 HQ_INTERPOLATE_1(w[5], w[8]) -#define HQ4X_PIXEL32_14 HQ_INTERPOLATE_1(w[8], w[5]) -#define HQ4X_PIXEL32_21 HQ_INTERPOLATE_2(w[8], w[5], w[6]) -#define HQ4X_PIXEL32_31 HQ_INTERPOLATE_3(w[5], w[6]) -#define HQ4X_PIXEL32_50 HQ_INTERPOLATE_5(w[8], w[5]) -#define HQ4X_PIXEL32_60 HQ_INTERPOLATE_6(w[5], w[8], w[6]) -#define HQ4X_PIXEL32_61 HQ_INTERPOLATE_6(w[5], w[8], w[9]) -#define HQ4X_PIXEL32_82 HQ_INTERPOLATE_8(w[5], w[8]) -#define HQ4X_PIXEL32_83 HQ_INTERPOLATE_8(w[8], w[6]) -#define HQ4X_PIXEL33_0 w[5] -#define HQ4X_PIXEL33_11 HQ_INTERPOLATE_1(w[5], w[6]) -#define HQ4X_PIXEL33_12 HQ_INTERPOLATE_1(w[5], w[8]) -#define HQ4X_PIXEL33_20 HQ_INTERPOLATE_2(w[5], w[8], w[6]) -#define HQ4X_PIXEL33_50 HQ_INTERPOLATE_5(w[8], w[6]) -#define HQ4X_PIXEL33_80 HQ_INTERPOLATE_8(w[5], w[9]) -#define HQ4X_PIXEL33_81 HQ_INTERPOLATE_8(w[5], w[6]) -#define HQ4X_PIXEL33_82 HQ_INTERPOLATE_8(w[5], w[8]) - -#define HQ_trY 0x00000030 -#define HQ_trU 0x00000007 -#define HQ_trV 0x00000006 - -#define HQ_YUVDIFF(y1,u1,v1,y2,u2,v2) \ - ( ( ABS( y1 - y2 ) > HQ_trY ) || \ - ( ABS( u1 - u2 ) > HQ_trU ) || \ - ( ABS( v1 - v2 ) > HQ_trV ) ) - -void -FUNCTION( scaler_Super2xSaI )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - const scaler_data_type *bP; - scaler_data_type *dP; - - { - const libspectrum_dword nextlineSrc = srcPitch / sizeof( scaler_data_type ); - libspectrum_dword nextDstLine = dstPitch / sizeof( scaler_data_type ); - size_t i; - - while (height--) { - bP = (const scaler_data_type*)srcPtr; - dP = (scaler_data_type*)dstPtr; - - for( i = 0; i < width; ++i ) { - libspectrum_dword color4, color5, color6; - libspectrum_dword color1, color2, color3; - libspectrum_dword colorA0, colorA1, colorA2, colorA3, colorB0, colorB1, colorB2, - colorB3, colorS1, colorS2; - libspectrum_dword product1a, product1b, product2a, product2b; - -/*--------------------------------------- B1 B2 - 4 5 6 S2 - 1 2 3 S1 - A1 A2 -*/ - - colorB0 = *(bP - nextlineSrc - 1); - colorB1 = *(bP - nextlineSrc); - colorB2 = *(bP - nextlineSrc + 1); - colorB3 = *(bP - nextlineSrc + 2); - - color4 = *(bP - 1); - color5 = *(bP); - color6 = *(bP + 1); - colorS2 = *(bP + 2); - - color1 = *(bP + nextlineSrc - 1); - color2 = *(bP + nextlineSrc); - color3 = *(bP + nextlineSrc + 1); - colorS1 = *(bP + nextlineSrc + 2); - - colorA0 = *(bP + 2 * nextlineSrc - 1); - colorA1 = *(bP + 2 * nextlineSrc); - colorA2 = *(bP + 2 * nextlineSrc + 1); - colorA3 = *(bP + 2 * nextlineSrc + 2); - -/*--------------------------------------*/ - if (color2 == color6 && color5 != color3) { - product2b = product1b = color2; - } else if (color5 == color3 && color2 != color6) { - product2b = product1b = color5; - } else if (color5 == color3 && color2 == color6) { - register int r = 0; - - r += GetResult(color6, color5, color1, colorA1); - r += GetResult(color6, color5, color4, colorB1); - r += GetResult(color6, color5, colorA2, colorS1); - r += GetResult(color6, color5, colorB2, colorS2); - - if (r > 0) - product2b = product1b = color6; - else if (r < 0) - product2b = product1b = color5; - else { - product2b = product1b = INTERPOLATE(color5, color6); - } - } else { - if (color6 == color3 && color3 == colorA1 && color2 != colorA2 && color3 != colorA0) - product2b = Q_INTERPOLATE(color3, color3, color3, color2); - else if (color5 == color2 && color2 == colorA2 && colorA1 != color3 && color2 != colorA3) - product2b = Q_INTERPOLATE(color2, color2, color2, color3); - else - product2b = INTERPOLATE(color2, color3); - - if (color6 == color3 && color6 == colorB1 && color5 != colorB2 && color6 != colorB0) - product1b = Q_INTERPOLATE(color6, color6, color6, color5); - else if (color5 == color2 && color5 == colorB2 && colorB1 != color6 && color5 != colorB3) - product1b = Q_INTERPOLATE(color6, color5, color5, color5); - else - product1b = INTERPOLATE(color5, color6); - } - - if (color5 == color3 && color2 != color6 && color4 == color5 && color5 != colorA2) - product2a = INTERPOLATE(color2, color5); - else if (color5 == color1 && color6 == color5 && color4 != color2 && color5 != colorA0) - product2a = INTERPOLATE(color2, color5); - else - product2a = color2; - - if (color2 == color6 && color5 != color3 && color1 == color2 && color2 != colorB2) - product1a = INTERPOLATE(color2, color5); - else if (color4 == color2 && color3 == color2 && color1 != color5 && color2 != colorB0) - product1a = INTERPOLATE(color2, color5); - else - product1a = color5; - - *dP = (scaler_data_type)product1a; - *(dP+nextDstLine) = (scaler_data_type)product2a; - dP++; - *dP = (scaler_data_type)product1b; - *(dP+nextDstLine) = (scaler_data_type)product2b; - dP++; - - bP++; - } - - srcPtr += srcPitch; - dstPtr += dstPitch * 2; - } - } -} - -void -FUNCTION( scaler_SuperEagle )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - const scaler_data_type *bP; - scaler_data_type *dP; - - { - size_t i; - const libspectrum_dword nextlineSrc = srcPitch / sizeof( scaler_data_type ); - libspectrum_dword nextDstLine = dstPitch / sizeof( scaler_data_type ); - - while (height--) { - bP = (const scaler_data_type*)srcPtr; - dP = (scaler_data_type*)dstPtr; - for( i = 0; i < width; ++i ) { - libspectrum_dword color4, color5, color6; - libspectrum_dword color1, color2, color3; - libspectrum_dword colorA1, colorA2, colorB1, colorB2, colorS1, colorS2; - libspectrum_dword product1a, product1b, product2a, product2b; - - colorB1 = *(bP - nextlineSrc); - colorB2 = *(bP - nextlineSrc + 1); - - color4 = *(bP - 1); - color5 = *(bP); - color6 = *(bP + 1); - colorS2 = *(bP + 2); - - color1 = *(bP + nextlineSrc - 1); - color2 = *(bP + nextlineSrc); - color3 = *(bP + nextlineSrc + 1); - colorS1 = *(bP + nextlineSrc + 2); - - colorA1 = *(bP + 2 * nextlineSrc); - colorA2 = *(bP + 2 * nextlineSrc + 1); - - /* -------------------------------------- */ - if (color5 != color3 ) - { - if (color2 == color6) - { - product1b = product2a = color2; - if ((color1 == color2) || (color6 == colorB2)) { - product1a = INTERPOLATE(color2, color5); - product1a = INTERPOLATE(color2, product1a); - } else { - product1a = INTERPOLATE(color5, color6); - } - - if ((color6 == colorS2) || (color2 == colorA1)) { - product2b = INTERPOLATE(color2, color3); - product2b = INTERPOLATE(color2, product2b); - } else { - product2b = INTERPOLATE(color2, color3); - } - } - else - { - product2b = product1a = INTERPOLATE(color2, color6); - product2b = Q_INTERPOLATE(color3, color3, color3, product2b); - product1a = Q_INTERPOLATE(color5, color5, color5, product1a); - - product2a = product1b = INTERPOLATE(color5, color3); - product2a = Q_INTERPOLATE(color2, color2, color2, product2a); - product1b = Q_INTERPOLATE(color6, color6, color6, product1b); - } - } - else /*if (color5 == color3) */ - { - if (color2 != color6) - { - product2b = product1a = color5; - - if ((colorB1 == color5) || (color3 == colorS1)) { - product1b = INTERPOLATE(color5, color6); - product1b = INTERPOLATE(color5, product1b); - } else { - product1b = INTERPOLATE(color5, color6); - } - - if ((color3 == colorA2) || (color4 == color5)) { - product2a = INTERPOLATE(color5, color2); - product2a = INTERPOLATE(color5, product2a); - } else { - product2a = INTERPOLATE(color2, color3); - } - - } - else /* if (color2 != color6) */ - { - register int r = 0; - - r += GetResult(color6, color5, color1, colorA1); - r += GetResult(color6, color5, color4, colorB1); - r += GetResult(color6, color5, colorA2, colorS1); - r += GetResult(color6, color5, colorB2, colorS2); - - if (r > 0) { - product1b = product2a = color2; - product1a = product2b = INTERPOLATE(color5, color6); - } else if (r < 0) { - product2b = product1a = color5; - product1b = product2a = INTERPOLATE(color5, color6); - } else { - product2b = product1a = color5; - product1b = product2a = color2; - } - } - } - - *dP = (scaler_data_type)product1a; - *(dP+nextDstLine) = (scaler_data_type)product2a; - dP++; - *dP = (scaler_data_type)product1b; - *(dP+nextDstLine) = (scaler_data_type)product2b; - dP++; - - bP++; - } - - srcPtr += srcPitch; - dstPtr += dstPitch * 2; - } - } -} - -void -FUNCTION( scaler_2xSaI )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - const scaler_data_type *bP; - scaler_data_type *dP; - - { - libspectrum_dword nextlineSrc = srcPitch / sizeof( scaler_data_type ); - libspectrum_dword nextDstLine = dstPitch / sizeof( scaler_data_type ); - - while (height--) { - size_t i; - bP = (const scaler_data_type*)srcPtr; - dP = (scaler_data_type*)dstPtr; - - for( i = 0; i < width; ++i ) { - - register libspectrum_dword colorA, colorB; - libspectrum_dword colorC, colorD, colorE, colorF, colorG, colorH, - colorI, colorJ, colorK, colorL, colorM, colorN, colorO; - libspectrum_dword product, product1, product2; - -/*--------------------------------------- - Map of the pixels: I|E F|J - G|A B|K - H|C D|L - M|N O|P - - Note that P does not contribute to the algorithm -*/ - colorI = *(bP - nextlineSrc - 1); - colorE = *(bP - nextlineSrc); - colorF = *(bP - nextlineSrc + 1); - colorJ = *(bP - nextlineSrc + 2); - - colorG = *(bP - 1); - colorA = *(bP); - colorB = *(bP + 1); - colorK = *(bP + 2); - - colorH = *(bP + nextlineSrc - 1); - colorC = *(bP + nextlineSrc); - colorD = *(bP + nextlineSrc + 1); - colorL = *(bP + nextlineSrc + 2); - - colorM = *(bP + 2 * nextlineSrc - 1); - colorN = *(bP + 2 * nextlineSrc); - colorO = *(bP + 2 * nextlineSrc + 1); - - if ((colorA == colorD) && (colorB != colorC)) { - if (((colorA == colorE) && (colorB == colorL)) || - ((colorA == colorC) && (colorA == colorF) && (colorB != colorE) && (colorB == colorJ))) { - product = colorA; - } else { - product = INTERPOLATE(colorA, colorB); - } - - if (((colorA == colorG) && (colorC == colorO)) || - ((colorA == colorB) && (colorA == colorH) && (colorG != colorC) && (colorC == colorM))) { - product1 = colorA; - } else { - product1 = INTERPOLATE(colorA, colorC); - } - product2 = colorA; - } else if ((colorB == colorC) && (colorA != colorD)) { - if (((colorB == colorF) && (colorA == colorH)) || - ((colorB == colorE) && (colorB == colorD) && (colorA != colorF) && (colorA == colorI))) { - product = colorB; - } else { - product = INTERPOLATE(colorA, colorB); - } - - if (((colorC == colorH) && (colorA == colorF)) || - ((colorC == colorG) && (colorC == colorD) && (colorA != colorH) && (colorA == colorI))) { - product1 = colorC; - } else { - product1 = INTERPOLATE(colorA, colorC); - } - product2 = colorB; - } else if ((colorA == colorD) && (colorB == colorC)) { - if (colorA == colorB) { - product = colorA; - product1 = colorA; - product2 = colorA; - } else { - register int r = 0; - - product1 = INTERPOLATE(colorA, colorC); - product = INTERPOLATE(colorA, colorB); - - r += GetResult(colorA, colorB, colorG, colorE); - r -= GetResult(colorB, colorA, colorK, colorF); - r -= GetResult(colorB, colorA, colorH, colorN); - r += GetResult(colorA, colorB, colorL, colorO); - - if (r > 0) - product2 = colorA; - else if (r < 0) - product2 = colorB; - else { - product2 = Q_INTERPOLATE(colorA, colorB, colorC, colorD); - } - } - } else { - product2 = Q_INTERPOLATE(colorA, colorB, colorC, colorD); - - if ((colorA == colorC) && (colorA == colorF) - && (colorB != colorE) && (colorB == colorJ)) { - product = colorA; - } else if ((colorB == colorE) && (colorB == colorD) - && (colorA != colorF) && (colorA == colorI)) { - product = colorB; - } else { - product = INTERPOLATE(colorA, colorB); - } - - if ((colorA == colorB) && (colorA == colorH) - && (colorG != colorC) && (colorC == colorM)) { - product1 = colorA; - } else if ((colorC == colorG) && (colorC == colorD) - && (colorA != colorH) && (colorA == colorI)) { - product1 = colorC; - } else { - product1 = INTERPOLATE(colorA, colorC); - } - } - - *dP = (scaler_data_type)colorA; - *(dP+nextDstLine) = (scaler_data_type)product1; - dP++; - *dP = (scaler_data_type)product; - *(dP+nextDstLine) = (scaler_data_type)product2; - dP++; - - bP++; - } - - srcPtr += srcPitch; - dstPtr += dstPitch * 2; - } - } -} - -void -FUNCTION( scaler_AdvMame2x )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - unsigned int nextlineSrc = srcPitch / sizeof( scaler_data_type ); - const scaler_data_type *p = (const scaler_data_type*) srcPtr; - - unsigned int nextlineDst = dstPitch / sizeof( scaler_data_type ); - scaler_data_type *q = (scaler_data_type*) dstPtr; - - scaler_data_type /* A, */ B, C; - scaler_data_type D, E, F; - scaler_data_type /* G, */ H, I; - - while (height--) { - int i; - - /* B = *(p - 1 - nextlineSrc); */ - E = *(p - 1); - /* H = *(p - 1 + nextlineSrc); */ - C = *(p - nextlineSrc); - F = *(p); - I = *(p + nextlineSrc); - - for (i = 0; i < width; ++i) { - p++; - /* A = B; */ B = C; C = *(p - nextlineSrc); - D = E; E = F; F = *(p); - /* G = H; */ H = I; I = *(p + nextlineSrc); - - *(q) = D == B && B != F && D != H ? D : E; - *(q + 1) = B == F && B != D && F != H ? F : E; - *(q + nextlineDst) = D == H && D != B && H != F ? D : E; - *(q + nextlineDst + 1) = H == F && D != H && B != F ? F : E; - q += 2; - } - p += nextlineSrc - width; - q += (nextlineDst - width) << 1; - } -} - -void -FUNCTION( scaler_AdvMame3x )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - unsigned int nextlineSrc = srcPitch / sizeof( scaler_data_type ); - const scaler_data_type *p = (const scaler_data_type*) srcPtr; - - unsigned int nextlineDst = dstPitch / sizeof( scaler_data_type ); - scaler_data_type *q = (scaler_data_type*) dstPtr; - - scaler_data_type A, B, C; - scaler_data_type D, E, F; - scaler_data_type G, H, I; - - while (height--) { - int i; - - B = *(p - 1 - nextlineSrc); - E = *(p - 1); - H = *(p - 1 + nextlineSrc); - C = *(p - nextlineSrc); - F = *(p); - I = *(p + nextlineSrc); - - for (i = 0; i < width; ++i) { - p++; - A = B; B = C; C = *(p - nextlineSrc); - D = E; E = F; F = *(p); - G = H; H = I; I = *(p + nextlineSrc); - - *(q) = D == B && B != F && D != H ? D : E; - *(q + 1) = (D == B && B != F && D != H && E != C) || (B == F && B != D && F != H && E != A) ? B : E; - *(q + 2) = B == F && B != D && F != H ? F : E; - *(q + nextlineDst) = (D == B && B != F && D != H && E != G) || (D == H && D != B && H != F && E != A) ? D : E; - *(q + nextlineDst + 1) = E; - *(q + nextlineDst + 2) = (B == F && B != D && F != H && E != I) || (H == F && D != H && B != F && E != C) ? F : E; - *(q + 2 * nextlineDst) = D == H && D != B && H != F ? D : E; - *(q + 2 * nextlineDst + 1) = (D == H && D != B && H != F && E != I) || (H == F && D != H && B != F && E != G) ? H : E; - *(q + 2 * nextlineDst + 2) = H == F && D != H && B != F ? F : E; - q += 3; - } - p += nextlineSrc - width; - q += (nextlineDst - width) * 3; - } -} - -void -FUNCTION( scaler_Half )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - scaler_data_type *r; - - while (height--) { - int i; - r = (scaler_data_type*) dstPtr; - - if( ( height & 1 ) == 0 ) { - for (i = 0; i < width; i+=2, ++r) { - scaler_data_type color1 = *(((scaler_data_type*) srcPtr) + i); - scaler_data_type color2 = *(((scaler_data_type*) srcPtr) + i + 1); - - *r = INTERPOLATE(color1, color2); - } - dstPtr += dstPitch; - } - - srcPtr += srcPitch; - } -} - -void -FUNCTION( scaler_HalfSkip )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - scaler_data_type *r; - - while (height--) { - int i; - r = (scaler_data_type*) dstPtr; - - if( ( height & 1 ) == 0 ) { - for (i = 0; i < width; i+=2, ++r) { - *r = *(((const scaler_data_type*) srcPtr) + i + 1); - } - dstPtr += dstPitch; - } - - srcPtr += srcPitch; - } -} - -void -FUNCTION( scaler_Normal1x )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - while( height-- ) { - memcpy( dstPtr, srcPtr, SCALER_DATA_SIZE * width ); - srcPtr += srcPitch; - dstPtr += dstPitch; - } -} - -void -FUNCTION( scaler_Normal2x )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - const scaler_data_type *s; - scaler_data_type i, *d, *d2; - - while( height-- ) { - - for( i = 0, s = (const scaler_data_type*)srcPtr, - d = (scaler_data_type*)dstPtr, - d2 = (scaler_data_type*)(dstPtr + dstPitch); - i < width; - i++ ) { - *d++ = *d2++ = *s; *d++ = *d2++ = *s++; - } - - srcPtr += srcPitch; - dstPtr += dstPitch << 1; - } -} - -void -FUNCTION( scaler_Normal3x )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - libspectrum_byte *r; - libspectrum_dword dstPitch2 = dstPitch * 2; - libspectrum_dword dstPitch3 = dstPitch * 3; - - while (height--) { - int i; - r = dstPtr; - for (i = 0; i < width; ++i, r += 3 * SCALER_DATA_SIZE ) { - scaler_data_type color = *(((const scaler_data_type*) srcPtr) + i); - - *(scaler_data_type*)( r + 0 ) = color; - *(scaler_data_type*)( r + SCALER_DATA_SIZE ) = color; - *(scaler_data_type*)( r + 2 * SCALER_DATA_SIZE ) = color; - *(scaler_data_type*)( r + 0 + dstPitch ) = color; - *(scaler_data_type*)( r + SCALER_DATA_SIZE + dstPitch ) = color; - *(scaler_data_type*)( r + 2 * SCALER_DATA_SIZE + dstPitch ) = color; - *(scaler_data_type*)( r + 0 + dstPitch2 ) = color; - *(scaler_data_type*)( r + SCALER_DATA_SIZE + dstPitch2 ) = color; - *(scaler_data_type*)( r + 2 * SCALER_DATA_SIZE + dstPitch2 ) = color; - } - srcPtr += srcPitch; - dstPtr += dstPitch3; - } -} - -void -FUNCTION( scaler_Normal4x )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - libspectrum_byte *r; - libspectrum_dword dstPitch2 = dstPitch * 2; - libspectrum_dword dstPitch3 = dstPitch * 3; - libspectrum_dword dstPitch4 = dstPitch * 4; - - while (height--) { - int i; - r = dstPtr; - for (i = 0; i < width; ++i, r += 4 * SCALER_DATA_SIZE ) { - scaler_data_type color = *(((const scaler_data_type*) srcPtr) + i); - - *(scaler_data_type*)( r + 0 ) = color; - *(scaler_data_type*)( r + SCALER_DATA_SIZE ) = color; - *(scaler_data_type*)( r + 2 * SCALER_DATA_SIZE ) = color; - *(scaler_data_type*)( r + 3 * SCALER_DATA_SIZE ) = color; - - *(scaler_data_type*)( r + 0 + dstPitch ) = color; - *(scaler_data_type*)( r + SCALER_DATA_SIZE + dstPitch ) = color; - *(scaler_data_type*)( r + 2 * SCALER_DATA_SIZE + dstPitch ) = color; - *(scaler_data_type*)( r + 3 * SCALER_DATA_SIZE + dstPitch ) = color; - - *(scaler_data_type*)( r + 0 + dstPitch2 ) = color; - *(scaler_data_type*)( r + SCALER_DATA_SIZE + dstPitch2 ) = color; - *(scaler_data_type*)( r + 2 * SCALER_DATA_SIZE + dstPitch2 ) = color; - *(scaler_data_type*)( r + 3 * SCALER_DATA_SIZE + dstPitch2 ) = color; - - *(scaler_data_type*)( r + 0 + dstPitch3 ) = color; - *(scaler_data_type*)( r + SCALER_DATA_SIZE + dstPitch3 ) = color; - *(scaler_data_type*)( r + 2 * SCALER_DATA_SIZE + dstPitch3 ) = color; - *(scaler_data_type*)( r + 3 * SCALER_DATA_SIZE + dstPitch3 ) = color; - } - srcPtr += srcPitch; - dstPtr += dstPitch4; - } -} - -void -FUNCTION( scaler_Timex1_5x )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - libspectrum_byte *r; - libspectrum_dword dstPitch2 = dstPitch * 2; - libspectrum_dword dstPitch3 = dstPitch * 3; - - while (height--) { - int i; - r = dstPtr; - if( ( height & 1 ) == 0 ) { - for (i = 0; i < width; i+=2, r += 3 * SCALER_DATA_SIZE ) { - /* Interpolate a new pixel inbetween the source pixels */ - scaler_data_type color1 = *(((const scaler_data_type*) srcPtr) + i); - scaler_data_type color2 = *(((const scaler_data_type*) srcPtr) + i + 1); - scaler_data_type color3 = INTERPOLATE(color1, color2); - - *(scaler_data_type*)( r + 0 ) = color1; - *(scaler_data_type*)( r + SCALER_DATA_SIZE ) = color3; - *(scaler_data_type*)( r + 2 * SCALER_DATA_SIZE ) = color2; - *(scaler_data_type*)( r + 0 + dstPitch ) = color1; - *(scaler_data_type*)( r + SCALER_DATA_SIZE + dstPitch ) = color3; - *(scaler_data_type*)( r + 2 * SCALER_DATA_SIZE + dstPitch ) = color2; - *(scaler_data_type*)( r + 0 + dstPitch2 ) = color1; - *(scaler_data_type*)( r + SCALER_DATA_SIZE + dstPitch2 ) = color3; - *(scaler_data_type*)( r + 2 * SCALER_DATA_SIZE + dstPitch2 ) = color2; - } - dstPtr += dstPitch3; - } - srcPtr += srcPitch; - } -} - -void -FUNCTION( scaler_TV2x )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - int i, j; - unsigned int nextlineSrc = srcPitch / sizeof( scaler_data_type ); - const scaler_data_type *p = (const scaler_data_type*)srcPtr; - - unsigned int nextlineDst = dstPitch / sizeof( scaler_data_type ); - scaler_data_type *q = (scaler_data_type*)dstPtr; - - while(height--) { - for (i = 0, j = 0; i < width; ++i, j += 2) { - scaler_data_type p1 = *(p + i); - scaler_data_type pi; - - pi = (((p1 & redblueMask) * 7) >> 3) & redblueMask; - pi |= (((p1 & greenMask ) * 7) >> 3) & greenMask; - - *(q + j) = p1; - *(q + j + 1) = p1; - *(q + j + nextlineDst) = pi; - *(q + j + nextlineDst + 1) = pi; - } - p += nextlineSrc; - q += nextlineDst << 1; - } -} - -void -FUNCTION( scaler_TV3x )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - int i, j; - unsigned int nextlineSrc = srcPitch / sizeof( scaler_data_type ); - const scaler_data_type *p = (const scaler_data_type*)srcPtr; - - unsigned int nextlineDst = dstPitch / sizeof( scaler_data_type ); - scaler_data_type *q = (scaler_data_type*)dstPtr; - - while(height--) { - for (i = 0, j = 0; i < width; ++i, j += 3) { - scaler_data_type p1 = *(p + i); - scaler_data_type pi; - - pi = (((p1 & redblueMask) * 7) >> 3) & redblueMask; - pi |= (((p1 & greenMask ) * 7) >> 3) & greenMask; - - *(q + j) = p1; - *(q + j + 1) = p1; - *(q + j + 2) = p1; - - *(q + j + nextlineDst) = p1; - *(q + j + nextlineDst + 1) = p1; - *(q + j + nextlineDst + 2) = p1; - - *(q + j + (nextlineDst << 1)) = pi; - *(q + j + (nextlineDst << 1) + 1) = pi; - *(q + j + (nextlineDst << 1) + 2) = pi; - } - p += nextlineSrc; - q += nextlineDst * 3; - } -} - -void -FUNCTION( scaler_TV4x )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - int i, j; - unsigned int nextlineSrc = srcPitch / sizeof( scaler_data_type ); - const scaler_data_type *p = (const scaler_data_type*)srcPtr; - - unsigned int nextlineDst = dstPitch / sizeof( scaler_data_type ); - scaler_data_type *q = (scaler_data_type*)dstPtr; - - while(height--) { - for (i = 0, j = 0; i < width; ++i, j += 4) { - scaler_data_type p1 = *(p + i); - scaler_data_type pi; - - pi = (((p1 & redblueMask) * 7) >> 3) & redblueMask; - pi |= (((p1 & greenMask ) * 7) >> 3) & greenMask; - - *(q + j) = p1; - *(q + j + 1) = p1; - *(q + j + 2) = p1; - *(q + j + 3) = p1; - - *(q + j + nextlineDst) = p1; - *(q + j + nextlineDst + 1) = p1; - *(q + j + nextlineDst + 2) = p1; - *(q + j + nextlineDst + 3) = p1; - - *(q + j + (nextlineDst << 1)) = pi; - *(q + j + (nextlineDst << 1) + 1) = pi; - *(q + j + (nextlineDst << 1) + 2) = pi; - *(q + j + (nextlineDst << 1) + 3) = pi; - - *(q + j + (nextlineDst * 3)) = pi; - *(q + j + (nextlineDst * 3) + 1) = pi; - *(q + j + (nextlineDst * 3) + 2) = pi; - *(q + j + (nextlineDst * 3) + 3) = pi; - } - p += nextlineSrc; - q += nextlineDst * 4; - } -} - -void -FUNCTION( scaler_TimexTV )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - int i, j; - unsigned int nextlineSrc = srcPitch / sizeof( scaler_data_type ); - const scaler_data_type *p = (const scaler_data_type *)srcPtr; - - unsigned int nextlineDst = dstPitch / sizeof( scaler_data_type ); - scaler_data_type *q = (scaler_data_type *)dstPtr; - - while(height--) { - if( ( height & 1 ) == 0 ) { - for (i = 0, j = 0; i < width; ++i, j++ ) { - scaler_data_type p1 = *(p + i); - scaler_data_type pi; - - pi = (((p1 & redblueMask) * 7) >> 3) & redblueMask; - pi |= (((p1 & greenMask ) * 7) >> 3) & greenMask; - - *(q + j) = p1; - *(q + j + nextlineDst) = pi; - } - q += nextlineDst << 1; - } - p += nextlineSrc; - } -} - -static inline scaler_data_type DOT_16(scaler_data_type c, int j, int i) { - return c - ((c >> 2) & *(dotmatrix + ((j & 3) << 2) + (i & 3))); -} - -void -FUNCTION( scaler_DotMatrix )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - int i, j, ii, jj; - unsigned int nextlineSrc = srcPitch / sizeof( scaler_data_type ); - const scaler_data_type *p = (const scaler_data_type *)srcPtr; - - unsigned int nextlineDst = dstPitch / sizeof( scaler_data_type ); - scaler_data_type *q = (scaler_data_type *)dstPtr; - - for (j = 0, jj = 0; j < height; ++j, jj += 2) { - for (i = 0, ii = 0; i < width; ++i, ii += 2) { - scaler_data_type c = *(p + i); - *(q + ii) = DOT_16(c, jj, ii); - *(q + ii + 1) = DOT_16(c, jj, ii + 1); - *(q + ii + nextlineDst) = DOT_16(c, jj + 1, ii); - *(q + ii + nextlineDst + 1) = DOT_16(c, jj + 1, ii + 1); - } - p += nextlineSrc; - q += nextlineDst << 1; - } -} - -/* - Y = 0.29900 * R + 0.58700 * G + 0.11400 * B - U = -0.16874 * R - 0.33126 * G + 0.50000 * B (+ 128) - V = 0.50000 * R - 0.41869 * G - 0.08131 * B (+ 128) -*/ - -#define RGB_TO_Y(r, g, b) ( ( 2449L * r + 4809L * g + 934L * b + 1024 ) >> 11 ) -#define RGB_TO_U(r, g, b) ( ( 4096L * b - 1383L * r - 2713L * g + 1024 ) >> 11 ) -#define RGB_TO_V(r, g, b) ( ( 4096L * r - 3430L * g - 666L * b + 1024 ) >> 11 ) - -/* - R = Y + 1.402 (V-128) - G = Y - 0.34414 (U-128) - 0.71414 (V-128) - B = Y + 1.772 (U-128) -*/ - -#define YUV_TO_R(y, u, v) ( MIN( ABS( ( 8192L * y + 11485L * v + 16384 ) >> 15 ), 255 ) ) -#define YUV_TO_G(y, u, v) ( MIN( ABS( ( 8192L * y - 2819L * u - 5850L * v + 16384 ) >> 15 ), 255 ) ) -#define YUV_TO_B(y, u, v) ( MIN( ABS( ( 8192L * y + 14516L * u + 16384 ) >> 15 ), 255 ) ) - -#define RGB_TO_PIXEL_555(r,g,b) \ - (((r * 125) >> 10) + (((g * 125) >> 5) & greenMask) + \ - ((b * 125) & blueMask)) - -#define RGB_TO_PIXEL_565(r,g,b) \ - (((r * 125) >> 10) + (((g * 253) >> 5) & greenMask) + \ - ((b * 249) & blueMask)) - -#define R_TO_R(r) \ - ( ( ( (r) & redMask ) * 8424 ) >> 10 ) - -#define G_TO_G(g) \ - ( green6bit ? \ - ( ( ( (g) & greenMask ) >> 5 ) * 4145 ) >> 10 : \ - ( ( ( (g) & greenMask ) >> 5 ) * 8424 ) >> 10 ) - -#define B_TO_B(b) \ - ( green6bit ? \ - ( ( ( (b) & blueMask ) >> 11 ) * 8424 ) >> 10 : \ - ( ( ( (b) & blueMask ) >> 10 ) * 8424 ) >> 10 ) - -void -FUNCTION( scaler_PalTV )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ -/* - 1.a. RGB => 255,255,255 RGB - 1.b. RGB => YUV - 2. 422 interstricial color subsampling - 3.a. YUV => RGB - 3.b 255,255,255 RGB => RGB -*/ - int i, j; - unsigned int nextlineSrc = srcPitch / sizeof( scaler_data_type ); - const scaler_data_type *p, *p0 = (const scaler_data_type *)srcPtr; - - unsigned int nextlineDst = dstPitch / sizeof( scaler_data_type ); - scaler_data_type *q, *q0 = (scaler_data_type *)dstPtr; - - libspectrum_byte r0, g0, b0, - r1, g1, b1, - r2, g2, b2, - r3, g3, b3; - libspectrum_signed_word y1, y2, u1, u2, v1, v2; - -/* - 422 cosited - # + # + + only Y - # Y and Cb Cr - # + # + - - abcd... => 1/2a + a + 1/2b / 2; ...; 1/2a + b + 1/2c; ... ; ... - always 3 sample/proc - -*/ - for( j = height; j; j-- ) { - p = p0 - 1; q = q0; -#if SCALER_DATA_SIZE == 2 - /* 1.a. RGB => RGB */ - r2 = R_TO_R( *p ); - g2 = G_TO_G( *p ); - b2 = B_TO_B( *p ); - p++; - r0 = R_TO_R( *p ); - g0 = G_TO_G( *p ); - b0 = B_TO_B( *p ); - p++; - r1 = R_TO_R( *p ); - g1 = G_TO_G( *p ); - b1 = B_TO_B( *p ); - p++; -#else - r2 = (*p & redMask); - g2 = (*p & greenMask) >> 8; - b2 = (*p & blueMask) >> 16; - p++; - r0 = (*p & redMask); - g0 = (*p & greenMask) >> 8; - b0 = (*p & blueMask) >> 16; - p++; - r1 = (*p & redMask); - g1 = (*p & greenMask) >> 8; - b1 = (*p & blueMask) >> 16; - p++; -#endif - u1 = ( RGB_TO_U( r2, g2, b2 ) + 2 * RGB_TO_U( r0, g0, b0 ) + - RGB_TO_U( r1, g1, b1 ) ) >> 2; - v1 = ( RGB_TO_V( r2, g2, b2 ) + 2 * RGB_TO_V( r0, g0, b0 ) + - RGB_TO_V( r1, g1, b1 ) ) >> 2; - for( i = width; i; i -= 2 ) { -#if SCALER_DATA_SIZE == 2 - /* 1.a. RGB => RGB */ - r2 = R_TO_R( *p ); - g2 = G_TO_G( *p ); - b2 = B_TO_B( *p ); - p++; - r3 = R_TO_R( *p ); - g3 = G_TO_G( *p ); - b3 = B_TO_B( *p ); - p++; -#else - r2 = (*p & redMask); - g2 = (*p & greenMask) >> 8; - b2 = (*p & blueMask) >> 16; - p++; - r3 = (*p & redMask); - g3 = (*p & greenMask) >> 8; - b3 = (*p & blueMask) >> 16; - p++; -#endif -/* 1.b. RGB => YUV && 2. YUV subsampling */ - y1 = RGB_TO_Y( r0, g0, b0 ); - y2 = RGB_TO_Y( r1, g1, b1 ); - - u2 = ( RGB_TO_U( r1, g1, b1 ) + 2 * RGB_TO_U( r2, g2, b2 ) + - RGB_TO_U( r3, g3, b3 ) ) >> 2; - v2 = ( RGB_TO_V( r1, g1, b1 ) + 2 * RGB_TO_V( r2, g2, b2 ) + - RGB_TO_V( r3, g3, b3 ) ) >> 2; -/* 3.a. YUV => RGB */ - r0 = YUV_TO_R(y1, u1, v1); - g0 = YUV_TO_G(y1, u1, v1); - b0 = YUV_TO_B(y1, u1, v1); - - u1 = (u1 + u2) >> 1; - v1 = (v1 + v2) >> 1; - - r1 = YUV_TO_R(y2, u1, v1); - g1 = YUV_TO_G(y2, u1, v1); - b1 = YUV_TO_B(y2, u1, v1); -#if SCALER_DATA_SIZE == 2 -/* 3.b. RGB => RGB */ - if( green6bit ) { - *q++ = RGB_TO_PIXEL_565( r0, g0, b0 ); - *q++ = RGB_TO_PIXEL_565( r1, g1, b1 ); - } else { - *q++ = RGB_TO_PIXEL_555( r0, g0, b0 ); - *q++ = RGB_TO_PIXEL_555( r1, g1, b1 ); - } -#else - *q++ = r0 + (g0 << 8) + (b0 << 16); - *q++ = r1 + (g1 << 8) + (b1 << 16); -#endif - u1 = u2; v1 = v2; - r0 = r2; g0 = g2; b0 = b2; - r1 = r3; g1 = g3; b1 = b3; - } - p0 += nextlineSrc; - q0 += nextlineDst; - } -} - -void -FUNCTION( scaler_PalTV2x )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ -/* - 1.a. RGB => 255,255,255 RGB - 1.b. RGB => YUV - 2. 4:2:2 cosited color subsampling - 3.a. YUV => RGB - 3.b 255,255,255 RGB => RGB -*/ - int i, j; - unsigned int nextlineSrc = srcPitch / sizeof( scaler_data_type ); - const scaler_data_type *p, *p0 = (const scaler_data_type *)srcPtr; - - unsigned int nextlineDst = dstPitch / sizeof( scaler_data_type ); - scaler_data_type *q, *q0 = (scaler_data_type *)dstPtr; - - libspectrum_byte r0, g0, b0, - r1, g1, b1, - rx, gx, bx; - libspectrum_signed_dword y1, y2, u1, v1, u2, v2; - -/* - 422 cosited - # + # + + only Y - # Y and Cb Cr - # + # + - - abcd... => 1/2a + a + 1/2b / 2; ...; 1/2a + b + 1/2c; ... ; ... - always 3 sample/proc - -*/ - for( j = height; j; j-- ) { - p = p0 - 1; q = q0; -#if SCALER_DATA_SIZE == 2 - r0 = R_TO_R( *p ); - g0 = G_TO_G( *p ); - b0 = B_TO_B( *p ); - p++; - r1 = R_TO_R( *p ); - g1 = G_TO_G( *p ); - b1 = B_TO_B( *p ); -#else - r0 = *p & redMask; - g0 = (*p & greenMask) >> 8; - b0 = (*p & blueMask) >> 16; - p++; - r1 = *(p) & redMask; - g1 = (*(p) & greenMask) >> 8; - b1 = (*(p) & blueMask) >> 16; -#endif - y1 = RGB_TO_Y( r1, g1, b1 ); - u1 = ( RGB_TO_U( r0, g0, b0 ) + 3 * RGB_TO_U( r1, g1, b1 ) ) >> 2; - v1 = ( RGB_TO_V( r0, g0, b0 ) + 3 * RGB_TO_V( r1, g1, b1 ) ) >> 2; - for( i = width; i; i-- ) { - p++; /* next point */ -#if SCALER_DATA_SIZE == 2 - /* 1.a. RGB => RGB */ - r0 = R_TO_R( *p ); - g0 = G_TO_G( *p ); - b0 = B_TO_B( *p ); -#else - r0 = (*p & redMask); - g0 = (*p & greenMask) >> 8; - b0 = (*p & blueMask) >> 16; -#endif -/* 1.b. RGB => YUV && 2. YUV subsampling */ - y2 = RGB_TO_Y( r0, g0, b0 ); - u2 = ( RGB_TO_U( r1, g1, b1 ) + 3 * RGB_TO_U( r0, g0, b0 ) ) >> 2; - v2 = ( RGB_TO_V( r1, g1, b1 ) + 3 * RGB_TO_V( r0, g0, b0 ) ) >> 2; - -/* 3.a. YUV => RGB */ - rx = YUV_TO_R( y1, u1, v1 ); /* [x0][ ]*/ - gx = YUV_TO_G( y1, u1, v1 ); - bx = YUV_TO_B( y1, u1, v1 ); - - u1 = ( u1 + u2 ) >> 1; - v1 = ( v1 + v2 ) >> 1; - - r1 = YUV_TO_R( y1, u1, v1 ); - g1 = YUV_TO_G( y1, u1, v1 ); - b1 = YUV_TO_B( y1, u1, v1 ); - -#if SCALER_DATA_SIZE == 2 -/* 3.b. RGB => RGB */ - if( green6bit ) { - *q = RGB_TO_PIXEL_565( rx, gx, bx ); - } else { - *q = RGB_TO_PIXEL_555( rx, gx, bx ); - } -#else - *q = rx + ( gx << 8 ) + ( bx << 16 ); -#endif - - if( settings_current.pal_tv2x ) - *(q + nextlineDst) = - ((((*q & redblueMask) * 7) >> 3) & redblueMask) | - ((((*q & greenMask ) * 7) >> 3) & greenMask); - else - *(q + nextlineDst) = *q; - - q++; -#if SCALER_DATA_SIZE == 2 -/* 3.b. RGB => RGB */ - if( green6bit ) { - *q = RGB_TO_PIXEL_565( r1, g1, b1 ); - } else { - *q = RGB_TO_PIXEL_555( r1, g1, b1 ); - } -#else - *q = r1 + ( g1 << 8 ) + ( b1 << 16 ); -#endif - if( settings_current.pal_tv2x ) - *(q + nextlineDst) = - ((((*q & redblueMask) * 7) >> 3) & redblueMask) | - ((((*q & greenMask ) * 7) >> 3) & greenMask); - else - *(q + nextlineDst) = *q; - - q++; - y1 = y2; u1 = u2; v1 = v2; /* save for next point */ - r1 = r0; g1 = g0; b1 = b0; - } - p0 += nextlineSrc; - q0 += nextlineDst << 1; - } -} - -void -FUNCTION( scaler_PalTV3x )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ -/* - 1.a. RGB => 255,255,255 RGB - 1.b. RGB => YUV - 2. 4:2:2 cosited color subsampling - 3.a. YUV => RGB - 3.b 255,255,255 RGB => RGB -*/ - int i, j; - unsigned int nextlineSrc = srcPitch / sizeof( scaler_data_type ); - const scaler_data_type *p, *p0 = (const scaler_data_type *)srcPtr; - - unsigned int nextlineDst = dstPitch / sizeof( scaler_data_type ); - scaler_data_type *q, *q0 = (scaler_data_type *)dstPtr; - - libspectrum_byte r0, g0, b0, - r1, g1, b1, - r2, g2, b2, - rx, gx, bx; - libspectrum_signed_dword y1, y2, u1, v1, u2, v2; - -/* - 422 cosited - # + # + + only Y - # Y and Cb Cr - # + # + - - abcd... => 1/2a + a + 1/2b / 2; ...; 1/2a + b + 1/2c; ... ; ... - always 3 sample/proc - -*/ - for( j = height; j; j-- ) { - p = p0 - 1; q = q0; -#if SCALER_DATA_SIZE == 2 - r0 = R_TO_R( *p ); - g0 = G_TO_G( *p ); - b0 = B_TO_B( *p ); - p++; - r1 = R_TO_R( *p ); - g1 = G_TO_G( *p ); - b1 = B_TO_B( *p ); -#else - r0 = *p & redMask; - g0 = (*p & greenMask) >> 8; - b0 = (*p & blueMask) >> 16; - p++; /* next point */ - r1 = *(p) & redMask; - g1 = (*(p) & greenMask) >> 8; - b1 = (*(p) & blueMask) >> 16; -#endif - y1 = RGB_TO_Y( r1, g1, b1 ); - u1 = ( RGB_TO_U( r0, g0, b0 ) + 3 * RGB_TO_U( r1, g1, b1 ) ) >> 2; - v1 = ( RGB_TO_V( r0, g0, b0 ) + 3 * RGB_TO_V( r1, g1, b1 ) ) >> 2; - for( i = width; i; i-- ) { - p++; -#if SCALER_DATA_SIZE == 2 - /* 1.a. RGB => RGB */ - r0 = R_TO_R( *p ); - g0 = G_TO_G( *p ); - b0 = B_TO_B( *p ); -#else - r0 = (*p & redMask); - g0 = (*p & greenMask) >> 8; - b0 = (*p & blueMask) >> 16; -#endif -/* 1.b. RGB => YUV && 2. YUV subsampling */ - y2 = RGB_TO_Y( r0, g0, b0 ); - u2 = ( RGB_TO_U( r1, g1, b1 ) + 3 * RGB_TO_U( r0, g0, b0 ) ) >> 2; - v2 = ( RGB_TO_V( r1, g1, b1 ) + 3 * RGB_TO_V( r0, g0, b0 ) ) >> 2; - -/* 3.a. YUV => RGB */ - rx = YUV_TO_R( y1, u1, v1 ); /* [x0][ ]*/ - gx = YUV_TO_G( y1, u1, v1 ); - bx = YUV_TO_B( y1, u1, v1 ); - - u1 = ( u1 + u2 ) >> 1; - v1 = ( v1 + v2 ) >> 1; - - r1 = YUV_TO_R( y1, u1, v1 ); - g1 = YUV_TO_G( y1, u1, v1 ); - b1 = YUV_TO_B( y1, u1, v1 ); - -/* - ab => EFG - ab EFG - efg -*/ - r2 = ((int)rx + r1) >> 1; /* F */ - g2 = ((int)gx + g1) >> 1; - b2 = ((int)bx + b1) >> 1; - -#if SCALER_DATA_SIZE == 2 -/* 3.b. RGB => RGB */ - if( green6bit ) { - *q = RGB_TO_PIXEL_565( rx, gx, bx); - } else { - *q = RGB_TO_PIXEL_555( rx, gx, bx); - } -#else - *q = rx + ( gx << 8 ) + ( bx << 16 ); /* E, E, e */ -#endif - *(q + nextlineDst) = *q; - - if( settings_current.pal_tv2x ) - *(q + (nextlineDst << 1)) = - ((((*q & redblueMask) * 7) >> 3) & redblueMask) | - ((((*q & greenMask ) * 7) >> 3) & greenMask); - else - *(q + (nextlineDst << 1)) = *q; - - q++; -#if SCALER_DATA_SIZE == 2 -/* 3.b. RGB => RGB */ - if( green6bit ) { - *q = RGB_TO_PIXEL_565( r2, g2, b2 ); - } else { - *q = RGB_TO_PIXEL_555( r2, g2, b2 ); - } -#else - *q = r2 + ( g2 << 8 ) + ( b2 << 16 ); /* F, F, f*/ -#endif - *(q + nextlineDst) = *q; - - if( settings_current.pal_tv2x ) - *(q + (nextlineDst << 1)) = - ((((*q & redblueMask) * 7) >> 3) & redblueMask) | - ((((*q & greenMask ) * 7) >> 3) & greenMask); - else - *(q + (nextlineDst << 1)) = *q; - - q++; -#if SCALER_DATA_SIZE == 2 -/* 3.b. RGB => RGB */ - if( green6bit ) { - *q = RGB_TO_PIXEL_565( r1, g1, b1 ); - } else { - *q = RGB_TO_PIXEL_555( r1, g1, b1 ); - } -#else - *q = r1 + ( g1 << 8 ) + ( b1 << 16 ); /* G, G, g*/ -#endif - *(q + nextlineDst) = *q; - if( settings_current.pal_tv2x ) - *(q + (nextlineDst << 1)) = - ((((*q & redblueMask) * 7) >> 3) & redblueMask) | - ((((*q & greenMask ) * 7) >> 3) & greenMask); - else - *(q + (nextlineDst << 1)) = *q; - - q++; - y1 = y2; u1 = u2; v1 = v2; /* save for next point */ - r1 = r0; g1 = g0; b1 = b0; - } - p0 += nextlineSrc; - q0 += (nextlineDst << 1) + nextlineDst; - } -} - -void -FUNCTION( scaler_PalTV4x )( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ -/* - 1.a. RGB => 255,255,255 RGB - 1.b. RGB => YUV - 2. 4:2:2 cosited color subsampling - 3.a. YUV => RGB - 3.b 255,255,255 RGB => RGB -*/ - int i, j; - unsigned int nextlineSrc = srcPitch / sizeof( scaler_data_type ); - const scaler_data_type *p, *p0 = (const scaler_data_type *)srcPtr; - - unsigned int nextlineDst = dstPitch / sizeof( scaler_data_type ); - scaler_data_type *q, *q0 = (scaler_data_type *)dstPtr; - - libspectrum_byte r0, g0, b0, - r1, g1, b1, - rx, gx, bx; - libspectrum_signed_dword y1, y2, u1, v1, u2, v2; - -/* - 422 cosited - # + # + + only Y - # Y and Cb Cr - # + # + - - abcd... => 1/2a + a + 1/2b / 2; ...; 1/2a + b + 1/2c; ... ; ... - always 3 sample/proc - -*/ - for( j = height; j; j-- ) { - p = p0 - 1; q = q0; -#if SCALER_DATA_SIZE == 2 - r0 = R_TO_R( *p ); - g0 = G_TO_G( *p ); - b0 = B_TO_B( *p ); - p++; - r1 = R_TO_R( *p ); - g1 = G_TO_G( *p ); - b1 = B_TO_B( *p ); -#else - r0 = *p & redMask; - g0 = (*p & greenMask) >> 8; - b0 = (*p & blueMask) >> 16; - p++; - r1 = *(p) & redMask; - g1 = (*(p) & greenMask) >> 8; - b1 = (*(p) & blueMask) >> 16; -#endif - y1 = RGB_TO_Y( r1, g1, b1 ); - u1 = ( RGB_TO_U( r0, g0, b0 ) + 3 * RGB_TO_U( r1, g1, b1 ) ) >> 2; - v1 = ( RGB_TO_V( r0, g0, b0 ) + 3 * RGB_TO_V( r1, g1, b1 ) ) >> 2; - for( i = width; i; i-- ) { - p++; /* next point */ -#if SCALER_DATA_SIZE == 2 - /* 1.a. RGB => RGB */ - r0 = R_TO_R( *p ); - g0 = G_TO_G( *p ); - b0 = B_TO_B( *p ); -#else - r0 = (*p & redMask); - g0 = (*p & greenMask) >> 8; - b0 = (*p & blueMask) >> 16; -#endif -/* 1.b. RGB => YUV && 2. YUV subsampling */ - y2 = RGB_TO_Y( r0, g0, b0 ); - u2 = ( RGB_TO_U( r1, g1, b1 ) + 3 * RGB_TO_U( r0, g0, b0 ) ) >> 2; - v2 = ( RGB_TO_V( r1, g1, b1 ) + 3 * RGB_TO_V( r0, g0, b0 ) ) >> 2; - -/* 3.a. YUV => RGB */ - rx = YUV_TO_R( y1, u1, v1 ); /* [x0][ ]*/ - gx = YUV_TO_G( y1, u1, v1 ); - bx = YUV_TO_B( y1, u1, v1 ); - - u1 = ( u1 + u2 ) >> 1; - v1 = ( v1 + v2 ) >> 1; - - r1 = YUV_TO_R( y1, u1, v1 ); - g1 = YUV_TO_G( y1, u1, v1 ); - b1 = YUV_TO_B( y1, u1, v1 ); - -#if SCALER_DATA_SIZE == 2 -/* - q q+1 | q+2 q+3 - q q+1 | q+2 q+3 - _______________ - -*/ -/* 3.b. RGB => RGB */ - if( green6bit ) { - *q = *(q+1) = RGB_TO_PIXEL_565( rx, gx, bx ); - } else { - *q = *(q+1) = RGB_TO_PIXEL_555( rx, gx, bx ); - } -#else - *q = *(q+1) = rx + ( gx << 8 ) + ( bx << 16 ); -#endif - - if( settings_current.pal_tv2x ) - *(q + nextlineDst) = *(q + nextlineDst + 1) = - *(q + 2 * nextlineDst) = *(q + 2 * nextlineDst + 1) = - *(q + 3 * nextlineDst) = *(q + 3 * nextlineDst + 1) = - ((((*q & redblueMask) * 7) >> 3) & redblueMask) | - ((((*q & greenMask ) * 7) >> 3) & greenMask); - else - *(q + nextlineDst) = *(q + nextlineDst + 1) = - *(q + 2 * nextlineDst) = *(q + 2 * nextlineDst + 1) = - *(q + 3 * nextlineDst) = *(q + 3 * nextlineDst + 1) = *q; - - q++; q++; -#if SCALER_DATA_SIZE == 2 -/* 3.b. RGB => RGB */ - if( green6bit ) { - *q = *(q + 1) = RGB_TO_PIXEL_565( r1, g1, b1 ); - } else { - *q = *(q + 1) = RGB_TO_PIXEL_555( r1, g1, b1 ); - } -#else - *q = *(q + 1) = r1 + ( g1 << 8 ) + ( b1 << 16 ); -#endif - if( settings_current.pal_tv2x ) - *(q + nextlineDst) = *(q + nextlineDst + 1) = - *(q + 2 * nextlineDst) = *(q + 2 * nextlineDst + 1) = - *(q + 3 * nextlineDst) = *(q + 3 * nextlineDst + 1) = - ((((*q & redblueMask) * 7) >> 3) & redblueMask) | - ((((*q & greenMask ) * 7) >> 3) & greenMask); - else - *(q + nextlineDst) = *(q + nextlineDst + 1) = - *(q + 2 * nextlineDst) = *(q + 2 * nextlineDst + 1) = - *(q + 3 * nextlineDst) = *(q + 3 * nextlineDst + 1) = *q; - - q++; q++; - y1 = y2; u1 = u2; v1 = v2; /* save for next point */ - r1 = r0; g1 = g0; b1 = b0; - } - p0 += nextlineSrc; - q0 += nextlineDst << 2; - } -} - -#define prevline (-nextlineSrc) -#define nextline nextlineSrc -#define MOVE_B_TO_A(A,B) \ - w[A] = w[B]; y[A] = y[B]; u[A] = u[B]; v[A] = v[B]; -#define MOVE_P_RIGHT \ - MOVE_B_TO_A(1,2) \ - MOVE_B_TO_A(4,5) \ - MOVE_B_TO_A(7,8) \ - MOVE_B_TO_A(2,3) \ - MOVE_B_TO_A(5,6) \ - MOVE_B_TO_A(8,9) - -void -FUNCTION( scaler_HQ2x ) ( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - int i, j, k, pattern; - int nextlineSrc = srcPitch / sizeof( scaler_data_type ); - const scaler_data_type *p, *p0 = (const scaler_data_type *)srcPtr; - int nextlineDst = dstPitch / sizeof( scaler_data_type ); - scaler_data_type *q, *q1, *qN, *qN1, *q0 = (scaler_data_type *)dstPtr; - libspectrum_qword w[10]; - - libspectrum_byte r, g, b; - libspectrum_signed_dword y[10], u[10], v[10]; - - /* +----+----+----+ - | | | | - | w1 | w2 | w3 | - +----+----+----+ - | | | | - | w4 | w5 | w6 | - +----+----+----+ - | | | | - | w7 | w8 | w9 | - +----+----+----+ */ - for( j = 0; j < height; j++ ) { - p = p0; - q = q0; q1 = q + 1; - qN = q + nextlineDst; qN1 = qN + 1; - w[2] = *(p + prevline); - w[5] = *p; - w[8] = *(p + nextline); - w[1] = *(p + prevline - 1); - w[4] = *(p - 1); - w[7] = *(p + nextline - 1); - w[3] = *(p + prevline + 1); - w[6] = *(p + 1); - w[9] = *(p + nextline + 1); - for( k = 1; k <= 9; k++ ) { -#if SCALER_DATA_SIZE == 2 - r = R_TO_R( w[k] ); - g = G_TO_G( w[k] ); - b = B_TO_B( w[k] ); -#else - r = w[k] & redMask; - g = (w[k] & greenMask) >> 8; - b = (w[k] & blueMask) >> 16; -#endif - y[k] = RGB_TO_Y( r, g, b ); - u[k] = RGB_TO_U( r, g, b ); - v[k] = RGB_TO_V( r, g, b ); - } - - for( i = 0; i < width; i++ ) { - pattern = 0; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[1], u[1], v[1] ) ) pattern |= 0x01; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[2], u[2], v[2] ) ) pattern |= 0x02; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[3], u[3], v[3] ) ) pattern |= 0x04; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[4], u[4], v[4] ) ) pattern |= 0x08; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[6], u[6], v[6] ) ) pattern |= 0x10; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[7], u[7], v[7] ) ) pattern |= 0x20; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[8], u[8], v[8] ) ) pattern |= 0x40; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[9], u[9], v[9] ) ) pattern |= 0x80; - -#include "scaler_hq2x.c" - - p++; - q += 2; q1 += 2; - qN += 2; qN1 += 2; - MOVE_P_RIGHT - w[3] = *(p + prevline + 1); - w[6] = *(p + 1); - w[9] = *(p + nextline + 1); - for( k = 3; k <= 9; k += 3 ) { -#if SCALER_DATA_SIZE == 2 - r = R_TO_R( w[k] ); - g = G_TO_G( w[k] ); - b = B_TO_B( w[k] ); -#else - r = w[k] & redMask; - g = ( w[k] & greenMask ) >> 8; - b = ( w[k] & blueMask ) >> 16; -#endif - y[k] = RGB_TO_Y( r, g, b ); - u[k] = RGB_TO_U( r, g, b ); - v[k] = RGB_TO_V( r, g, b ); - } - } - p0 += nextlineSrc; - q0 += nextlineDst << 1; - } -} - -void -FUNCTION( scaler_HQ3x ) ( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - int i, j, k, pattern; - int nextlineSrc = srcPitch / sizeof( scaler_data_type ); - const scaler_data_type *p, *p0 = (const scaler_data_type *)srcPtr; - int nextlineDst = dstPitch / sizeof( scaler_data_type ); - scaler_data_type *q, *qN, *qNN, *q1, *qN1, *qNN1, *q2, *qN2, *qNN2, - *q0 = (scaler_data_type *)dstPtr; - libspectrum_qword w[10]; - - libspectrum_byte r, g, b; - libspectrum_signed_dword y[10], u[10], v[10]; - - /* +----+----+----+ - | | | | - | w1 | w2 | w3 | - +----+----+----+ - | | | | - | w4 | w5 | w6 | - +----+----+----+ - | | | | - | w7 | w8 | w9 | - +----+----+----+ */ - for( j = 0; j < height; j++ ) { - p = p0; - q = q0; - q1 = q + 1; q2 = q + 2; - qN = q + nextlineDst; qN1 = qN + 1; qN2 = qN + 2; - qNN = qN + nextlineDst; qNN1 = qNN + 1; qNN2 = qNN + 2; - - w[2] = *(p + prevline); - w[5] = *p; - w[8] = *(p + nextline); - w[1] = *(p + prevline - 1); - w[4] = *(p - 1); - w[7] = *(p + nextline - 1); - w[3] = *(p + prevline + 1); - w[6] = *(p + 1); - w[9] = *(p + nextline + 1); - for( k = 1; k <= 9; k++ ) { -#if SCALER_DATA_SIZE == 2 - r = R_TO_R( w[k] ); - g = G_TO_G( w[k] ); - b = B_TO_B( w[k] ); -#else - r = w[k] & redMask; - g = (w[k] & greenMask) >> 8; - b = (w[k] & blueMask) >> 16; -#endif - y[k] = RGB_TO_Y( r, g, b ); - u[k] = RGB_TO_U( r, g, b ); - v[k] = RGB_TO_V( r, g, b ); - } - - for( i = 0; i < width; i++ ) { - pattern = 0; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[1], u[1], v[1] ) ) pattern |= 0x01; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[2], u[2], v[2] ) ) pattern |= 0x02; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[3], u[3], v[3] ) ) pattern |= 0x04; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[4], u[4], v[4] ) ) pattern |= 0x08; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[6], u[6], v[6] ) ) pattern |= 0x10; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[7], u[7], v[7] ) ) pattern |= 0x20; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[8], u[8], v[8] ) ) pattern |= 0x40; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[9], u[9], v[9] ) ) pattern |= 0x80; - -#include "scaler_hq3x.c" - - p++; - q += 3; q1 += 3; q2 += 3; - qN += 3; qN1 += 3; qN2 += 3; - qNN += 3; qNN1 += 3; qNN2 += 3; - MOVE_P_RIGHT - w[3] = *(p + prevline + 1); - w[6] = *(p + 1); - w[9] = *(p + nextline + 1); - for( k = 3; k <= 9; k += 3 ) { -#if SCALER_DATA_SIZE == 2 - r = R_TO_R( w[k] ); - g = G_TO_G( w[k] ); - b = B_TO_B( w[k] ); -#else - r = w[k] & redMask; - g = ( w[k] & greenMask ) >> 8; - b = ( w[k] & blueMask ) >> 16; -#endif - y[k] = RGB_TO_Y( r, g, b ); - u[k] = RGB_TO_U( r, g, b ); - v[k] = RGB_TO_V( r, g, b ); - } - } - p0 += nextlineSrc; - q0 += ( nextlineDst << 1 ) + nextlineDst; - } -} - -void -FUNCTION( scaler_HQ4x ) ( const libspectrum_byte *srcPtr, - libspectrum_dword srcPitch, - libspectrum_byte *dstPtr, - libspectrum_dword dstPitch, - int width, int height ) -{ - int i, j, k, pattern; - int nextlineSrc = srcPitch / sizeof( scaler_data_type ); - const scaler_data_type *p, *p0 = (const scaler_data_type *)srcPtr; - int nextlineDst = dstPitch / sizeof( scaler_data_type ); - scaler_data_type *q, *qN, *qNN, *qNNN, - *q1, *qN1, *qNN1, *qNNN1, - *q2, *qN2, *qNN2, *qNNN2, - *q3, *qN3, *qNN3, *qNNN3, - *q0 = (scaler_data_type *)dstPtr; - libspectrum_qword w[10]; - - libspectrum_byte r, g, b; - libspectrum_signed_dword y[10], u[10], v[10]; - - /* +----+----+----+ - | | | | - | w1 | w2 | w3 | - +----+----+----+ - | | | | - | w4 | w5 | w6 | - +----+----+----+ - | | | | - | w7 | w8 | w9 | - +----+----+----+ */ - for( j = 0; j < height; j++ ) { - p = p0; - q = q0; - q1 = q + 1; q2 = q + 2; q3 = q + 3; - qN = q + nextlineDst; qN1 = qN + 1; qN2 = qN + 2; qN3 = qN + 3; - qNN = qN + nextlineDst; qNN1 = qNN + 1; qNN2 = qNN + 2; qNN3 = qNN + 3; - qNNN = qNN + nextlineDst; qNNN1 = qNNN + 1; qNNN2 = qNNN + 2; qNNN3 = qNNN + 3; - - w[2] = *(p + prevline); - w[5] = *p; - w[8] = *(p + nextline); - w[1] = *(p + prevline - 1); - w[4] = *(p - 1); - w[7] = *(p + nextline - 1); - w[3] = *(p + prevline + 1); - w[6] = *(p + 1); - w[9] = *(p + nextline + 1); - for( k = 1; k <= 9; k++ ) { -#if SCALER_DATA_SIZE == 2 - r = R_TO_R( w[k] ); - g = G_TO_G( w[k] ); - b = B_TO_B( w[k] ); -#else - r = w[k] & redMask; - g = (w[k] & greenMask) >> 8; - b = (w[k] & blueMask) >> 16; -#endif - y[k] = RGB_TO_Y( r, g, b ); - u[k] = RGB_TO_U( r, g, b ); - v[k] = RGB_TO_V( r, g, b ); - } - - for( i = 0; i < width; i++ ) { - pattern = 0; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[1], u[1], v[1] ) ) pattern |= 0x01; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[2], u[2], v[2] ) ) pattern |= 0x02; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[3], u[3], v[3] ) ) pattern |= 0x04; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[4], u[4], v[4] ) ) pattern |= 0x08; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[6], u[6], v[6] ) ) pattern |= 0x10; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[7], u[7], v[7] ) ) pattern |= 0x20; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[8], u[8], v[8] ) ) pattern |= 0x40; - if( HQ_YUVDIFF( y[5], u[5], v[5], y[9], u[9], v[9] ) ) pattern |= 0x80; - -#include "scaler_hq4x.c" - - p++; - q += 4; q1 += 4; q2 += 4; q3 += 4; - qN += 4; qN1 += 4; qN2 += 4; qN3 += 4; - qNN += 4; qNN1 += 4; qNN2 += 4; qNN3 += 4; - qNNN += 4; qNNN1 += 4; qNNN2 += 4; qNNN3 += 4; - MOVE_P_RIGHT - w[3] = *(p + prevline + 1); - w[6] = *(p + 1); - w[9] = *(p + nextline + 1); - for( k = 3; k <= 9; k += 3 ) { -#if SCALER_DATA_SIZE == 2 - r = R_TO_R( w[k] ); - g = G_TO_G( w[k] ); - b = B_TO_B( w[k] ); -#else - r = w[k] & redMask; - g = ( w[k] & greenMask ) >> 8; - b = ( w[k] & blueMask ) >> 16; -#endif - y[k] = RGB_TO_Y( r, g, b ); - u[k] = RGB_TO_U( r, g, b ); - v[k] = RGB_TO_V( r, g, b ); - } - } - p0 += nextlineSrc; - q0 += ( nextlineDst << 2 ); - } -} diff --git a/fuse/ui/sdl/Makefile.am b/fuse/ui/sdl/Makefile.am deleted file mode 100644 index dc6622d..0000000 --- a/fuse/ui/sdl/Makefile.am +++ /dev/null @@ -1,48 +0,0 @@ -## Process this file with automake to produce Makefile.in -## Copyright (c) 2001-2004 Philip Kendall -## Copyright (c) 2015 Sergio Baldoví - -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -## -## Author contact information: -## -## E-mail: philip-fuse@shadowmagic.org.uk - -if UI_SDL - -fuse_SOURCES += $(ui_sdl_files) - -BUILT_SOURCES += $(ui_sdl_built) - -endif - - -CLEANFILES += $(ui_sdl_built) - -ui_sdl_files = \ - ui/sdl/sdldisplay.c \ - ui/sdl/sdldisplay.h \ - ui/sdl/sdljoystick.c \ - ui/sdl/sdljoystick.h \ - ui/sdl/sdlkeyboard.c \ - ui/sdl/sdlkeyboard.h \ - ui/sdl/sdlui.c \ - ui/sdl/keysyms.c - -ui_sdl_built = ui/sdl/keysyms.c - -ui/sdl/keysyms.c: $(srcdir)/keysyms.pl $(srcdir)/keysyms.dat - @$(MKDIR_P) ui/sdl - $(AM_V_GEN)$(PERL) -I$(srcdir)/perl $(srcdir)/keysyms.pl sdl $(srcdir)/keysyms.dat > $@.tmp && mv $@.tmp $@ diff --git a/fuse/ui/sdl/sdldisplay.c b/fuse/ui/sdl/sdldisplay.c deleted file mode 100644 index 2b73acc..0000000 --- a/fuse/ui/sdl/sdldisplay.c +++ /dev/null @@ -1,928 +0,0 @@ -/* sdldisplay.c: Routines for dealing with the SDL display - Copyright (c) 2000-2006 Philip Kendall, Matan Ziv-Av, Fredrick Meunier - Copyright (c) 2015 Adrien Destugues - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include -#include - -#include - -#include "display.h" -#include "fuse.h" -#include "machine.h" -#include "peripherals/scld.h" -#include "screenshot.h" -#include "settings.h" -#include "ui/ui.h" -#include "ui/scaler/scaler.h" -#include "ui/uidisplay.h" -#include "utils.h" - -SDL_Surface *sdldisplay_gc = NULL; /* Hardware screen */ -static SDL_Surface *tmp_screen=NULL; /* Temporary screen for scalers */ - -static SDL_Surface *red_cassette[2], *green_cassette[2]; -static SDL_Surface *red_mdr[2], *green_mdr[2]; -static SDL_Surface *red_disk[2], *green_disk[2]; - -static ui_statusbar_state sdl_disk_state, sdl_mdr_state, sdl_tape_state; -static int sdl_status_updated; - -static int tmp_screen_width; - -static Uint32 colour_values[16]; - -static SDL_Color colour_palette[] = { - { 0, 0, 0, 0 }, - { 0, 0, 192, 0 }, - { 192, 0, 0, 0 }, - { 192, 0, 192, 0 }, - { 0, 192, 0, 0 }, - { 0, 192, 192, 0 }, - { 192, 192, 0, 0 }, - { 192, 192, 192, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 255, 0 }, - { 255, 0, 0, 0 }, - { 255, 0, 255, 0 }, - { 0, 255, 0, 0 }, - { 0, 255, 255, 0 }, - { 255, 255, 0, 0 }, - { 255, 255, 255, 0 } -}; - -static Uint32 bw_values[16]; - -/* This is a rule of thumb for the maximum number of rects that can be updated - each frame. If more are generated we just update the whole screen */ -#define MAX_UPDATE_RECT 300 -static SDL_Rect updated_rects[MAX_UPDATE_RECT]; -static int num_rects = 0; -static libspectrum_byte sdldisplay_force_full_refresh = 1; - -static int max_fullscreen_height; -static int min_fullscreen_height; -static int fullscreen_width = 0; -static int fullscreen_x_off = 0; -static int fullscreen_y_off = 0; - -/* The current size of the display (in units of DISPLAY_SCREEN_*) */ -static float sdldisplay_current_size = 1; - -static libspectrum_byte sdldisplay_is_full_screen = 0; - -static int image_width; -static int image_height; - -static int timex; - -static void init_scalers( void ); -static int sdldisplay_allocate_colours( int numColours, Uint32 *colour_values, - Uint32 *bw_values ); - -static int sdldisplay_load_gfx_mode( void ); - -static void -init_scalers( void ) -{ - scaler_register_clear(); - - scaler_register( SCALER_NORMAL ); - scaler_register( SCALER_2XSAI ); - scaler_register( SCALER_SUPER2XSAI ); - scaler_register( SCALER_SUPEREAGLE ); - scaler_register( SCALER_ADVMAME2X ); - scaler_register( SCALER_ADVMAME3X ); - scaler_register( SCALER_DOTMATRIX ); - scaler_register( SCALER_PALTV ); - scaler_register( SCALER_HQ2X ); - if( machine_current->timex ) { - scaler_register( SCALER_HALF ); - scaler_register( SCALER_HALFSKIP ); - scaler_register( SCALER_TIMEXTV ); - scaler_register( SCALER_TIMEX1_5X ); - scaler_register( SCALER_TIMEX2X ); - } else { - scaler_register( SCALER_DOUBLESIZE ); - scaler_register( SCALER_TRIPLESIZE ); - scaler_register( SCALER_QUADSIZE ); - scaler_register( SCALER_TV2X ); - scaler_register( SCALER_TV3X ); - scaler_register( SCALER_TV4X ); - scaler_register( SCALER_PALTV2X ); - scaler_register( SCALER_PALTV3X ); - scaler_register( SCALER_PALTV4X ); - scaler_register( SCALER_HQ3X ); - scaler_register( SCALER_HQ4X ); - } - - if( scaler_is_supported( current_scaler ) ) { - scaler_select_scaler( current_scaler ); - } else { - scaler_select_scaler( SCALER_NORMAL ); - } -} - -static int -sdl_convert_icon( SDL_Surface *source, SDL_Surface **icon, int red ) -{ - SDL_Surface *copy; /* Copy with altered palette */ - int i; - - SDL_Color colors[ source->format->palette->ncolors ]; - - copy = SDL_ConvertSurface( source, source->format, SDL_SWSURFACE ); - - for( i = 0; i < copy->format->palette->ncolors; i++ ) { - colors[i].r = red ? copy->format->palette->colors[i].r : 0; - colors[i].g = red ? 0 : copy->format->palette->colors[i].g; - colors[i].b = 0; - } - - SDL_SetPalette( copy, SDL_LOGPAL, colors, 0, i ); - - icon[0] = SDL_ConvertSurface( copy, tmp_screen->format, SDL_SWSURFACE ); - - SDL_FreeSurface( copy ); - - icon[1] = SDL_CreateRGBSurface( SDL_SWSURFACE, - (icon[0]->w)<<1, (icon[0]->h)<<1, - icon[0]->format->BitsPerPixel, - icon[0]->format->Rmask, - icon[0]->format->Gmask, - icon[0]->format->Bmask, - icon[0]->format->Amask - ); - - ( scaler_get_proc16( SCALER_DOUBLESIZE ) )( - (libspectrum_byte*)icon[0]->pixels, - icon[0]->pitch, - (libspectrum_byte*)icon[1]->pixels, - icon[1]->pitch, icon[0]->w, icon[0]->h - ); - - return 0; -} - -static int -sdl_load_status_icon( const char*filename, SDL_Surface **red, SDL_Surface **green ) -{ - char path[ PATH_MAX ]; - SDL_Surface *temp; /* Copy of image as loaded */ - - if( utils_find_file_path( filename, path, UTILS_AUXILIARY_LIB ) ) { - fprintf( stderr, "%s: Error getting path for icons\n", fuse_progname ); - return -1; - } - - if((temp = SDL_LoadBMP(path)) == NULL) { - fprintf( stderr, "%s: Error loading icon \"%s\" text:%s\n", fuse_progname, - path, SDL_GetError() ); - return -1; - } - - if(temp->format->palette == NULL) { - fprintf( stderr, "%s: Icon \"%s\" is not paletted\n", fuse_progname, path ); - return -1; - } - - sdl_convert_icon( temp, red, 1 ); - sdl_convert_icon( temp, green, 0 ); - - SDL_FreeSurface( temp ); - - return 0; -} - -int -uidisplay_init( int width, int height ) -{ - SDL_Rect **modes; - int no_modes; - int i = 0, mw = 0, mh = 0, mn = 0; - - /* Get available fullscreen/software modes */ - modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_SWSURFACE); - - no_modes = ( modes == (SDL_Rect **) 0 || modes == (SDL_Rect **) -1 ) ? 1 : 0; - - if( settings_current.sdl_fullscreen_mode && - strcmp( settings_current.sdl_fullscreen_mode, "list" ) == 0 ) { - - fprintf( stderr, - "=====================================================================\n" - " List of available SDL fullscreen modes:\n" - "---------------------------------------------------------------------\n" - " No. width height\n" - "---------------------------------------------------------------------\n" - ); - if( no_modes ) { - fprintf( stderr, " ** The modes list is empty%s...\n", - modes == (SDL_Rect **) -1 ? ", all resolutions allowed" : "" ); - } else { - for( i = 0; modes[i]; i++ ) { - fprintf( stderr, "% 3d % 5d % 5d\n", i + 1, modes[i]->w, modes[i]->h ); - } - } - fprintf( stderr, - "=====================================================================\n"); - fuse_exiting = 1; - return 0; - } - - if( !no_modes ) { - for( i=0; modes[i]; ++i ); /* count modes */ - } - - if( settings_current.sdl_fullscreen_mode ) { - if( sscanf( settings_current.sdl_fullscreen_mode, " %dx%d", &mw, &mh ) != 2 ) { - if( !no_modes && - sscanf( settings_current.sdl_fullscreen_mode, " %d", &mn ) == 1 && - mn <= i ) { - mw = modes[mn - 1]->w; mh = modes[mn - 1]->h; - } - } - } - - /* Check if there are any modes available, or if our resolution is restricted - at all */ - if( mh > 0 ) { - /* set from command line */ - max_fullscreen_height = min_fullscreen_height = mh; - fullscreen_width = mw; - } else if( no_modes ){ - /* Just try whatever we have and see what happens */ - max_fullscreen_height = 480; - min_fullscreen_height = 240; - } else { - /* Record the largest supported fullscreen software mode */ - max_fullscreen_height = modes[0]->h; - - /* Record the smallest supported fullscreen software mode */ - for( i=0; modes[i]; ++i ) { - min_fullscreen_height = modes[i]->h; - } - } - - image_width = width; - image_height = height; - - timex = machine_current->timex; - - init_scalers(); - - if ( scaler_select_scaler( current_scaler ) ) - scaler_select_scaler( SCALER_NORMAL ); - - if( sdldisplay_load_gfx_mode() ) return 1; - - SDL_WM_SetCaption( "Fuse", "Fuse" ); - - /* We can now output error messages to our output device */ - display_ui_initialised = 1; - - sdl_load_status_icon( "cassette.bmp", red_cassette, green_cassette ); - sdl_load_status_icon( "microdrive.bmp", red_mdr, green_mdr ); - sdl_load_status_icon( "plus3disk.bmp", red_disk, green_disk ); - - return 0; -} - -static int -sdldisplay_allocate_colours( int numColours, Uint32 *colour_values, - Uint32 *bw_values ) -{ - int i; - Uint8 red, green, blue, grey; - - for( i = 0; i < numColours; i++ ) { - - red = colour_palette[i].r; - green = colour_palette[i].g; - blue = colour_palette[i].b; - - /* Addition of 0.5 is to avoid rounding errors */ - grey = ( 0.299 * red + 0.587 * green + 0.114 * blue ) + 0.5; - - colour_values[i] = SDL_MapRGB( tmp_screen->format, red, green, blue ); - bw_values[i] = SDL_MapRGB( tmp_screen->format, grey, grey, grey ); - } - - return 0; -} - -static void -sdldisplay_find_best_fullscreen_scaler( void ) -{ - static int windowed_scaler = -1; - static int searching_fullscreen_scaler = 0; - - /* Make sure we have at least more than half of the screen covered in - fullscreen to avoid the "postage stamp" on machines that don't support - 320x240 anymore e.g. Mac notebooks */ - if( settings_current.full_screen ) { - int i = 0; - - if( searching_fullscreen_scaler ) return; - searching_fullscreen_scaler = 1; - while( i < SCALER_NUM && - ( image_height*sdldisplay_current_size <= min_fullscreen_height/2 || - image_height*sdldisplay_current_size > max_fullscreen_height ) ) { - if( windowed_scaler == -1) windowed_scaler = current_scaler; - while( !scaler_is_supported(i) ) i++; - scaler_select_scaler( i++ ); - sdldisplay_current_size = scaler_get_scaling_factor( current_scaler ); - /* if we failed to find a suitable size scaler, just use normal (what the - user had originally may be too big) */ - if( image_height * sdldisplay_current_size <= min_fullscreen_height/2 || - image_height * sdldisplay_current_size > max_fullscreen_height ) { - scaler_select_scaler( SCALER_NORMAL ); - sdldisplay_current_size = scaler_get_scaling_factor( current_scaler ); - } - } - searching_fullscreen_scaler = 0; - } else { - if( windowed_scaler != -1 ) { - scaler_select_scaler( windowed_scaler ); - windowed_scaler = -1; - sdldisplay_current_size = scaler_get_scaling_factor( current_scaler ); - } - } -} - -static int -sdldisplay_load_gfx_mode( void ) -{ - Uint16 *tmp_screen_pixels; - - sdldisplay_force_full_refresh = 1; - - /* Free the old surface */ - if( tmp_screen ) { - free( tmp_screen->pixels ); - SDL_FreeSurface( tmp_screen ); - tmp_screen = NULL; - } - - tmp_screen_width = (image_width + 3); - - sdldisplay_current_size = scaler_get_scaling_factor( current_scaler ); - - sdldisplay_find_best_fullscreen_scaler(); - - /* Create the surface that contains the scaled graphics in 16 bit mode */ - sdldisplay_gc = SDL_SetVideoMode( - settings_current.full_screen && fullscreen_width ? fullscreen_width : - image_width * sdldisplay_current_size, - settings_current.full_screen && fullscreen_width ? max_fullscreen_height : - image_height * sdldisplay_current_size, - 16, - settings_current.full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) - : SDL_SWSURFACE - ); - if( !sdldisplay_gc ) { - fprintf( stderr, "%s: couldn't create SDL graphics context\n", fuse_progname ); - fuse_abort(); - } - - settings_current.full_screen = - !!( sdldisplay_gc->flags & ( SDL_FULLSCREEN | SDL_NOFRAME ) ); - sdldisplay_is_full_screen = settings_current.full_screen; - - /* Distinguish 555 and 565 mode */ - if( sdldisplay_gc->format->Gmask >> sdldisplay_gc->format->Gshift == 0x1f ) - scaler_select_bitformat( 555 ); - else - scaler_select_bitformat( 565 ); - - /* Create the surface used for the graphics in 16 bit before scaling */ - - /* Need some extra bytes around when using 2xSaI */ - tmp_screen_pixels = (Uint16*)calloc(tmp_screen_width*(image_height+3), sizeof(Uint16)); - tmp_screen = SDL_CreateRGBSurfaceFrom(tmp_screen_pixels, - tmp_screen_width, - image_height + 3, - 16, tmp_screen_width*2, - sdldisplay_gc->format->Rmask, - sdldisplay_gc->format->Gmask, - sdldisplay_gc->format->Bmask, - sdldisplay_gc->format->Amask ); - - if( !tmp_screen ) { - fprintf( stderr, "%s: couldn't create tmp_screen\n", fuse_progname ); - fuse_abort(); - } - - fullscreen_x_off = ( sdldisplay_gc->w - image_width * sdldisplay_current_size ) * - sdldisplay_is_full_screen / 2; - fullscreen_y_off = ( sdldisplay_gc->h - image_height * sdldisplay_current_size ) * - sdldisplay_is_full_screen / 2; - - sdldisplay_allocate_colours( 16, colour_values, bw_values ); - - /* Redraw the entire screen... */ - display_refresh_all(); - - return 0; -} - -int -uidisplay_hotswap_gfx_mode( void ) -{ - fuse_emulation_pause(); - - /* Free the old surface */ - if( tmp_screen ) { - free( tmp_screen->pixels ); - SDL_FreeSurface( tmp_screen ); tmp_screen = NULL; - } - - /* Setup the new GFX mode */ - if( sdldisplay_load_gfx_mode() ) return 1; - - /* reset palette */ - SDL_SetColors( sdldisplay_gc, colour_palette, 0, 16 ); - - /* Mac OS X resets the state of the cursor after a switch to full screen - mode */ - if ( settings_current.full_screen || ui_mouse_grabbed ) { - SDL_ShowCursor( SDL_DISABLE ); - SDL_WarpMouse( 128, 128 ); - } else { - SDL_ShowCursor( SDL_ENABLE ); - } - - fuse_emulation_unpause(); - - return 0; -} - -SDL_Surface *saved = NULL; - -void -uidisplay_frame_save( void ) -{ - if( saved ) { - SDL_FreeSurface( saved ); - saved = NULL; - } - - saved = SDL_ConvertSurface( tmp_screen, tmp_screen->format, - SDL_SWSURFACE ); -} - -void -uidisplay_frame_restore( void ) -{ - if( saved ) { - SDL_BlitSurface( saved, NULL, tmp_screen, NULL ); - sdldisplay_force_full_refresh = 1; - } -} - -static void -sdl_blit_icon( SDL_Surface **icon, - SDL_Rect *r, Uint32 tmp_screen_pitch, - Uint32 dstPitch ) -{ - int x, y, w, h, dst_x, dst_y, dst_h; - - if( timex ) { - r->x<<=1; - r->y<<=1; - r->w<<=1; - r->h<<=1; - } - - x = r->x; - y = r->y; - w = r->w; - h = r->h; - r->x++; - r->y++; - - if( SDL_BlitSurface( icon[timex], NULL, tmp_screen, r ) ) return; - - /* Extend the dirty region by 1 pixel for scalers - that "smear" the screen, e.g. 2xSAI */ - if( scaler_flags & SCALER_FLAGS_EXPAND ) - scaler_expander( &x, &y, &w, &h, image_width, image_height ); - - dst_y = y * sdldisplay_current_size + fullscreen_y_off; - dst_h = h; - dst_x = x * sdldisplay_current_size + fullscreen_x_off; - - scaler_proc16( - (libspectrum_byte*)tmp_screen->pixels + - (x+1) * tmp_screen->format->BytesPerPixel + - (y+1) * tmp_screen_pitch, - tmp_screen_pitch, - (libspectrum_byte*)sdldisplay_gc->pixels + - dst_x * sdldisplay_gc->format->BytesPerPixel + - dst_y * dstPitch, - dstPitch, w, dst_h - ); - - if( num_rects == MAX_UPDATE_RECT ) { - sdldisplay_force_full_refresh = 1; - return; - } - - /* Adjust rects for the destination rect size */ - updated_rects[num_rects].x = dst_x; - updated_rects[num_rects].y = dst_y; - updated_rects[num_rects].w = w * sdldisplay_current_size; - updated_rects[num_rects].h = dst_h * sdldisplay_current_size; - - num_rects++; -} - -static void -sdl_icon_overlay( Uint32 tmp_screen_pitch, Uint32 dstPitch ) -{ - SDL_Rect r = { 243, 218, red_disk[0]->w, red_disk[0]->h }; - - switch( sdl_disk_state ) { - case UI_STATUSBAR_STATE_ACTIVE: - sdl_blit_icon( green_disk, &r, tmp_screen_pitch, dstPitch ); - break; - case UI_STATUSBAR_STATE_INACTIVE: - sdl_blit_icon( red_disk, &r, tmp_screen_pitch, dstPitch ); - break; - case UI_STATUSBAR_STATE_NOT_AVAILABLE: - break; - } - - r.x = 264; - r.y = 218; - r.w = red_mdr[0]->w; - r.h = red_mdr[0]->h; - - switch( sdl_mdr_state ) { - case UI_STATUSBAR_STATE_ACTIVE: - sdl_blit_icon( green_mdr, &r, tmp_screen_pitch, dstPitch ); - break; - case UI_STATUSBAR_STATE_INACTIVE: - sdl_blit_icon( red_mdr, &r, tmp_screen_pitch, dstPitch ); - break; - case UI_STATUSBAR_STATE_NOT_AVAILABLE: - break; - } - - r.x = 285; - r.y = 220; - r.w = red_cassette[0]->w; - r.h = red_cassette[0]->h; - - switch( sdl_tape_state ) { - case UI_STATUSBAR_STATE_ACTIVE: - sdl_blit_icon( green_cassette, &r, tmp_screen_pitch, dstPitch ); - break; - case UI_STATUSBAR_STATE_INACTIVE: - case UI_STATUSBAR_STATE_NOT_AVAILABLE: - sdl_blit_icon( red_cassette, &r, tmp_screen_pitch, dstPitch ); - break; - } - - sdl_status_updated = 0; -} - -/* Set one pixel in the display */ -void -uidisplay_putpixel( int x, int y, int colour ) -{ - libspectrum_word *dest_base, *dest; - Uint32 *palette_values = settings_current.bw_tv ? bw_values : - colour_values; - - Uint32 palette_colour = palette_values[ colour ]; - - if( machine_current->timex ) { - x <<= 1; y <<= 1; - dest_base = dest = - (libspectrum_word*)( (libspectrum_byte*)tmp_screen->pixels + - (x+1) * tmp_screen->format->BytesPerPixel + - (y+1) * tmp_screen->pitch); - - *(dest++) = palette_colour; - *(dest++) = palette_colour; - dest = (libspectrum_word*) - ( (libspectrum_byte*)dest_base + tmp_screen->pitch); - *(dest++) = palette_colour; - *(dest++) = palette_colour; - } else { - dest = - (libspectrum_word*)( (libspectrum_byte*)tmp_screen->pixels + - (x+1) * tmp_screen->format->BytesPerPixel + - (y+1) * tmp_screen->pitch); - - *dest = palette_colour; - } -} - -/* Print the 8 pixels in `data' using ink colour `ink' and paper - colour `paper' to the screen at ( (8*x) , y ) */ -void -uidisplay_plot8( int x, int y, libspectrum_byte data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - libspectrum_word *dest; - Uint32 *palette_values = settings_current.bw_tv ? bw_values : - colour_values; - - Uint32 palette_ink = palette_values[ ink ]; - Uint32 palette_paper = palette_values[ paper ]; - - if( machine_current->timex ) { - int i; - libspectrum_word *dest_base; - - x <<= 4; y <<= 1; - - dest_base = - (libspectrum_word*)( (libspectrum_byte*)tmp_screen->pixels + - (x+1) * tmp_screen->format->BytesPerPixel + - (y+1) * tmp_screen->pitch); - - for( i=0; i<2; i++ ) { - dest = dest_base; - - *(dest++) = ( data & 0x80 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x80 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x40 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x40 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x20 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x20 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x10 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x10 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x08 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x08 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x04 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x04 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x02 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x02 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x01 ) ? palette_ink : palette_paper; - *dest = ( data & 0x01 ) ? palette_ink : palette_paper; - - dest_base = (libspectrum_word*) - ( (libspectrum_byte*)dest_base + tmp_screen->pitch); - } - } else { - x <<= 3; - - dest = - (libspectrum_word*)( (libspectrum_byte*)tmp_screen->pixels + - (x+1) * tmp_screen->format->BytesPerPixel + - (y+1) * tmp_screen->pitch); - - *(dest++) = ( data & 0x80 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x40 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x20 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x10 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x08 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x04 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x02 ) ? palette_ink : palette_paper; - *dest = ( data & 0x01 ) ? palette_ink : palette_paper; - } -} - -/* Print the 16 pixels in `data' using ink colour `ink' and paper - colour `paper' to the screen at ( (16*x) , y ) */ -void -uidisplay_plot16( int x, int y, libspectrum_word data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - libspectrum_word *dest_base, *dest; - int i; - Uint32 *palette_values = settings_current.bw_tv ? bw_values : - colour_values; - Uint32 palette_ink = palette_values[ ink ]; - Uint32 palette_paper = palette_values[ paper ]; - x <<= 4; y <<= 1; - - dest_base = - (libspectrum_word*)( (libspectrum_byte*)tmp_screen->pixels + - (x+1) * tmp_screen->format->BytesPerPixel + - (y+1) * tmp_screen->pitch); - - for( i=0; i<2; i++ ) { - dest = dest_base; - - *(dest++) = ( data & 0x8000 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x4000 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x2000 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x1000 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x0800 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x0400 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x0200 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x0100 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x0080 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x0040 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x0020 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x0010 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x0008 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x0004 ) ? palette_ink : palette_paper; - *(dest++) = ( data & 0x0002 ) ? palette_ink : palette_paper; - *dest = ( data & 0x0001 ) ? palette_ink : palette_paper; - - dest_base = (libspectrum_word*) - ( (libspectrum_byte*)dest_base + tmp_screen->pitch); - } -} - -void -uidisplay_frame_end( void ) -{ - SDL_Rect *r; - Uint32 tmp_screen_pitch, dstPitch; - SDL_Rect *last_rect; - - /* We check for a switch to fullscreen here to give systems with a - windowed-only UI a chance to free menu etc. resources before - the switch to fullscreen (e.g. Mac OS X) */ - if( sdldisplay_is_full_screen != settings_current.full_screen && - uidisplay_hotswap_gfx_mode() ) { - fprintf( stderr, "%s: Error switching to fullscreen\n", fuse_progname ); - fuse_abort(); - } - - /* Force a full redraw if requested */ - if ( sdldisplay_force_full_refresh ) { - num_rects = 1; - - updated_rects[0].x = 0; - updated_rects[0].y = 0; - updated_rects[0].w = image_width; - updated_rects[0].h = image_height; - } - - if ( !(ui_widget_level >= 0) && num_rects == 0 && !sdl_status_updated ) - return; - - if( SDL_MUSTLOCK( sdldisplay_gc ) ) SDL_LockSurface( sdldisplay_gc ); - - tmp_screen_pitch = tmp_screen->pitch; - - dstPitch = sdldisplay_gc->pitch; - - last_rect = updated_rects + num_rects; - - for( r = updated_rects; r != last_rect; r++ ) { - - int dst_y = r->y * sdldisplay_current_size + fullscreen_y_off; - int dst_h = r->h; - int dst_x = r->x * sdldisplay_current_size + fullscreen_x_off; - - scaler_proc16( - (libspectrum_byte*)tmp_screen->pixels + - (r->x+1) * tmp_screen->format->BytesPerPixel + - (r->y+1)*tmp_screen_pitch, - tmp_screen_pitch, - (libspectrum_byte*)sdldisplay_gc->pixels + - dst_x * sdldisplay_gc->format->BytesPerPixel + - dst_y*dstPitch, - dstPitch, r->w, dst_h - ); - - /* Adjust rects for the destination rect size */ - r->x = dst_x; - r->y = dst_y; - r->w *= sdldisplay_current_size; - r->h = dst_h * sdldisplay_current_size; - } - - if ( settings_current.statusbar ) - sdl_icon_overlay( tmp_screen_pitch, dstPitch ); - - if( SDL_MUSTLOCK( sdldisplay_gc ) ) SDL_UnlockSurface( sdldisplay_gc ); - - /* Finally, blit all our changes to the screen */ - SDL_UpdateRects( sdldisplay_gc, num_rects, updated_rects ); - - num_rects = 0; - sdldisplay_force_full_refresh = 0; -} - -void -uidisplay_area( int x, int y, int width, int height ) -{ - if ( sdldisplay_force_full_refresh ) - return; - - if( num_rects == MAX_UPDATE_RECT ) { - sdldisplay_force_full_refresh = 1; - return; - } - - /* Extend the dirty region by 1 pixel for scalers - that "smear" the screen, e.g. 2xSAI */ - if( scaler_flags & SCALER_FLAGS_EXPAND ) - scaler_expander( &x, &y, &width, &height, image_width, image_height ); - - updated_rects[num_rects].x = x; - updated_rects[num_rects].y = y; - updated_rects[num_rects].w = width; - updated_rects[num_rects].h = height; - - num_rects++; -} - -int -uidisplay_end( void ) -{ - int i; - - display_ui_initialised = 0; - - if ( tmp_screen ) { - free( tmp_screen->pixels ); - SDL_FreeSurface( tmp_screen ); tmp_screen = NULL; - } - - if( saved ) { - SDL_FreeSurface( saved ); saved = NULL; - } - - for( i=0; i<2; i++ ) { - if ( red_cassette[i] ) { - SDL_FreeSurface( red_cassette[i] ); red_cassette[i] = NULL; - } - if ( green_cassette[i] ) { - SDL_FreeSurface( green_cassette[i] ); green_cassette[i] = NULL; - } - if ( red_mdr[i] ) { - SDL_FreeSurface( red_mdr[i] ); red_mdr[i] = NULL; - } - if ( green_mdr[i] ) { - SDL_FreeSurface( green_mdr[i] ); green_mdr[i] = NULL; - } - if ( red_disk[i] ) { - SDL_FreeSurface( red_disk[i] ); red_disk[i] = NULL; - } - if ( green_disk[i] ) { - SDL_FreeSurface( green_disk[i] ); green_disk[i] = NULL; - } - } - - return 0; -} - -/* The statusbar handling function */ -int -ui_statusbar_update( ui_statusbar_item item, ui_statusbar_state state ) -{ - switch( item ) { - - case UI_STATUSBAR_ITEM_DISK: - sdl_disk_state = state; - sdl_status_updated = 1; - return 0; - - case UI_STATUSBAR_ITEM_PAUSED: - /* We don't support pausing this version of Fuse */ - return 0; - - case UI_STATUSBAR_ITEM_TAPE: - sdl_tape_state = state; - sdl_status_updated = 1; - return 0; - - case UI_STATUSBAR_ITEM_MICRODRIVE: - sdl_mdr_state = state; - sdl_status_updated = 1; - return 0; - - case UI_STATUSBAR_ITEM_MOUSE: - /* We don't support showing a grab icon */ - return 0; - - } - - ui_error( UI_ERROR_ERROR, "Attempt to update unknown statusbar item %d", - item ); - return 1; -} diff --git a/fuse/ui/sdl/sdldisplay.h b/fuse/ui/sdl/sdldisplay.h deleted file mode 100644 index a461f5e..0000000 --- a/fuse/ui/sdl/sdldisplay.h +++ /dev/null @@ -1,29 +0,0 @@ -/* sdldisplay.h: Routines for dealing with the SDL display - Copyright (c) 2000-2003 Philip Kendall, Fredrick Meunier - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#ifndef FUSE_SDLDISPLAY_H -#define FUSE_SDLDISPLAY_H - -extern SDL_Surface *sdldisplay_gc; /* Hardware screen */ - -#endif /* #ifndef FUSE_SDLDISPLAY_H */ diff --git a/fuse/ui/sdl/sdljoystick.c b/fuse/ui/sdl/sdljoystick.c deleted file mode 100644 index 683480a..0000000 --- a/fuse/ui/sdl/sdljoystick.c +++ /dev/null @@ -1,255 +0,0 @@ -/* sdljoystick.c: routines for dealing with the SDL joystick - Copyright (c) 2003-2004 Darren Salt, Fredrick Meunier, Philip Kendall - Copyright (c) 2015 UB880D - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - - Fred: fredm@spamcop.net - -*/ - -#include - -#if !defined USE_JOYSTICK || defined HAVE_JSW_H -/* Fake joystick, or override UI-specific handling */ -#include "../uijoystick.c" - -#else /* #if !defined USE_JOYSTICK || defined HAVE_JSW_H */ - -#include - -#include "compat.h" -#include "input.h" -#include "sdljoystick.h" -#include "settings.h" -#include "ui/ui.h" -#include "ui/uijoystick.h" - -static SDL_Joystick *joystick1 = NULL; -static SDL_Joystick *joystick2 = NULL; - -static void do_axis( int which, Sint16 value, input_key negative, - input_key positive ); -static void do_hat( int which, Uint8 value, Uint8 mask, input_key direction ); - -int -ui_joystick_init( void ) -{ - int error, retval; - -#ifdef UI_SDL - error = SDL_InitSubSystem( SDL_INIT_JOYSTICK ); -#else - /* Other UIs could handle joysticks by the SDL library */ - error = SDL_Init( SDL_INIT_JOYSTICK ); -#endif - - if ( error ) { - ui_error( UI_ERROR_ERROR, "failed to initialise joystick subsystem" ); - return 0; - } - - retval = SDL_NumJoysticks(); - - if( retval >= 2 ) { - - retval = 2; - - if( ( joystick2 = SDL_JoystickOpen( 1 ) ) == NULL ) { - ui_error( UI_ERROR_ERROR, "failed to initialise joystick 2" ); - return 0; - } - - if( SDL_JoystickNumAxes( joystick2 ) < 2 || - SDL_JoystickNumButtons( joystick2 ) < 1 ) { - ui_error( UI_ERROR_ERROR, "sorry, joystick 2 is inadequate!" ); - return 0; - } - - } - - if( retval > 0 ) { - - if( ( joystick1 = SDL_JoystickOpen( 0 ) ) == NULL ) { - ui_error( UI_ERROR_ERROR, "failed to initialise joystick 1" ); - return 0; - } - - if( SDL_JoystickNumAxes( joystick1 ) < 2 || - SDL_JoystickNumButtons( joystick1 ) < 1 ) { - ui_error( UI_ERROR_ERROR, "sorry, joystick 1 is inadequate!" ); - return 0; - } - } - - SDL_JoystickEventState( SDL_ENABLE ); - - return retval; -} - -void -ui_joystick_poll( void ) -{ - /* No action needed in SDL UI; joysticks already handled by the SDL events - system */ - -#ifndef UI_SDL - SDL_Event event; - - while( SDL_PollEvent( &event ) ) { - switch( event.type ) { - case SDL_JOYBUTTONDOWN: - sdljoystick_buttonpress( &(event.jbutton) ); - break; - case SDL_JOYBUTTONUP: - sdljoystick_buttonrelease( &(event.jbutton) ); - break; - case SDL_JOYAXISMOTION: - sdljoystick_axismove( &(event.jaxis) ); - break; - case SDL_JOYHATMOTION: - sdljoystick_hatmove( &(event.jhat) ); - break; - default: - break; - } - } -#endif - -} - -static void -button_action( SDL_JoyButtonEvent *buttonevent, input_event_type type ) -{ - int button; - input_event_t event; - - button = buttonevent->button; - if( button >= NUM_JOY_BUTTONS ) return; /* We support 'only' NUM_JOY_BUTTONS (15 as defined in ui/uijoystick.h) fire buttons */ - - event.type = type; - event.types.joystick.which = buttonevent->which; - event.types.joystick.button = INPUT_JOYSTICK_FIRE_1 + button; - - input_event( &event ); -} - -void -sdljoystick_buttonpress( SDL_JoyButtonEvent *buttonevent ) -{ - button_action( buttonevent, INPUT_EVENT_JOYSTICK_PRESS ); -} - -void -sdljoystick_buttonrelease( SDL_JoyButtonEvent *buttonevent ) -{ - button_action( buttonevent, INPUT_EVENT_JOYSTICK_RELEASE ); -} - -void -sdljoystick_axismove( SDL_JoyAxisEvent *axisevent ) -{ - if( axisevent->axis == 0 ) { - do_axis( axisevent->which, axisevent->value, - INPUT_JOYSTICK_LEFT, INPUT_JOYSTICK_RIGHT ); - } else if( axisevent->axis == 1 ) { - do_axis( axisevent->which, axisevent->value, - INPUT_JOYSTICK_UP, INPUT_JOYSTICK_DOWN ); - } -} - -static void -do_axis( int which, Sint16 value, input_key negative, input_key positive ) -{ - input_event_t event1, event2; - - event1.types.joystick.which = event2.types.joystick.which = which; - - event1.types.joystick.button = negative; - event2.types.joystick.button = positive; - - if( value > 16384 ) { - event1.type = INPUT_EVENT_JOYSTICK_RELEASE; - event2.type = INPUT_EVENT_JOYSTICK_PRESS; - } else if( value < -16384 ) { - event1.type = INPUT_EVENT_JOYSTICK_PRESS; - event2.type = INPUT_EVENT_JOYSTICK_RELEASE; - } else { - event1.type = INPUT_EVENT_JOYSTICK_RELEASE; - event2.type = INPUT_EVENT_JOYSTICK_RELEASE; - } - - input_event( &event1 ); - input_event( &event2 ); -} - -void -sdljoystick_hatmove( SDL_JoyHatEvent *hatevent ) -{ - int which = hatevent->which; - Uint8 value = hatevent->value; - - if( hatevent->hat != 0 ) { - return; - } - - do_hat( which, value, SDL_HAT_UP, INPUT_JOYSTICK_UP ); - do_hat( which, value, SDL_HAT_DOWN, INPUT_JOYSTICK_DOWN ); - do_hat( which, value, SDL_HAT_RIGHT, INPUT_JOYSTICK_RIGHT ); - do_hat( which, value, SDL_HAT_LEFT, INPUT_JOYSTICK_LEFT ); -} - -static void -do_hat( int which, Uint8 value, Uint8 mask, input_key direction ) -{ - input_event_t event; - - event.types.joystick.which = which; - event.types.joystick.button = direction; - - event.type = INPUT_EVENT_JOYSTICK_RELEASE; - input_event( &event ); - - if( value & mask ) { - event.type = INPUT_EVENT_JOYSTICK_PRESS; - input_event( &event ); - } -} - -void -ui_joystick_end( void ) -{ - if( joystick1 != NULL || joystick2 != NULL ) { - - SDL_JoystickEventState( SDL_IGNORE ); - if( joystick1 != NULL ) SDL_JoystickClose( joystick1 ); - if( joystick2 != NULL ) SDL_JoystickClose( joystick2 ); - joystick1 = NULL; - joystick2 = NULL; - - } - -#ifdef UI_SDL - SDL_QuitSubSystem( SDL_INIT_JOYSTICK ); -#else - SDL_Quit(); -#endif -} - -#endif /* #if !defined USE_JOYSTICK || defined HAVE_JSW_H */ diff --git a/fuse/ui/sdl/sdljoystick.h b/fuse/ui/sdl/sdljoystick.h deleted file mode 100644 index 48bcfce..0000000 --- a/fuse/ui/sdl/sdljoystick.h +++ /dev/null @@ -1,34 +0,0 @@ -/* sdljoystick.h: routines for dealing with the SDL joystick - Copyright (c) 2003 Fredrick Meunier - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - - Fred: fredm@spamcop.net - -*/ - -#ifndef FUSE_SDLJOYSTICK_H -#define FUSE_SDLJOYSTICK_H - -void sdljoystick_buttonpress( SDL_JoyButtonEvent *buttonevent ); -void sdljoystick_buttonrelease( SDL_JoyButtonEvent *buttonevent ); -void sdljoystick_axismove( SDL_JoyAxisEvent *axisevent ); -void sdljoystick_hatmove( SDL_JoyHatEvent *hatevent ); - -#endif /* #ifndef FUSE_SDLJOYSTICK_H */ diff --git a/fuse/ui/sdl/sdlkeyboard.c b/fuse/ui/sdl/sdlkeyboard.c deleted file mode 100644 index 583ed67..0000000 --- a/fuse/ui/sdl/sdlkeyboard.c +++ /dev/null @@ -1,123 +0,0 @@ -/* sdlkeyboard.c: routines for dealing with the SDL keyboard - Copyright (c) 2000-2005 Philip Kendall, Matan Ziv-Av, Fredrick Meunier - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include - -#include "display.h" -#include "fuse.h" -#include "keyboard.h" -#include "machine.h" -#include "settings.h" -#include "snapshot.h" -#include "spectrum.h" -#include "tape.h" -#include "ui/ui.h" -#include "utils.h" -#include "sdlkeyboard.h" - -/* Map low byte of UCS-2(?) Unicode to Fuse input layer keysym for - upper case letters */ -extern const keysyms_map_t unicode_keysyms_map[]; - -static GHashTable *unicode_keysyms_hash; - -static input_key -unicode_keysyms_remap( libspectrum_dword ui_keysym ) -{ - const input_key *ptr; - - ptr = g_hash_table_lookup( unicode_keysyms_hash, &ui_keysym ); - - return ptr ? *ptr : INPUT_KEY_NONE; -} - -void -sdlkeyboard_init(void) -{ - keysyms_map_t *ptr3; - - unicode_keysyms_hash = g_hash_table_new( g_int_hash, g_int_equal ); - - for( ptr3 = (keysyms_map_t *)unicode_keysyms_map; ptr3->ui; ptr3++ ) - g_hash_table_insert( unicode_keysyms_hash, &( ptr3->ui ), - &( ptr3->fuse ) ); - - SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); -} - -void -sdlkeyboard_end(void) -{ - g_hash_table_destroy( unicode_keysyms_hash ); -} - -void -sdlkeyboard_keypress( SDL_KeyboardEvent *keyevent ) -{ - input_key fuse_keysym, unicode_keysym; - input_event_t fuse_event; - - fuse_keysym = keysyms_remap( keyevent->keysym.sym ); - - /* Currently unicode_keysyms_map contains ASCII character keys */ - if( ( keyevent->keysym.unicode & 0xFF80 ) == 0 ) - unicode_keysym = unicode_keysyms_remap( keyevent->keysym.unicode ); - else - unicode_keysym = INPUT_KEY_NONE; - - if( fuse_keysym == INPUT_KEY_NONE && unicode_keysym == INPUT_KEY_NONE ) - return; - - fuse_event.type = INPUT_EVENT_KEYPRESS; - if( unicode_keysym == INPUT_KEY_NONE ) - fuse_event.types.key.native_key = fuse_keysym; - else - fuse_event.types.key.native_key = unicode_keysym; - fuse_event.types.key.spectrum_key = fuse_keysym; - - input_event( &fuse_event ); -} - -void -sdlkeyboard_keyrelease( SDL_KeyboardEvent *keyevent ) -{ - input_key fuse_keysym; - input_event_t fuse_event; - - fuse_keysym = keysyms_remap( keyevent->keysym.sym ); - - if( fuse_keysym == INPUT_KEY_NONE ) return; - - fuse_event.type = INPUT_EVENT_KEYRELEASE; - /* SDL doesn't provide key release information for UNICODE, assuming that - the values will just be used for dialog boxes et. al. so put in SDL keysym - equivalent and hope for the best */ - fuse_event.types.key.native_key = fuse_keysym; - fuse_event.types.key.spectrum_key = fuse_keysym; - - input_event( &fuse_event ); -} diff --git a/fuse/ui/sdl/sdlkeyboard.h b/fuse/ui/sdl/sdlkeyboard.h deleted file mode 100644 index 2f46475..0000000 --- a/fuse/ui/sdl/sdlkeyboard.h +++ /dev/null @@ -1,33 +0,0 @@ -/* sdlkeyboard.h: routines for dealing with the SDL keyboard - Copyright (c) 2000-2002 Philip Kendall, Matan Ziv-Av, Fredrick Meunier - Copyright (c) 2005 Fredrick Meunier - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#ifndef FUSE_SDLKEYBOARD_H -#define FUSE_SDLKEYBOARD_H - -void sdlkeyboard_init(void); -void sdlkeyboard_end(void); -void sdlkeyboard_keypress(SDL_KeyboardEvent *keyevent); -void sdlkeyboard_keyrelease(SDL_KeyboardEvent *keyevent); - -#endif /* #ifndef FUSE_SDLKEYBOARD_H */ diff --git a/fuse/ui/sdl/sdlui.c b/fuse/ui/sdl/sdlui.c deleted file mode 100644 index 090f44e..0000000 --- a/fuse/ui/sdl/sdlui.c +++ /dev/null @@ -1,201 +0,0 @@ -/* sdlui.c: Routines for dealing with the SDL user interface - Copyright (c) 2000-2002 Philip Kendall, Matan Ziv-Av, Fredrick Meunier - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include "display.h" -#include "fuse.h" -#include "ui/ui.h" -#include "ui/uidisplay.h" -#include "settings.h" -#include "sdldisplay.h" -#include "sdljoystick.h" -#include "sdlkeyboard.h" -#include "ui/scaler/scaler.h" -#include "menu.h" - -static void -atexit_proc( void ) -{ - SDL_ShowCursor( SDL_ENABLE ); - SDL_Quit(); -} - -int -ui_init( int *argc, char ***argv ) -{ - int error; - - if( ui_widget_init() ) return 1; - -/* Comment out to Work around a bug in OS X 10.1 related to OpenGL in windowed - mode */ - atexit(atexit_proc); - - error = SDL_Init( SDL_INIT_VIDEO ); - if ( error ) - return error; - -#ifndef __MORPHOS__ - SDL_EnableUNICODE( 1 ); -#endif /* #ifndef __MORPHOS__ */ - - sdlkeyboard_init(); - - ui_mouse_present = 1; - - return 0; -} - -int -ui_event( void ) -{ - SDL_Event event; - - while ( SDL_PollEvent( &event ) ) { - switch ( event.type ) { - case SDL_KEYDOWN: - sdlkeyboard_keypress( &(event.key) ); - break; - case SDL_KEYUP: - sdlkeyboard_keyrelease( &(event.key) ); - break; - - case SDL_MOUSEBUTTONDOWN: - ui_mouse_button( event.button.button, 1 ); - break; - case SDL_MOUSEBUTTONUP: - ui_mouse_button( event.button.button, 0 ); - break; - case SDL_MOUSEMOTION: - if( ui_mouse_grabbed ) { - ui_mouse_motion( event.motion.x - 128, event.motion.y - 128 ); - if( event.motion.x != 128 || event.motion.y != 128 ) - SDL_WarpMouse( 128, 128 ); - } - break; - -#if defined USE_JOYSTICK && !defined HAVE_JSW_H - - case SDL_JOYBUTTONDOWN: - sdljoystick_buttonpress( &(event.jbutton) ); - break; - case SDL_JOYBUTTONUP: - sdljoystick_buttonrelease( &(event.jbutton) ); - break; - case SDL_JOYAXISMOTION: - sdljoystick_axismove( &(event.jaxis) ); - break; - case SDL_JOYHATMOTION: - sdljoystick_hatmove( &(event.jhat) ); - break; - -#endif /* if defined USE_JOYSTICK && !defined HAVE_JSW_H */ - - case SDL_QUIT: - fuse_emulation_pause(); - menu_file_exit(0); - fuse_emulation_unpause(); - break; - case SDL_VIDEOEXPOSE: - display_refresh_all(); - break; - case SDL_ACTIVEEVENT: - if( event.active.state & SDL_APPINPUTFOCUS ) { - if( event.active.gain ) ui_mouse_resume(); else ui_mouse_suspend(); - } - break; - default: - break; - } - } - - return 0; -} - -int -ui_end( void ) -{ - int error; - - error = uidisplay_end(); - if ( error ) - return error; - - sdlkeyboard_end(); - - SDL_Quit(); - - ui_widget_end(); - - return 0; -} - -int -ui_statusbar_update_speed( float speed ) -{ - char buffer[15]; - const char fuse[] = "Fuse"; - - snprintf( buffer, 15, "%s - %3.0f%%", fuse, speed ); - - /* FIXME: Icon caption should be snapshot name? */ - SDL_WM_SetCaption( buffer, fuse ); - - return 0; -} - -int -ui_mouse_grab( int startup ) -{ - if( settings_current.full_screen ) { - SDL_WarpMouse( 128, 128 ); - return 1; - } - if( startup ) return 0; - - switch( SDL_WM_GrabInput( SDL_GRAB_ON ) ) { - case SDL_GRAB_ON: - case SDL_GRAB_FULLSCREEN: - SDL_ShowCursor( SDL_DISABLE ); - SDL_WarpMouse( 128, 128 ); - return 1; - default: - ui_error( UI_ERROR_WARNING, "Mouse grab failed" ); - return 0; - } -} - -int -ui_mouse_release( int suspend ) -{ - if( settings_current.full_screen ) return !suspend; - - SDL_WM_GrabInput( SDL_GRAB_OFF ); - SDL_ShowCursor( SDL_ENABLE ); - return 0; -} diff --git a/fuse/ui/svga/Makefile.am b/fuse/ui/svga/Makefile.am deleted file mode 100644 index cd037e1..0000000 --- a/fuse/ui/svga/Makefile.am +++ /dev/null @@ -1,47 +0,0 @@ -## Process this file with automake to produce Makefile.in -## Copyright (c) 2001-2004 Philip Kendall -## Copyright (c) 2015 Sergio Baldoví - -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -## -## Author contact information: -## -## E-mail: philip-fuse@shadowmagic.org.uk - -if UI_SVGA - -fuse_SOURCES += $(ui_svga_files) - -BUILT_SOURCES += $(ui_svga_built) - -endif - - -CLEANFILES += $(ui_svga_built) - -ui_svga_files = \ - ui/svga/keysyms.c \ - ui/svga/svgadisplay.c \ - ui/svga/svgadisplay.h \ - ui/svga/svgajoystick.c \ - ui/svga/svgakeyboard.c \ - ui/svga/svgakeyboard.h \ - ui/svga/svgaui.c - -ui_svga_built = ui/svga/keysyms.c - -ui/svga/keysyms.c: $(srcdir)/keysyms.pl $(srcdir)/keysyms.dat - @$(MKDIR_P) ui/svga - $(AM_V_GEN)$(PERL) -I$(srcdir)/perl $(srcdir)/keysyms.pl svga $(srcdir)/keysyms.dat > $@.tmp && mv $@.tmp $@ diff --git a/fuse/ui/svga/svgadisplay.c b/fuse/ui/svga/svgadisplay.c deleted file mode 100644 index ae5db2d..0000000 --- a/fuse/ui/svga/svgadisplay.c +++ /dev/null @@ -1,822 +0,0 @@ -/* svgadisplay.c: Routines for dealing with the svgalib display - Copyright (c) 2000-2003 Philip Kendall, Matan Ziv-Av, Witold Filipczyk, - Russell Marks - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include -#include -#include - -#include "fuse.h" -#include "display.h" -#include "screenshot.h" -#include "settings.h" -#include "ui/ui.h" -#include "ui/uidisplay.h" - -/* The size of a 1x1 image in units of - DISPLAY_ASPECT WIDTH x DISPLAY_SCREEN_HEIGHT - scale * 4, so 2 => 0.5, 6 => 1.5, 4 => 1.0 */ -static int image_scale = 1; - -/* The height and width of a 1x1 image in pixels */ -static int image_width, image_height, scaled_image_w, scaled_image_h; - -/* A copy of every pixel on the screen */ -static libspectrum_word - rgb_image[2 * ( DISPLAY_SCREEN_HEIGHT + 4 )][2 * ( DISPLAY_SCREEN_WIDTH + 3 )]; -static const int rgb_pitch = 2 * ( DISPLAY_SCREEN_WIDTH + 3 ); - -/* A scaled copy of the image displayed on the Spectrum's screen */ -static libspectrum_word - scaled_image[3*DISPLAY_SCREEN_HEIGHT][3*DISPLAY_SCREEN_WIDTH]; -static const ptrdiff_t scaled_pitch = - 3 * DISPLAY_SCREEN_WIDTH * sizeof( libspectrum_word ); - -/* The line buffer for svga_putpixel ...*/ -static libspectrum_byte - line_buff[3*4*DISPLAY_SCREEN_WIDTH]; -static libspectrum_byte *line_buff_ptr; -static int bytesperpixel = 0; -static int xoffs, yoffs, xclip, yclip; - -static int svgadisplay_current_size = 0; -static int svgadisplay_depth = -1; -static int svgadisplay_bw = -1; -static int rShift = 16, gShift = 8, bShift = 0; - -/* This is a rule of thumb for the maximum number of rects that can be updated - each frame. If more are generated we just update the whole screen */ -typedef struct { - int x; int y; int w; int h; -} SVGA_Rect; -#define MAX_UPDATE_RECT 300 -static SVGA_Rect updated_rects[MAX_UPDATE_RECT]; -static int num_rects = 0; -static libspectrum_byte svgadisplay_force_full_refresh = 1; - -typedef void svgadisplay_update_rect_t( int x, int y, int w, int h ); - -static svgadisplay_update_rect_t *svgadisplay_update_rect; -static svgadisplay_update_rect_t svgadisplay_update_rect_noscale; -static svgadisplay_update_rect_t svgadisplay_update_rect_scale; - -typedef void svgadisplay_putpixel_t( int x, int y, libspectrum_word *color ); - -static svgadisplay_putpixel_t *svgadisplay_putpixel; - -static svgadisplay_putpixel_t svgadisplay_putpixel_4; -static svgadisplay_putpixel_t svgadisplay_putpixel_8; -static svgadisplay_putpixel_t svgadisplay_putpixel_15; -static svgadisplay_putpixel_t svgadisplay_putpixel_16; -static svgadisplay_putpixel_t svgadisplay_putpixel_24; - -static int svgadisplay_allocate_colours4( void ); -static int svgadisplay_allocate_colours8( void ); - - -static libspectrum_word pal_colour[16] = { - 0x0000, 0x0017, 0xb800, 0xb817, 0x05e0, 0x05f7, 0xbde0, 0xbdf7, - 0x0000, 0x001f, 0xf800, 0xf81f, 0x07e0, 0x07ff, 0xffe0, 0xffff, -}; - -static libspectrum_word pal_grey[16] = { - 0x0000, 0x39c7, 0x18a3, 0x526a, 0x738e, 0xad55, 0x8430, 0xbdf7, - 0x0000, 0x4a69, 0x20e4, 0x6b4d, 0x94b2, 0xdf1b, 0xb596, 0xffff, -}; - -static int rgb_for_4[] = { - 0x00, 0x00, 0x00, - 0x00, 0x00, 0xBF, - 0xBF, 0x00, 0x00, - 0xBF, 0x00, 0xBF, - 0x00, 0xBF, 0x00, - 0x00, 0xBF, 0xBF, - 0xBF, 0xBF, 0x00, - 0xBF, 0xBF, 0xBF, - 0x00, 0x00, 0x00, - 0x00, 0x00, 0xFF, - 0xFF, 0x00, 0x00, - 0xFF, 0x00, 0xFF, - 0x00, 0xFF, 0x00, - 0x00, 0xFF, 0xFF, - 0xFF, 0xFF, 0x00, - 0xFF, 0xFF, 0xFF -}; - -static void register_scalers( void ); - -typedef struct svga_mode_t { - int n; - /* vga_modeinfo *inf; */ - int width, height, bytesperpixel, colors; - int depth; -} svga_mode_t; - -#define SIZE_1x_REGISTER(p,s) if( modes[0].n != -1 && ( p || modes[0].depth > 4 ) ) scaler_register( s ) -#define SIZE_2x_REGISTER(p,s) if( modes[1].n != -1 && ( p || modes[1].depth > 4 ) ) scaler_register( s ) -#define SIZE_3x_REGISTER(p,s) if( modes[2].n != -1 && ( p || modes[2].depth > 4 ) ) scaler_register( s ) - -svga_mode_t modes[] = { - { -1, 0, 0, 0, 0, 0, }, /* 320x240 */ - { -1, 0, 0, 0, 0, 0, }, /* 640x480 */ - { -1, 0, 0, 0, 0, 0, }, /* 960x720 */ -}; - -void -set_mode( int i, int n, vga_modeinfo *inf ) -{ - if( inf->colors >= 16 && !( inf->flags & IS_MODEX ) && - inf->width >= 256 * ( i + 1 ) && - inf->height >= 192 * ( i + 1 ) ) { - modes[i].n = n; - modes[i].width = inf->width; - modes[i].height = inf->height; - modes[i].colors = inf->colors; - modes[i].bytesperpixel = inf->bytesperpixel ? inf->bytesperpixel : 1; - modes[i].depth = inf->colors == 16 ? 4 : - ( inf->colors == 256 ? 8 : - ( inf->colors == 32768 ? 15 : - ( inf->colors == 65536 ? 16 : - inf->bytesperpixel == 3 ? 24 : 32 ) ) ); - } -} - -void -find_mode( int exact ) -{ - vga_modeinfo *inf; - int i, j, w, h; - - for( i = 0; i <= vga_lastmodenumber(); i++ ) { - if( vga_hasmode( i ) ) { - inf = vga_getmodeinfo( i ); - if( inf->colors >= 16 && !( inf->flags & IS_MODEX ) && - inf->width >= 320 && inf->height >= 240 && - inf->width <= 1280 && inf->height <= 1024 ) { - /* try exact match */ - for( j = 0; j < 3; j++ ) { - w = DISPLAY_ASPECT_WIDTH * ( j + 1 ); - h = DISPLAY_SCREEN_HEIGHT * ( j + 1 ); - if( exact == 0 && inf->width == w && inf->height == h && - ( modes[j].n == -1 || - ( ( modes[j].width != w || modes[j].height != h || - modes[j].depth != 16 ) && ( - inf->colors == 65536 || - inf->colors > modes[j].colors ) ) ) ) { - set_mode( j, i, inf ); - } - - if( exact == 1 && inf->width >= w && inf->height >= h && - inf->width < w * 5 / 4 && inf->height < h * 5 / 4 && - ( modes[j].n == -1 || - ( ( modes[j].width > inf->width || - modes[j].height > inf->height || - modes[j].depth != 16 ) && ( - inf->colors == 65536 || - inf->colors > modes[j].colors ) ) ) ) { - set_mode( j, i, inf ); - } - - if( exact == -1 && inf->width <= w && inf->height <= h && - inf->width > w * 3 / 4 && inf->height > h * 3 / 4 && - ( modes[j].n == -1 || - ( ( modes[j].width < inf->width || - modes[j].height < inf->height || - modes[j].depth != 16 ) && ( - inf->colors == 65536 || - inf->colors > modes[j].colors ) ) ) ) { - set_mode( j, i, inf ); - } - } - } - } - } -} - -static void -svgadisplay_setmode( int i ) -{ - int w, h; - w = DISPLAY_ASPECT_WIDTH * ( i + 1 ); - h = DISPLAY_SCREEN_HEIGHT * ( i + 1 ); - vga_setmode( modes[i].n ); - svgadisplay_depth = modes[i].depth; - bytesperpixel = modes[i].bytesperpixel; - xoffs = xclip = 0; - if( modes[i].width > w ) { - xoffs = ( modes[i].width - w ) >> 1; - } else if( modes[i].width < w ) { - xclip = ( w - modes[i].width ) >> 1; - } - yoffs = yclip = 0; - if( modes[i].height > h ) { - yoffs = ( modes[i].height - h ) >> 1; - } else if( modes[i].height < h ) { - yclip = ( h - modes[i].height ) >> 1; - } - if( svgadisplay_depth == 4 ) - svgadisplay_allocate_colours4(); - if( svgadisplay_depth == 8 ) - svgadisplay_allocate_colours8(); -} - -int -svgadisplay_init( void ) -{ - int i, j, found_mode = 0; - int n0 = -1, n1 = -1, n2 = -1; - vga_modeinfo *inf; - vga_init(); - - if( settings_current.svga_modes && - strcmp( settings_current.svga_modes, "list" ) == 0 ) { - fprintf( stderr, - "=====================================================================\n" - " List of available SVGA modes:\n" - "---------------------------------------------------------------------\n" - " No. width height colors Normal Double Triple\n" - "---------------------------------------------------------------------\n" - ); - for( j = 0; j <= vga_lastmodenumber(); j++ ) { - if( vga_hasmode( j ) ) { - inf = vga_getmodeinfo( j ); - if( inf->colors >= 16 && !( inf->flags & IS_MODEX ) && - inf->width >= 256 && - inf->height >= 192 ) { - fprintf( stderr, "% 4d % 5d% 5d %s % 4d%%% 4d%%", j, inf->width, inf->height, - ( inf->colors == 16 ? " 16 " : - ( inf->colors == 256 ? "256 " : - ( inf->colors == 32768 ? " 32k" : - ( inf->colors == 65536 ? " 64k" : " 16M" ) ) ) ), - inf->width * 100 / DISPLAY_ASPECT_WIDTH, - inf->height * 100 / DISPLAY_SCREEN_HEIGHT ); - if( inf->width >= 512 && inf->height >= 384 ) { - fprintf( stderr, " % 4d%%% 4d%%", - inf->width * 50 / DISPLAY_ASPECT_WIDTH, - inf->height * 50 / DISPLAY_SCREEN_HEIGHT ); - } else { - fprintf( stderr, " N/A " ); - } - if( inf->width >= 768 && inf->height >= 576 ) { - fprintf( stderr, " % 4d%%% 4d%%\n", - inf->width * 100 / DISPLAY_ASPECT_WIDTH / 3, - inf->height * 100 / DISPLAY_SCREEN_HEIGHT / 3 ); - } else { - fprintf( stderr, " N/A\n" ); - } - } - } - } - return 1; - } - - find_mode( 0 ); - find_mode( 1 ); - find_mode( -1 ); - - - if( settings_current.svga_modes ) { - sscanf( settings_current.svga_modes, " %i%*[ ,;/|] %i%*[ ,;/|] %i", &n0, &n1, &n2 ); - if( n0 > 0 && vga_hasmode( n0 ) ) set_mode( 0, n0, vga_getmodeinfo( n0 ) ); - if( n1 > 0 && vga_hasmode( n1 ) ) set_mode( 1, n1, vga_getmodeinfo( n1 ) ); - if( n2 > 0 && vga_hasmode( n2 ) ) set_mode( 2, n2, vga_getmodeinfo( n2 ) ); - } - -#if 0 /* for debugging */ - for( i = 0; i < 3; i++ ) { - fprintf( stderr, "svgadisplay_size: %d:", i ); - if( modes[i].n != -1 ) { - fprintf( stderr, " %d %dx%d %s (%d)", modes[i].n, modes[i].width, modes[i].height, - vga_getmodename( modes[i].n ), modes[i].depth ); - } - fprintf( stderr, "\n" ); - } -#endif - - for( i = 0; i < 3; i++ ) { - if( modes[i].n != -1 ) { - svgadisplay_current_size = i + 1; - svgadisplay_setmode( i ); - found_mode = 1; - break; - } - } - - /* Error out if we couldn't find a VGA mode */ - if( !found_mode ) { - ui_error( UI_ERROR_ERROR, "couldn't find a mode to start in" ); - return 1; - } - - return 0; -} - -static void -svgadisplay_putpixel_4( int x, int y, libspectrum_word *colour) -{ - *line_buff_ptr++ = *colour; -} - -static void -svgadisplay_putpixel_8( int x, int y, libspectrum_word *colour) -{ - libspectrum_word c = *colour; - - c = ( c & 0x1f ) * 3 / 31 + - ( ( ( ( c >> 5 ) & 0x3f ) * 7 / 63 ) << 2 ) + - ( ( ( c >> 11 ) * 3 / 31 ) << 5 ); - *line_buff_ptr++ = c; -} - -static void -svgadisplay_putpixel_15( int x, int y, libspectrum_word *colour ) -{ - libspectrum_word c = *colour; - - *(libspectrum_word *)line_buff_ptr = - ( c & 0x1f ) + ( ( c >> 1 ) & 0xffe0 ); - line_buff_ptr += 2; -} - -static void -svgadisplay_putpixel_16( int x, int y, libspectrum_word *colour ) -{ - libspectrum_word c = *colour; - - *(libspectrum_word *)line_buff_ptr = c; - line_buff_ptr += 2; -} - -static void -svgadisplay_putpixel_24( int x, int y, libspectrum_word *colour ) -{ - libspectrum_dword c = *colour; - - c = ( ( ( c >> 11 ) * 255 / 31 ) << rShift ) + - ( ( ( ( c >> 5 ) & 0x3f ) * 255 / 63 ) << gShift ) + - ( ( ( c & 0x1f ) * 255 / 31 ) << bShift ); - *(libspectrum_dword *)line_buff_ptr = c; - line_buff_ptr += 3; -} - -static void -svgadisplay_putpixel_32( int x, int y, libspectrum_word *colour ) -{ - libspectrum_dword c = *colour; - - c = ( ( ( c >> 11 ) * 255 / 31 ) << rShift ) + - ( ( ( ( c >> 5 ) & 0x3f ) * 255 / 63 ) << gShift ) + - ( ( ( c & 0x1f ) * 255 / 31 ) << bShift ); - *(libspectrum_dword *)line_buff_ptr = c; - line_buff_ptr += 4; -} - -static int -svgadisplay_allocate_colours4( void ) -{ - int i; - int red, green, blue; - -/* Y = 0.29900 * R + 0.58700 * G + 0.11400 * B */ - - if( settings_current.bw_tv ) { - for( i=0; i<16; i++ ) { /* grey */ - red = green = blue = ( - rgb_for_4[i * 3 ] * 4822 / 255 + - rgb_for_4[i * 3 + 1] * 9467 / 255 + - rgb_for_4[i * 3 + 2] * 1839 / 255 ) >> 8; - vga_setpalette( i, red, green, blue ); - } - } else { - for( i=0; i<16; i++ ) { /* rgb */ - red = rgb_for_4[i * 3 ] * 63 / 255; - green = rgb_for_4[i * 3 + 1] * 63 / 255; - blue = rgb_for_4[i * 3 + 2] * 63 / 255; - vga_setpalette( i, red, green, blue ); - } - } - - return 0; -} - -static int -svgadisplay_allocate_colours8( void ) -{ - int i, r, g, b; - int red, green, blue; - - i = 0; - for( r=0; r<4; r++ ) /* rgb232 => 128 */ - for( g=0; g<8; g++ ) - for( b=0; b<4; b++ ) { - if( settings_current.bw_tv ) { - red = green = blue = ( - r * 4822 / 3 + - g * 9467 / 7 + - b * 1839 / 3 ) >> 8; - } else { - red = r * 63 / 3; - green = g * 63 / 7; - blue = b * 63 / 3; - } - vga_setpalette( i, red, green, blue ); - i++; - } - - return 0; -} - - -int -uidisplay_init( int width, int height ) -{ - image_width = width; - image_height = height; - if( !scaler_is_supported( current_scaler ) ) { - if( machine_current->timex ) - scaler_select_scaler( SCALER_HALFSKIP ); - else - scaler_select_scaler( SCALER_NORMAL ); - } - register_scalers(); - display_ui_initialised = 1; - - display_refresh_all(); - - return 0; -} - -static void -register_scalers( void ) -{ - int f = -1; - - scaler_register_clear(); - scaler_select_bitformat( 565 ); /* 16bit always */ - - if( machine_current->timex ) { - SIZE_1x_REGISTER( 0, SCALER_HALF ); - SIZE_1x_REGISTER( 1, SCALER_HALFSKIP ); - SIZE_2x_REGISTER( 1, SCALER_NORMAL ); - SIZE_2x_REGISTER( 0, SCALER_PALTV ); - SIZE_3x_REGISTER( 0, SCALER_TIMEXTV ); - SIZE_3x_REGISTER( 1, SCALER_TIMEX1_5X ); - } else { - SIZE_1x_REGISTER( 1, SCALER_NORMAL ); - SIZE_1x_REGISTER( 0, SCALER_PALTV ); - - SIZE_2x_REGISTER( 1, SCALER_DOUBLESIZE ); - SIZE_2x_REGISTER( 0, SCALER_2XSAI ); - SIZE_2x_REGISTER( 0, SCALER_SUPER2XSAI ); - SIZE_2x_REGISTER( 0, SCALER_SUPEREAGLE ); - SIZE_2x_REGISTER( 1, SCALER_ADVMAME2X ); - SIZE_2x_REGISTER( 0, SCALER_TV2X ); - SIZE_2x_REGISTER( 0, SCALER_DOTMATRIX ); - SIZE_2x_REGISTER( 0, SCALER_PALTV2X ); - SIZE_2x_REGISTER( 0, SCALER_HQ2X ); - - SIZE_3x_REGISTER( 1, SCALER_TRIPLESIZE ); - SIZE_3x_REGISTER( 1, SCALER_ADVMAME3X ); - SIZE_3x_REGISTER( 0, SCALER_TV3X ); - SIZE_3x_REGISTER( 0, SCALER_PALTV3X ); - SIZE_3x_REGISTER( 0, SCALER_HQ3X ); - } - if( current_scaler != SCALER_NUM ) - f = 4.0 * scaler_get_scaling_factor( current_scaler ) * - ( machine_current->timex ? 2 : 1 ); - if( scaler_is_supported( current_scaler ) && - ( svgadisplay_current_size * 4 == f ) ) { - uidisplay_hotswap_gfx_mode(); - } else { - switch( svgadisplay_current_size ) { - case 1: - scaler_select_scaler( machine_current->timex ? SCALER_HALF : SCALER_NORMAL ); - break; - case 2: - scaler_select_scaler( machine_current->timex ? SCALER_NORMAL : SCALER_DOUBLESIZE ); - break; - case 3: - scaler_select_scaler( machine_current->timex ? SCALER_TIMEX1_5X : SCALER_TRIPLESIZE ); - break; - } - } -} - -static void -svgadisplay_setup_rgb_putpixel( void ) -{ - switch( svgadisplay_depth ) { - case 4: - svgadisplay_putpixel = svgadisplay_putpixel_4; - break; - case 8: - svgadisplay_putpixel = svgadisplay_putpixel_8; - break; - case 15: - svgadisplay_putpixel = svgadisplay_putpixel_15; - break; - case 16: - svgadisplay_putpixel = svgadisplay_putpixel_16; - break; - case 24: - svgadisplay_putpixel = svgadisplay_putpixel_24; - break; - case 32: - svgadisplay_putpixel = svgadisplay_putpixel_32; - break; - } -/* resize_window( scaled_image_w, scaled_image_h ); */ -} - -int -uidisplay_hotswap_gfx_mode( void ) -{ - image_scale = 4.0 * scaler_get_scaling_factor( current_scaler ); - scaled_image_w = image_width * image_scale >> 2; - scaled_image_h = image_height * image_scale >> 2; - - if( svgadisplay_current_size * 4 != - image_scale * ( machine_current->timex ? 2 : 1 ) ) { - svgadisplay_current_size = ( image_scale * ( machine_current->timex ? 2 : 1 ) ) >> 2; - svgadisplay_setmode( svgadisplay_current_size - 1 ); - } - - if( current_scaler == SCALER_NORMAL ) - svgadisplay_update_rect = svgadisplay_update_rect_noscale; - else - svgadisplay_update_rect = svgadisplay_update_rect_scale; - - svgadisplay_force_full_refresh = 1; - - svgadisplay_setup_rgb_putpixel(); - - if( settings_current.bw_tv != svgadisplay_bw ) { - svgadisplay_bw = settings_current.bw_tv; - if( svgadisplay_depth == 4 ) - svgadisplay_allocate_colours4(); - else if( svgadisplay_depth == 8 ) - svgadisplay_allocate_colours8(); - } - display_refresh_all(); - return 0; -} - -static void -svgadisplay_update_rect_noscale( int x, int y, int w, int h ) -{ - int yy, xx; - - if( xclip || yclip ) { - if( x < xclip ) w -= xclip - x, x = xclip; - if( y < yclip ) h -= yclip - y, y = yclip; - if( x + w > scaled_image_w - xclip ) w = scaled_image_w - xclip - x; - if( y + h > scaled_image_h - yclip ) h = scaled_image_h - yclip - y; - } - /* Call putpixel multiple times */ - for( yy = y; yy < y + h; yy++ ) { - line_buff_ptr = line_buff; - for( xx = x; xx < x + w; xx++ ) - svgadisplay_putpixel( xx, yy, &rgb_image[yy + 2][xx + 1] ); - if( w > 0 ) - vga_drawscansegment( line_buff, x + xoffs - xclip, yy + yoffs - yclip, w * bytesperpixel ); - } -} - -static void -svgadisplay_update_rect_scale( int x, int y, int w, int h ) -{ - int yy = y, xx = x; - - y = y * image_scale >> 2; - x = x * image_scale >> 2; - scaler_proc16( - (libspectrum_byte *)&(rgb_image[yy + 2][xx + 1]), - rgb_pitch * sizeof(rgb_image[0][0]), - (libspectrum_byte *)&(scaled_image[y][x]), - scaled_pitch, - w, h - ); - - w = w * image_scale >> 2; - h = h * image_scale >> 2; - - if( xclip || yclip ) { - if( x < xclip ) w -= xclip - x, x = xclip; - if( y < yclip ) h -= yclip - y, y = yclip; - if( x + w > scaled_image_w - xclip ) w = scaled_image_w - xclip - x; - if( y + h > scaled_image_h - yclip ) h = scaled_image_h - yclip - y; - } - /* Call putpixel multiple times */ - for( yy = y; yy < y + h; yy++ ) { - line_buff_ptr = line_buff; - for( xx = x; xx < x + w; xx++ ) - svgadisplay_putpixel( xx, yy, &scaled_image[yy][xx] ); - if( w > 0 ) - vga_drawscansegment( line_buff, x + xoffs - xclip, yy + yoffs - yclip, w * bytesperpixel ); - } -} - -void -uidisplay_frame_end( void ) -{ - SVGA_Rect *r, *last_rect; - - /* Force a full redraw if requested */ - if ( svgadisplay_force_full_refresh ) { - num_rects = 1; - - updated_rects[0].x = 0; - updated_rects[0].y = 0; - updated_rects[0].w = image_width; - updated_rects[0].h = image_height; - } - - if ( !( ui_widget_level >= 0 ) && num_rects == 0 ) return; - - last_rect = updated_rects + num_rects; - - for( r = updated_rects; r != last_rect; r++ ) - svgadisplay_update_rect( r->x, r->y, r->w, r->h ); - num_rects = 0; - svgadisplay_force_full_refresh = 0; -} - -void -uidisplay_area( int x, int y, int w, int h ) -{ - if ( svgadisplay_force_full_refresh ) - return; - - if( num_rects == MAX_UPDATE_RECT ) { - svgadisplay_force_full_refresh = 1; - return; - } - - /* Extend the dirty region by 1 pixel for scalers - that "smear" the screen, e.g. 2xSAI */ - if( scaler_flags & SCALER_FLAGS_EXPAND ) - scaler_expander( &x, &y, &w, &h, image_width, image_height ); - - updated_rects[num_rects].x = x; - updated_rects[num_rects].y = y; - updated_rects[num_rects].w = w; - updated_rects[num_rects].h = h; - num_rects++; -} - -int -uidisplay_end( void ) -{ - display_ui_initialised = 0; - return 0; -} - -/* Set one pixel in the display */ -void -uidisplay_putpixel( int x, int y, int colour ) -{ - libspectrum_word pc = svgadisplay_depth == 4 ? colour : - ( settings_current.bw_tv ? pal_grey[ colour ] : - pal_colour[ colour ] ); - - if( machine_current->timex ) { - x <<= 1; y <<= 1; - rgb_image[y + 2][x + 1] = pc; - rgb_image[y + 2][x + 2] = pc; - rgb_image[y + 3][x + 1] = pc; - rgb_image[y + 3][x + 2] = pc; - } else { - rgb_image[y + 2][x + 1] = pc; - } -} - -/* Print the 8 pixels in `data' using ink colour `ink' and paper - colour `paper' to the screen at ( (8*x) , y ) */ -void -uidisplay_plot8( int x, int y, libspectrum_byte data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - libspectrum_word *dest; - libspectrum_word pi = svgadisplay_depth == 4 ? ink : - ( settings_current.bw_tv ? pal_grey[ ink ] : - pal_colour[ ink ] ); - libspectrum_word pp = svgadisplay_depth == 4 ? paper : - ( settings_current.bw_tv ? pal_grey[ paper ] : - pal_colour[ paper ] ); - - if( machine_current->timex ) { - - x <<= 4; y <<= 1; - - dest = &(rgb_image[y + 2][x + 1]); - - *(dest + rgb_pitch) = *dest = ( data & 0x80 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x80 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x40 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x40 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x20 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x20 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x10 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x10 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x08 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x08 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x04 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x04 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x02 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x02 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x01 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x01 ) ? pi : pp; - } else { - x <<= 3; - - dest = &(rgb_image[y + 2][x + 1]); - - *(dest++) = ( data & 0x80 ) ? pi : pp; - *(dest++) = ( data & 0x40 ) ? pi : pp; - *(dest++) = ( data & 0x20 ) ? pi : pp; - *(dest++) = ( data & 0x10 ) ? pi : pp; - *(dest++) = ( data & 0x08 ) ? pi : pp; - *(dest++) = ( data & 0x04 ) ? pi : pp; - *(dest++) = ( data & 0x02 ) ? pi : pp; - *dest = ( data & 0x01 ) ? pi : pp; - } -} - -/* Print the 16 pixels in `data' using ink colour `ink' and paper - colour `paper' to the screen at ( (16*x) , y ) */ -void -uidisplay_plot16( int x, int y, libspectrum_word data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - libspectrum_word *dest; - libspectrum_word pi = svgadisplay_depth == 4 ? ink : - ( settings_current.bw_tv ? pal_grey[ ink ] : - pal_colour[ ink ] ); - libspectrum_word pp = svgadisplay_depth == 4 ? paper : - ( settings_current.bw_tv ? pal_grey[ paper ] : - pal_colour[ paper ] ); - x <<= 4; y <<= 1; - - dest = &(rgb_image[y + 2][x + 1]); - *(dest + rgb_pitch) = *dest = ( data & 0x8000 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x4000 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x2000 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x1000 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0800 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0400 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0200 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0100 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0080 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0040 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0020 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0010 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0008 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0004 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0002 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0001 ) ? pi : pp; -} - -int svgadisplay_end( void ) -{ - vga_setmode( TEXT ); - return 0; -} - -void -uidisplay_frame_save( void ) -{ - /* FIXME: Save current framebuffer state as the widget UI wants to scribble - in here */ -} - -void -uidisplay_frame_restore( void ) -{ - /* FIXME: Restore saved framebuffer state as the widget UI wants to draw a - new menu */ -} diff --git a/fuse/ui/svga/svgadisplay.h b/fuse/ui/svga/svgadisplay.h deleted file mode 100644 index 7293ae4..0000000 --- a/fuse/ui/svga/svgadisplay.h +++ /dev/null @@ -1,30 +0,0 @@ -/* svgadisplay.h: Routines for dealing with the svgalib display - Copyright (c) 2003 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#ifndef FUSE_SVGADISPLAY_H -#define FUSE_SVGADISPLAY_H - -int svgadisplay_init( void ); -int svgadisplay_end( void ); - -#endif /* #ifndef FUSE_SVGADISPLAY_H */ diff --git a/fuse/ui/svga/svgajoystick.c b/fuse/ui/svga/svgajoystick.c deleted file mode 100644 index 030210d..0000000 --- a/fuse/ui/svga/svgajoystick.c +++ /dev/null @@ -1,159 +0,0 @@ -/* svgajoystick.c: Joystick emulation (using svgalib) - Copyright (c) 2003-4 Darren Salt - Copyright (c) 2015 UB880D - Copyright (c) 2015 Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - - Darren: linux@youmustbejoking.demon.co.uk - -*/ - -#include -#include "peripherals/joystick.h" - -#if !defined USE_JOYSTICK || defined HAVE_JSW_H - -/* Fake joystick, or override UI-specific handling */ -#include "../uijoystick.c" - -#else /* #if !defined USE_JOYSTICK || defined HAVE_JSW_H */ - -/* Use the svgalib joystick support */ - -#include -#include - -#include -#include - -#include "fuse.h" -#include "keyboard.h" -#include "settings.h" -#include "spectrum.h" -#include "machine.h" -#include "ui/ui.h" -#include "ui/uijoystick.h" - -static int sticks = 0; -static int buttons[2]; - -static void joy_handler( int ev, int number, char value, int which ); - -static int -init_stick( int which ) -{ - if( !joystick_init( which, JOY_CALIB_STDOUT ) ) { - ui_error( UI_ERROR_ERROR, "failed to initialise joystick %i: %s", - which + 1, errno ? strerror (errno) : "not configured?" ); - return 1; - } - - if( joystick_getnumaxes( which ) < 2 || - joystick_getnumbuttons( which ) < 1 ) { - joystick_close( which ); - ui_error( UI_ERROR_ERROR, "sorry, joystick %i is inadequate!", which + 1 ); - return 1; - } - - buttons[which] = joystick_getnumbuttons( which ); - if( buttons[which] > NUM_JOY_BUTTONS ) buttons[which] = NUM_JOY_BUTTONS; - - return 0; -} - -int -ui_joystick_init( void ) -{ - int i; - - /* If we can't init the first, don't try the second */ - if( init_stick( 0 ) ) { - sticks = 0; - } else if( init_stick( 1 ) ) { - sticks = 1; - } else { - sticks = 2; - } - - for( i = 0; i < sticks; i++ ) { - joystick_sethandler( i, joy_handler ); - } - - return sticks; -} - -void -ui_joystick_end( void ) -{ - joystick_close( -1 ); -} - -static void -do_axis( int which, int position, input_key negative, input_key positive ) -{ - input_event_t event1, event2; - - event1.types.joystick.which = event2.types.joystick.which = which; - - event1.types.joystick.button = positive; - event2.types.joystick.button = negative; - - event1.type = position > 0 ? INPUT_EVENT_JOYSTICK_PRESS : - INPUT_EVENT_JOYSTICK_RELEASE; - event2.type = position < 0 ? INPUT_EVENT_JOYSTICK_PRESS : - INPUT_EVENT_JOYSTICK_RELEASE; - - input_event( &event1 ); - input_event( &event2 ); -} - -static void -joy_handler( int ev, int number, char value, int which ) -{ - input_event_t event; - - switch ( ev ) { - case JOY_EVENTAXIS: - if( number == 0 ) - do_axis( which, value, INPUT_JOYSTICK_LEFT, INPUT_JOYSTICK_RIGHT ); - else if( number == 1 ) - do_axis( which, value, INPUT_JOYSTICK_UP, INPUT_JOYSTICK_DOWN ); - break; - case JOY_EVENTBUTTONDOWN: - case JOY_EVENTBUTTONUP: - if( number >= buttons[which] ) return; - event.types.joystick.which = which; - event.types.joystick.button = INPUT_JOYSTICK_FIRE_1 + number; - event.type = ( ev == JOY_EVENTBUTTONDOWN ) - ? INPUT_EVENT_JOYSTICK_PRESS - : INPUT_EVENT_JOYSTICK_RELEASE; - input_event( &event ); - break; - default: - break; - } -} - -void -ui_joystick_poll( void ) -{ -} - -#endif /* #if !defined USE_JOYSTICK || defined HAVE_JSW_H */ diff --git a/fuse/ui/svga/svgakeyboard.c b/fuse/ui/svga/svgakeyboard.c deleted file mode 100644 index a7c694b..0000000 --- a/fuse/ui/svga/svgakeyboard.c +++ /dev/null @@ -1,99 +0,0 @@ -/* svgakeyboard.c: svgalib routines for dealing with the keyboard - Copyright (c) 2000-2004 Philip Kendall, Matan Ziv-Av - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include - -#include -#include - -#include "display.h" -#include "fuse.h" -#include "keyboard.h" -#include "machine.h" -#include "settings.h" -#include "snapshot.h" -#include "spectrum.h" -#include "tape.h" -#include "ui/ui.h" -#include "utils.h" - -static void svgakeyboard_keystroke(int scancode, int press); -static int svgakeyboard_keypress( int keysym ); -static int svgakeyboard_keyrelease( int keysym ); - -int svgakeyboard_init(void) -{ - keyboard_init(); - keyboard_seteventhandler(svgakeyboard_keystroke); - return 0; -} - -static void svgakeyboard_keystroke(int scancode, int press) { - if(press) { - svgakeyboard_keypress(scancode); - } else { - svgakeyboard_keyrelease(scancode); - } -} - -static int -svgakeyboard_keypress( int keysym ) -{ - input_key fuse_keysym; - input_event_t fuse_event; - - fuse_keysym = keysyms_remap( keysym ); - - if( fuse_keysym == INPUT_KEY_NONE ) return 0; - - fuse_event.type = INPUT_EVENT_KEYPRESS; - fuse_event.types.key.native_key = fuse_keysym; - fuse_event.types.key.spectrum_key = fuse_keysym; - - return input_event( &fuse_event ); -} - -static int -svgakeyboard_keyrelease( int keysym ) -{ - input_key fuse_keysym; - input_event_t fuse_event; - - fuse_keysym = keysyms_remap( keysym ); - - if( fuse_keysym == INPUT_KEY_NONE ) return 0; - - fuse_event.type = INPUT_EVENT_KEYRELEASE; - fuse_event.types.key.native_key = fuse_keysym; - fuse_event.types.key.spectrum_key = fuse_keysym; - - return input_event( &fuse_event ); -} - -int svgakeyboard_end(void) -{ - keyboard_close(); - return 0; -} diff --git a/fuse/ui/svga/svgakeyboard.h b/fuse/ui/svga/svgakeyboard.h deleted file mode 100644 index 834c169..0000000 --- a/fuse/ui/svga/svgakeyboard.h +++ /dev/null @@ -1,30 +0,0 @@ -/* svgakeyboard.h: svgalib routines for dealing with the keyboard - Copyright (c) 2000-2002 Philip Kendall, Matan Ziv-Av - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#ifndef FUSE_SVGAKEYBOARD_H -#define FUSE_SVGAKEYBOARD_H - -int svgakeyboard_init(void); -int svgakeyboard_end(void); - -#endif /* #ifndef FUSE_SVGAKEYBOARD_H */ diff --git a/fuse/ui/svga/svgaui.c b/fuse/ui/svga/svgaui.c deleted file mode 100644 index 013867f..0000000 --- a/fuse/ui/svga/svgaui.c +++ /dev/null @@ -1,124 +0,0 @@ -/* svgaui.c: Routines for dealing with the svgalib user interface - Copyright (c) 2000-2003 Philip Kendall, Matan Ziv-Av, Russell Marks - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include - -#include - -#if defined USE_JOYSTICK && !defined HAVE_JSW_H -#include -#endif - -#include -#include - -#include "display.h" -#include "fuse.h" -#include "svgadisplay.h" -#include "svgakeyboard.h" -#include "ui/ui.h" -#include "ui/uidisplay.h" - -static int oldbutton = 0, oldx = 0, oldy = 0; - -int ui_init(int *argc, char ***argv) -{ - int error; - - if( ui_widget_init() ) return 1; - - error = svgadisplay_init(); - if(error) return error; - - error = svgakeyboard_init(); - if(error) return error; - - vga_setmousesupport( 1 ); - mouse_setxrange( 0, 255); - mouse_setyrange( 0, 255); - mouse_setscale( 64 ); - mouse_setwrap( MOUSE_WRAPX | MOUSE_WRAPY ); - mouse_setposition( 128, 128 ); - - ui_mouse_present = 1; - - return 0; -} - -int -ui_event( void ) -{ - int x, y, b, bd; - - keyboard_update(); - mouse_update(); -#if defined USE_JOYSTICK && !defined HAVE_JSW_H - joystick_update(); -#endif - - x = mouse_getx(); - y = mouse_gety(); - b = mouse_getbutton(); - - bd = b ^ oldbutton; - if( bd & MOUSE_LEFTBUTTON ) ui_mouse_button( 1, b & MOUSE_LEFTBUTTON ); - if( bd & MOUSE_MIDDLEBUTTON ) ui_mouse_button( 2, b & MOUSE_MIDDLEBUTTON ); - if( bd & MOUSE_RIGHTBUTTON ) ui_mouse_button( 3, b & MOUSE_RIGHTBUTTON ); - oldbutton = b; - - if( x != oldx || y != oldy ) { - ui_mouse_motion( x - oldx, y - oldy ); - oldx = x; oldy = y; - } - - return 0; -} - -int ui_end(void) -{ - int error; - - error = svgakeyboard_end(); - if(error) return error; - - error = svgadisplay_end(); - if(error) return error; - - ui_widget_end(); - - return 0; -} - -int -ui_mouse_grab( int startup GCC_UNUSED ) -{ - return 1; -} - -int -ui_mouse_release( int suspend ) -{ - return !suspend; -} diff --git a/fuse/ui/ui.h b/fuse/ui/ui.h index a53cb2b..68648a4 100644 --- a/fuse/ui/ui.h +++ b/fuse/ui/ui.h @@ -41,7 +41,6 @@ #include "peripherals/disk/opus.h" #include "peripherals/disk/plusd.h" #include "svg.h" -#include "ui/scaler/scaler.h" /* The various severities of error level, increasing downwards */ typedef enum ui_error_level { @@ -304,7 +303,6 @@ int ui_widget_init( void ); int ui_widget_end( void ); /* How many levels deep have we recursed through widgets; -1 => none */ -extern int ui_widget_level; /* widget system popup the apropriate menu */ void ui_popup_menu( int native_key ); diff --git a/fuse/ui/uijoystick.c b/fuse/ui/uijoystick.c deleted file mode 100644 index 7f344de..0000000 --- a/fuse/ui/uijoystick.c +++ /dev/null @@ -1,285 +0,0 @@ -/* uijoystick.c: Joystick emulation (using libjsw) - Copyright (c) 2003-2015 Darren Salt, Philip Kendall - Copyright (c) 2015 UB880D - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - - Darren: linux@youmustbejoking.demon.co.uk - -*/ - -/* Usage note: build this from within a specific UI unless that UI implements - * its own joystick support using some other library. - * Inclusion as follows: - * #if !defined USE_JOYSTICK || defined HAVE_JSW_H - * # include "../uijoystick.c" - * #else - * // UI-specific code implementing the following (exported) functions - * #endif - */ - -#include - -#include "input.h" -#include "uijoystick.h" - -#if defined USE_JOYSTICK && defined HAVE_JSW_H - -#include -#include -#include - -#include - -#include - -#include "fuse.h" -#include "keyboard.h" -#include "settings.h" -#include "spectrum.h" -#include "machine.h" -#include "ui/ui.h" -#include "utils.h" - -static js_data_struct jsd[2]; - -static int js_button_states[2][NUM_JOY_BUTTONS]; - -static void poll_joystick( int which ); -static void do_axis( int which, double position, input_key negative, - input_key positive ); - -static int -init_stick( int which, const char *const device, - const char *const calibration ) -{ - switch( JSInit( &jsd[which], device, calibration, JSFlagNonBlocking ) ) { - - case JSSuccess: - if( JSLoadCalibrationUNIX( &jsd[which] ) && errno != ENOENT ) { - ui_error( UI_ERROR_ERROR, - "failed to read calibration for joystick %i: %s", which + 1, - strerror( errno ) ); - break; - } - - if( jsd[which].total_axises < 2 || jsd[which].total_buttons < 1 ) - { - ui_error( UI_ERROR_ERROR, "sorry, joystick %i (%s) is inadequate!", - which + 1, device ); - break; - } - return 0; - - case JSBadValue: - ui_error( UI_ERROR_ERROR, "failed to initialise joystick %i: %s", - which + 1, "invalid parameter/value"); - break; - - case JSNoAccess: - - /* FIXME: why is this commented out? */ -/* - ui_error (UI_ERROR_ERROR, - "failed to initialise joystick %i: %s", - which + 1, "cannot access device"); -*/ - break; - - case JSNoBuffers: - ui_error( UI_ERROR_ERROR, "failed to initialise joystick %i: %s", - which + 1, "not enough memory" ); - break; - - default: - ui_error( UI_ERROR_ERROR, "failed to initialise joystick %i", which + 1 ); - break; - - } - - JSClose( &jsd[which] ); - - return 1; -} - -static -int open_joystick( int which, const char *device, const char *calibration ) -{ - char path[ PATH_MAX ]; - - /* If we were given an explicit device to use for this joystick, try - only that */ - if( device && device[0] ) return init_stick( which, device, calibration ); - - /* Otherwise try /dev/input/js and /dev/js */ - snprintf( path, PATH_MAX, "/dev/input/js%d", which ); - if( !init_stick( which, path, calibration ) ) return 0; - - snprintf( path, PATH_MAX, "/dev/js%d", which ); - if( !init_stick( which, path, calibration ) ) return 0; - - /* Couldn't find this joystick */ - return 1; -} - -int -ui_joystick_init( void ) -{ - const char *cfgdir; - char *calibration; - int error; - size_t i, j; - - cfgdir = compat_get_config_path(); if( !cfgdir ) return 1; - - /* Default calibration file is ~/.joystick */ - calibration = libspectrum_new( char, strlen( cfgdir ) + - strlen( JSDefaultCalibration ) + 2 ); - - sprintf( calibration, "%s/%s", cfgdir, JSDefaultCalibration ); - - for( i = 0; i < 2; i++ ) { - for( j = 0; j < NUM_JOY_BUTTONS; j++ ) { - js_button_states[i][j] = 0; - } - } - - /* If we can't init the first, don't try the second */ - error = open_joystick( 0, settings_current.joystick_1, calibration ); - if( error ) { - libspectrum_free( calibration ); - return 0; - } - - error = open_joystick( 1, settings_current.joystick_2, calibration ); - if( error ) { - libspectrum_free( calibration ); - return 1; - } - - libspectrum_free( calibration ); - - return 2; -} - -void -ui_joystick_end( void ) -{ - int i; - for( i = 0; i < joysticks_supported; i++ ) JSClose( &jsd[i] ); -} - -void -ui_joystick_poll( void ) -{ - int i; - - for( i = 0; i < joysticks_supported; i++ ) poll_joystick( i ); -} - -static void -poll_joystick( int which ) -{ - js_data_struct *joystick; - double position; - int fire, buttons; - input_event_t event; - size_t i; - - joystick = &jsd[which]; - - if( JSUpdate( joystick ) != JSGotEvent ) return; - - position = JSGetAxisCoeffNZ( joystick, 0 ); - do_axis( which, position, INPUT_JOYSTICK_LEFT, INPUT_JOYSTICK_RIGHT ); - - position = JSGetAxisCoeffNZ( joystick, 1 ); - do_axis( which, position, INPUT_JOYSTICK_UP, INPUT_JOYSTICK_DOWN ); - - event.types.joystick.which = which; - - buttons = joystick->total_buttons; - if( buttons > NUM_JOY_BUTTONS ) buttons = NUM_JOY_BUTTONS; /* We support 'only' NUM_JOY_BUTTONS (15 as defined in ui/uijoystick.h) fire buttons */ - - for( i = 0; i < buttons; i++ ) { - - fire = JSGetButtonState( joystick, i ); - if( fire == JSButtonStateOn ) { - event.type = INPUT_EVENT_JOYSTICK_PRESS; - } else { - event.type = INPUT_EVENT_JOYSTICK_RELEASE; - } - - event.types.joystick.button = INPUT_JOYSTICK_FIRE_1 + i; - - if( js_button_states[which][i] != fire ) { - js_button_states[which][i] = fire; - input_event( &event ); - } - - } - -} - -static void -do_axis( int which, double position, input_key negative, input_key positive ) -{ - input_event_t event1, event2; - - event1.types.joystick.which = event2.types.joystick.which = which; - - event1.types.joystick.button = positive; - event2.types.joystick.button = negative; - - if( position == 0.0 ) { - event1.type = INPUT_EVENT_JOYSTICK_RELEASE; - event2.type = INPUT_EVENT_JOYSTICK_RELEASE; - } else if( position > 0.0 ) { - event1.type = INPUT_EVENT_JOYSTICK_PRESS; - event2.type = INPUT_EVENT_JOYSTICK_RELEASE; - } else { - event1.type = INPUT_EVENT_JOYSTICK_RELEASE; - event2.type = INPUT_EVENT_JOYSTICK_PRESS; - } - - input_event( &event1 ); - input_event( &event2 ); -} - -#else /* #if defined USE_JOYSTICK && defined HAVE_JSW_H */ - -/* No joystick library */ - -int -ui_joystick_init( void ) -{ - return 0; -} - -void -ui_joystick_end( void ) -{ -} - -void -ui_joystick_poll( void ) -{ -} - -#endif /* #if defined USE_JOYSTICK && defined HAVE_JSW_H */ diff --git a/fuse/ui/widget/Makefile.am b/fuse/ui/widget/Makefile.am deleted file mode 100644 index 7d9ed1f..0000000 --- a/fuse/ui/widget/Makefile.am +++ /dev/null @@ -1,84 +0,0 @@ -## Process this file with automake to produce Makefile.in -## Copyright (c) 2001,2002 Philip Kendall -## Copyright (c) 2015 Sergio Baldoví - -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -## -## Author contact information: -## -## E-mail: philip-fuse@shadowmagic.org.uk - -if USE_WIDGET - -fuse_SOURCES += $(ui_widget_files) - -BUILT_SOURCES += $(ui_widget_built) - -pkgdata_DATA += ui/widget/fuse.font - -endif - - -CLEANFILES += $(ui_widget_built) - -ui_widget_files = \ - ui/widget/about.c \ - ui/widget/binary.c \ - ui/widget/browse.c \ - ui/widget/debugger.c \ - ui/widget/error.c \ - ui/widget/filesel.c \ - ui/widget/memory.c \ - ui/widget/menu.c \ - ui/widget/menu_data.c \ - ui/widget/options.c \ - ui/widget/picture.c \ - ui/widget/pokefinder.c \ - ui/widget/pokemem.c \ - ui/widget/query.c \ - ui/widget/roms.c \ - ui/widget/select.c \ - ui/widget/text.c \ - ui/widget/widget_internals.h \ - ui/widget/widget.c \ - ui/widget/widget.h - -ui_widget_built = \ - ui/widget/fuse.font \ - ui/widget/menu_data.c \ - ui/widget/options.c \ - ui/widget/options_internals.h - -EXTRA_DIST += \ - ui/widget/fuse.font.sbf \ - ui/widget/mkfusefont.pl \ - ui/widget/options.pl \ - ui/widget/options-header.pl - -ui/widget/menu_data.c: $(srcdir)/perl/cpp-perl.pl $(srcdir)/menu_data.dat $(srcdir)/menu_data.pl config.h - @$(MKDIR_P) ui/widget - $(AM_V_GEN)$(PERL) $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/menu_data.dat | $(PERL) -I$(srcdir)/perl $(srcdir)/menu_data.pl widget > $@.tmp && mv $@.tmp $@ - -ui/widget/options.c: $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/ui/widget/options.pl $(srcdir)/ui/options.dat $(srcdir)/perl/Fuse.pm $(srcdir)/perl/Fuse/Dialog.pm - @$(MKDIR_P) ui/widget - $(AM_V_GEN)$(PERL) $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/ui/options.dat | $(PERL) -I$(srcdir)/perl $(srcdir)/ui/widget/options.pl - > $@.tmp && mv $@.tmp $@ - -ui/widget/options_internals.h: $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/ui/widget/options-header.pl $(srcdir)/ui/options.dat $(srcdir)/perl/Fuse.pm $(srcdir)/perl/Fuse/Dialog.pm - @$(MKDIR_P) ui/widget - $(AM_V_GEN)$(PERL) $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/ui/options.dat | $(PERL) -I$(srcdir)/perl $(srcdir)/ui/widget/options-header.pl - > $@.tmp && mv $@.tmp $@ - -ui/widget/fuse.font: $(srcdir)/ui/widget/mkfusefont.pl $(srcdir)/ui/widget/fuse.font.sbf - @$(MKDIR_P) ui/widget - $(AM_V_GEN)$(PERL) $(srcdir)/ui/widget/mkfusefont.pl $(srcdir)/ui/widget/fuse.font.sbf > $@.tmp && mv $@.tmp $@ diff --git a/fuse/ui/widget/about.c b/fuse/ui/widget/about.c deleted file mode 100644 index 18bd87b..0000000 --- a/fuse/ui/widget/about.c +++ /dev/null @@ -1,92 +0,0 @@ -/* about.c: about dialog box - Copyright (c) 2016 Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: serbalgi@gmail.com - -*/ - -#include - -#include - -#include "widget.h" -#include "widget_internals.h" - -int -widget_about_draw( void *data GCC_UNUSED ) -{ - char buffer[80]; - int dialog_cols, string_width, margin, x, line; - - dialog_cols = 30; - margin = 17; - line = 0; - - widget_dialog_with_border( 1, 2, dialog_cols, 7+2 ); - widget_printstring( 10, 16, WIDGET_COLOUR_TITLE, "About Fuse" ); - - string_width = widget_stringwidth( "the Free Unix Spectrum Emulator (Fuse)" ); - x = margin - 8 + ( dialog_cols * 8 - string_width ) / 2; - widget_printstring( x, ++line * 8 + 24, WIDGET_COLOUR_FOREGROUND, - "the Free Unix Spectrum Emulator (Fuse)" ); - - snprintf( buffer, 80, "Version %s", VERSION ); - string_width = widget_stringwidth( buffer ); - x = margin - 8 + ( dialog_cols * 8 - string_width ) / 2; - widget_printstring( x, ++line * 8 + 24, WIDGET_COLOUR_FOREGROUND, buffer ); - - ++line; - - string_width = widget_stringwidth( FUSE_COPYRIGHT ); - x = margin - 8 + ( dialog_cols * 8 - string_width ) / 2; - widget_printstring( x, ++line * 8 + 24, WIDGET_COLOUR_FOREGROUND, - FUSE_COPYRIGHT ); - - ++line; - - string_width = widget_stringwidth( PACKAGE_URL ); - x = margin - 8 + ( dialog_cols * 8 - string_width ) / 2; - widget_printstring( x, ++line * 8 + 24, 0x09, PACKAGE_URL ); - - widget_display_lines( 2, line + 3 ); - - return 0; -} - -void -widget_about_keyhandler( input_key key ) -{ - switch( key ) { - - case INPUT_KEY_Escape: - case INPUT_JOYSTICK_FIRE_2: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - return; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: - widget_end_widget( WIDGET_FINISHED_OK ); - return; - - default: /* Keep gcc happy */ - break; - - } -} diff --git a/fuse/ui/widget/binary.c b/fuse/ui/widget/binary.c deleted file mode 100644 index c2d0cd9..0000000 --- a/fuse/ui/widget/binary.c +++ /dev/null @@ -1,433 +0,0 @@ -/* binary.c: The binary load/save widgets - Copyright (c) 2019 Gergely Szasz - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: szaszg@hu.inter.net - -*/ - -#include - -#include -#include -#include - -#include "fuse.h" -#include "utils.h" -#include "widget_internals.h" - -typedef struct { - int confirm; - ui_confirm_save_t save; - const char *title; - - char *filename; - utils_file file; - - int load; - char *start_str; - char *length_str; - libspectrum_dword start; - libspectrum_dword length; -} widget_binary_t; - -static widget_binary_t widget_binary; - -struct widget_binary_entry; - -/* A generic click function */ -typedef void (*widget_binary_click_fn)( void ); - -/* A general menu */ -typedef struct widget_binary_entry { - const char *text; - int x, y; - - widget_binary_click_fn click; -} widget_binary_entry; - -static void widget_browse_click( void ); -static void widget_start_click( void ); -static void widget_length_click( void ); -static void widget_cancel_click( void ); -static void widget_ok_click( void ); - -static widget_binary_entry binary_entry[] = { - { "\012B\001rowse", 208, 28, widget_browse_click }, - { "\012S\001tart", 16, 40, widget_start_click }, - { "\012L\001ength", 16, 48, widget_length_click }, - { "\012C\001ancel", 186, 68, widget_cancel_click }, - { "\012O\001k", 228, 68, widget_ok_click }, - { NULL } -}; - -static size_t highlight_entry = 0; - -static void -widget_binary_entry_draw( int index, int highlight ) -{ - int w = widget_stringwidth( binary_entry[index].text ); - - widget_rectangle( binary_entry[index].x - 1, binary_entry[index].y, w + 2, 8, - highlight ? WIDGET_COLOUR_HIGHLIGHT : WIDGET_COLOUR_BACKGROUND ); - widget_printstring( binary_entry[index].x, binary_entry[index].y, - WIDGET_COLOUR_FOREGROUND, binary_entry[index].text ); - widget_display_rasters( binary_entry[index].y, 8 ); -} - -/* 0 - all, 1 - filename, 2 - start, 3 - length, 4 - DEC/HEX/OCT */ -static void -display_values( int what ) -{ - if( !what || what == 1 ) { - const char *fn; - fn = widget_binary.filename; - while( widget_stringwidth( fn ) >= 136 ) fn++; - widget_rectangle( 68, 28, 136, 8, WIDGET_COLOUR_BACKGROUND ); - widget_printstring( 68, 28, WIDGET_COLOUR_DISABLED, fn ); - widget_display_lines( 3, 2 ); - } - if( !what || what == 2 ) { - widget_rectangle( 68, 40, 136, 8, WIDGET_COLOUR_BACKGROUND ); - widget_printstring( 68, 40, WIDGET_COLOUR_FOREGROUND, - widget_binary.start_str ); - widget_display_lines( 5, 1 ); - } - if( !what || what == 3 ) { - widget_rectangle( 68, 48, 136, 8, WIDGET_COLOUR_BACKGROUND ); - widget_printstring( 68, 48, WIDGET_COLOUR_FOREGROUND, - widget_binary.length_str ); - widget_display_lines( 6, 1 ); - } -} - -int -widget_binary_draw( void *data ) -{ - int i; - - widget_dialog_with_border( 1, 2, 30, 8 ); - widget_printstring( 10, 16, WIDGET_COLOUR_TITLE, widget_binary.title ); - widget_printstring( 16, 28, WIDGET_COLOUR_FOREGROUND, "Filename: " ); - - display_values( 0 ); - - for( i = 0; binary_entry[i].text != NULL; i++ ) { - widget_binary_entry_draw( i, ( highlight_entry == i ) ); - } - - widget_display_lines( 2, 8 ); - return 0; -} - -static void -ask_filename() -{ - widget_filesel_data filesel; - - filesel.exit_all_widgets = 0; - - if( widget_binary.load ) { - filesel.title = "Fuse - Load Binary Data"; - widget_do_fileselector( &filesel ); - } else { - filesel.title = "Fuse - Save Binary Data"; - widget_do_fileselector_save( &filesel ); - } - if( !widget_filesel_name ) return; - - free( widget_binary.filename ); - - widget_binary.filename = utils_safe_strdup( widget_filesel_name ); - - display_values( 1 ); -} - -/* 1 - filename, 2 - start, 3 - length */ -static void -ask_value( int what ) -{ - long int value; - char *s; - widget_text_t text_data; - - text_data.allow = WIDGET_INPUT_ALNUM; - text_data.max_length = 9; - if( what == 2 ) { - text_data.title = "Enter start value"; - s = widget_binary.start_str; - } else if( what == 3 ) { - text_data.title = "Enter length"; - s = widget_binary.length_str; - } - snprintf( text_data.text, sizeof( text_data.text ), "%s", s ); - widget_do_text( &text_data ); - if( !widget_text_text ) return; - - value = strtol( widget_text_text, &s, 0 ); - if( *s != '\0' ) { - ui_error( UI_ERROR_ERROR, "Invalid number" ); - return; - } - - if( what == 2 ) { - if( value < 0 || value > 0xffff ) { - ui_error( UI_ERROR_ERROR, "Start must be between 0 and 65535" ); - } else if( value + widget_binary.length > 0x10000 ) { - ui_error( UI_ERROR_ERROR, "Block ends after address 65535" ); - } else { - free( widget_binary.start_str ); - widget_binary.start_str = utils_safe_strdup( widget_text_text ); - widget_binary.start = value; - } - } else if( what == 3 ) { - if( value < 1 || value > 0x10000 ) { - ui_error( UI_ERROR_ERROR, "Length must be between 1 and 65536" ); - } else if( value + widget_binary.start > 0x10000 ) { - ui_error( UI_ERROR_ERROR, "Block ends after address 65535" ); - } else if( widget_binary.load && value > widget_binary.file.length ) { - ui_error( UI_ERROR_ERROR, "'%s' contains only %lu bytes", - widget_binary.filename, (unsigned long)widget_binary.file.length - ); - return; - } else { - free( widget_binary.length_str ); - widget_binary.length_str = utils_safe_strdup( widget_text_text ); - widget_binary.length = value; - } - } - - display_values( what ); -} - -static void -load_data() -{ - libspectrum_dword i; - - for( i = 0; i < widget_binary.length; i++ ) - writebyte_internal( widget_binary.start + i, - widget_binary.file.buffer[ i ] ); -} - -static void -save_data() -{ - int error; - error = utils_save_binary( widget_binary.start, widget_binary.length, - widget_binary.filename ); - /* TODO: some error reporting */ - if( error ) return; -} - -static void -widget_browse_click( void ) -{ - ask_filename(); -} - -static void -widget_start_click( void ) -{ - ask_value( 2 ); -} - -static void -widget_length_click( void ) -{ - ask_value( 3 ); -} - -static void -widget_cancel_click( void ) -{ - widget_end_widget( WIDGET_FINISHED_CANCEL ); -} - -static void -widget_ok_click( void ) -{ - if( widget_binary.load ) { - load_data(); - } else { - save_data(); - } - widget_end_all( WIDGET_FINISHED_OK ); - display_refresh_all(); -} - -void -widget_binary_keyhandler( input_key key ) -{ - int new_highlight_entry = highlight_entry; - int clicked = 0; - - switch( key ) { - -#if 0 - case INPUT_KEY_Resize: /* Fake keypress used on window resize */ - widget_dialog_with_border( 1, 2, 30, 2 + 20 ); - widget_general_show_all( &widget_options_settings ); - break; -#endif - - case INPUT_KEY_c: - case INPUT_KEY_C: - case INPUT_KEY_Escape: - case INPUT_KEY_F10: - case INPUT_JOYSTICK_FIRE_2: - new_highlight_entry = 3; - clicked = 1; - break; - - case INPUT_KEY_b: - case INPUT_KEY_B: - new_highlight_entry = 0; - clicked = 1; - break; - - case INPUT_KEY_s: - case INPUT_KEY_S: - new_highlight_entry = 1; - clicked = 1; - break; - - case INPUT_KEY_l: - case INPUT_KEY_L: - new_highlight_entry = 2; - clicked = 1; - break; - - case INPUT_KEY_o: - case INPUT_KEY_O: - new_highlight_entry = 4; - clicked = 1; - break; - - case INPUT_KEY_Up: - case INPUT_KEY_7: - case INPUT_JOYSTICK_UP: - new_highlight_entry = highlight_entry - 1; - if( new_highlight_entry < 0 ) - while( binary_entry[new_highlight_entry + 1].text != NULL ) - new_highlight_entry++; - break; - - case INPUT_KEY_Down: - case INPUT_KEY_6: - case INPUT_JOYSTICK_DOWN: - new_highlight_entry = highlight_entry + 1; - if( binary_entry[new_highlight_entry].text == NULL ) - new_highlight_entry = 0; - break; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: - clicked = 1; - - default: /* Keep gcc happy */ - break; - - } - - if( highlight_entry != new_highlight_entry ) { - widget_binary_entry_draw( highlight_entry, 0 ); - widget_binary_entry_draw( new_highlight_entry, 1 ); - highlight_entry = new_highlight_entry; - } - if( clicked ) binary_entry[highlight_entry].click(); -} - -int -widget_binary_finish( widget_finish_state finished ) -{ - free( widget_binary.start_str ); - free( widget_binary.length_str ); - free( widget_binary.filename ); - - return 0; -} - -static void -init_widget_binary() -{ - char str[8]; - - highlight_entry = 0; - widget_binary.start = 0; - widget_binary.length = widget_binary.load && - widget_binary.file.length < 65536 ? widget_binary.file.length : 65536; - - snprintf( str, 8, "%d", widget_binary.length ); - widget_binary.start_str = utils_safe_strdup( "0" ); - widget_binary.length_str = utils_safe_strdup( str ); -} - -int -menu_file_loadbinarydata( int action ) -{ - int error; - - fuse_emulation_pause(); - - widget_binary.filename = ui_get_open_filename( "Fuse - Load Binary Data" ); - if( !widget_binary.filename ) { - fuse_emulation_unpause(); - return 1; - } - - error = utils_read_file( widget_binary.filename, &widget_binary.file ); - if( error ) { - free( widget_binary.filename ); - fuse_emulation_unpause(); - return 1; - } - - widget_binary.load = 1; - widget_binary.title = "Fuse - Load Binary Data"; - init_widget_binary(); - /* Run dialog */ - widget_do_binary(); - - utils_close_file( &widget_binary.file ); - - fuse_emulation_unpause(); - return 0; -} - -int -menu_file_savebinarydata( int action ) -{ - fuse_emulation_pause(); - - widget_binary.filename = ui_get_save_filename( "Fuse - Save Binary Data" ); - if( !widget_binary.filename ) { - fuse_emulation_unpause(); - return 1; - } - - widget_binary.load = 0; - widget_binary.title = "Fuse - Save Binary Data"; - init_widget_binary(); - /* Run dialog */ - widget_do_binary(); - - fuse_emulation_unpause(); - return 0; -} diff --git a/fuse/ui/widget/browse.c b/fuse/ui/widget/browse.c deleted file mode 100644 index 7859e01..0000000 --- a/fuse/ui/widget/browse.c +++ /dev/null @@ -1,234 +0,0 @@ -/* browse.c: tape browser widget - Copyright (c) 2002-2004 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include - -#ifdef HAVE_LIB_GLIB -#include -#else /* #ifdef HAVE_LIB_GLIB */ -#include -#endif /* #ifdef HAVE_LIB_GLIB */ - -#include "fuse.h" -#include "tape.h" -#include "widget_internals.h" - -#define MAX_BLOCK_DESC 30 - -/* The descriptions of the blocks */ -static GSList *blocks; - -/* How many blocks we have in total */ -size_t block_count; - -/* Which block is shown on the top line of the widget */ -static int top_line; - -/* Which block is currently highlighted */ -static int highlight; - -static void show_blocks( void ); -static void add_block_description( libspectrum_tape_block *block, - void *user_data ); -static void free_description( gpointer data, gpointer user_data ); - -int -widget_browse_draw( void *data GCC_UNUSED ) -{ - int error; - - blocks = NULL; block_count = 0; - error = tape_foreach( add_block_description, &blocks ); - if( error ) return error; - - widget_dialog_with_border( 1, 2, 30, 20 ); - - widget_printstring( 10, 16, WIDGET_COLOUR_TITLE, "Browse Tape" ); - widget_display_lines( 2, 1 ); - - highlight = tape_get_current_block(); - top_line = highlight - 8; if( top_line < 0 ) top_line = 0; - - show_blocks(); - - return 0; -} - -static void -add_block_description( libspectrum_tape_block *block, void *user_data ) -{ - char data_detail[MAX_BLOCK_DESC]; - GSList **ptr = user_data; - - char *buffer; - - tape_block_details( data_detail, MAX_BLOCK_DESC, block ); - buffer = malloc( MAX_BLOCK_DESC ); if( !buffer ) return; - libspectrum_tape_block_description( buffer, MAX_BLOCK_DESC, block ); - if( strlen( data_detail ) ) strcpy( buffer, data_detail ); - - (*ptr) = g_slist_append( *ptr, buffer ); - - block_count++; -} - -static void -show_blocks( void ) -{ - size_t i; char buffer[64]; - GSList *ptr; - int numpos = g_slist_length( blocks ); - - if( numpos < 10 ) { - numpos = 24; - } else if( numpos < 100 ) { - numpos = 32; - } else { - numpos = 40; - } - - widget_rectangle( 9, 2*8, 30*8-2, 19*8, WIDGET_COLOUR_BACKGROUND ); - - for( i = 0, ptr = g_slist_nth( blocks, top_line ); - i < 18 && ptr; - i++, ptr = ptr->next ) { - - int colour = WIDGET_COLOUR_FOREGROUND; - - if( top_line + i == highlight ) - widget_rectangle( 9, i*8+24, 30*8-2, 1*8, WIDGET_COLOUR_HIGHLIGHT ); - - sprintf( buffer, "%lu", (unsigned long)( top_line + i + 1 ) ); - widget_printstring_right( numpos, i*8+24, colour, buffer ); - snprintf( buffer, sizeof( buffer ), ": %s", (char *)ptr->data ); - widget_printstring( numpos + 1, i*8+24, colour, buffer ); - } - - widget_display_lines( 3, 19 ); -} - -void -widget_browse_keyhandler( input_key key ) -{ - switch( key ) { - -#if 0 - case INPUT_KEY_Resize: /* Fake keypress used on window resize */ - widget_browse_draw( NULL ); - break; -#endif - - case INPUT_KEY_Escape: - case INPUT_JOYSTICK_FIRE_2: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - return; - - case INPUT_KEY_Down: - case INPUT_KEY_6: - case INPUT_KEY_j: - case INPUT_JOYSTICK_DOWN: - if( highlight < block_count - 1 ) { - highlight++; - if( highlight >= top_line + 18 ) top_line += 18; - show_blocks(); - } - break; - - case INPUT_KEY_Up: - case INPUT_KEY_7: - case INPUT_KEY_k: - case INPUT_JOYSTICK_UP: - if( highlight > 0 ) { - highlight--; - if( highlight < top_line ) - { - top_line -= 18; - if( top_line < 0 ) top_line = 0; - } - show_blocks(); - } - break; - - case INPUT_KEY_Page_Up: - highlight -= 18; if( highlight < 0 ) highlight = 0; - top_line -= 18; if( top_line < 0 ) top_line = 0; - show_blocks(); - break; - - case INPUT_KEY_Page_Down: - highlight += 18; - if( highlight >= block_count ) highlight = block_count - 1; - top_line += 18; - if( top_line >= block_count ) { - top_line = block_count - 18; - if( top_line < 0 ) top_line = 0; - } - show_blocks(); - break; - - case INPUT_KEY_Home: - highlight = top_line = 0; - show_blocks(); - break; - - case INPUT_KEY_End: - highlight = block_count - 1; - top_line = block_count - 18; if( top_line < 0 ) top_line = 0; - show_blocks(); - break; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: - widget_end_widget( WIDGET_FINISHED_OK ); - return; - - default: /* Keep gcc happy */ - break; - - } -} - -int -widget_browse_finish( widget_finish_state finished ) -{ - g_slist_foreach( blocks, free_description, NULL ); - g_slist_free( blocks ); - - if( finished == WIDGET_FINISHED_OK ) { - if( highlight != -1 ) tape_select_block( highlight ); - widget_end_all( WIDGET_FINISHED_OK ); - } - - return 0; -} - -static void -free_description( gpointer data, gpointer user_data ) -{ - free( data ); -} diff --git a/fuse/ui/widget/debugger.c b/fuse/ui/widget/debugger.c deleted file mode 100644 index 2d0a0c7..0000000 --- a/fuse/ui/widget/debugger.c +++ /dev/null @@ -1,586 +0,0 @@ -/* debugger.c: The debugger widget - Copyright (c) 2002-2014 Philip Kendall, Darren Salt - Copyright (c) 2015 Stuart Brady - Copyright (c) 2016 BogDan Vatra - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include - -#include "debugger/debugger.h" -#include "display.h" -#include "keyboard.h" -#include "machine.h" -#include "peripherals/ide/zxcf.h" -#include "peripherals/scld.h" -#include "peripherals/ula.h" -#include "ui/uidisplay.h" -#include "widget.h" -#include "widget_internals.h" -#include "z80/z80.h" -#include "z80/z80_macros.h" - -static enum { - DB_REGISTERS, DB_BYTES, DB_TEXT, DB_DISASM, DB_BREAKPT -} display = DB_REGISTERS; - -struct { - libspectrum_word value; - size_t page; - char x, width, column; -} db_editv = { - 0, 0, 255, 0 -}; - -static libspectrum_word debugger_memaddr; -static int breakpt_no = 0, breakpt_show = 0; - -/* Various data displays */ -static void display_registers( void ); -static void display_bytes( void ); -static void display_text( void ); -static void display_disasm( void ); -static void display_breakpts( void ); - -/* Scrolling for the data displays */ -static void scroll( int step ); - -#define LC(X) ( (X)*8 - DISPLAY_BORDER_ASPECT_WIDTH ) -#define LR(Y) ( (Y)*8 - DISPLAY_BORDER_HEIGHT ) - -static inline const char *format_8_bit( void ) -{ - return debugger_output_base == 10 ? "%-3d" : "%02X"; -} - -static inline const char *format_16_bit( void ) -{ - return debugger_output_base == 10 ? "%-5d" : "%04X"; -} - -int ui_debugger_activate( void ) -{ - return widget_do_debugger(); -} - -int ui_debugger_deactivate( int interruptible GCC_UNUSED ) -{ - /* Refresh the Spectrum's display, including the border */ - display_refresh_all(); - return widget_end_all( WIDGET_FINISHED_OK ); -} - -int ui_debugger_update( void ) -{ - return widget_debugger_draw( NULL ); -} - -int ui_debugger_disassemble( libspectrum_word addr ) -{ - debugger_memaddr = addr; - return 0; -} - -/* Debugger update function. The dialog box is created every time it is - displayed, so no need to do anything here */ -void ui_breakpoints_updated( void ) -{ -} - -int widget_debugger_draw( void *data ) -{ - static const char state[][8] = { - "Running", "Halted", "Stepped", "Breakpt" - }; - int x; - char pbuf[8]; - - widget_rectangle( LC(0), LR(0), 40 * 8, 17 * 8 + 4, 1 ); - widget_rectangle( LC(0), LR(17) + 2, 320, 1, 7 ); - - switch ( display ) { - case DB_REGISTERS: display_registers(); break; - case DB_BYTES: display_bytes(); break; - case DB_TEXT: display_text(); break; - case DB_DISASM: display_disasm(); break; - case DB_BREAKPT: display_breakpts(); break; - } - - widget_printstring( LC(0), LR(15) - 4, 6, state[debugger_mode] ); - widget_printstring( LC(10), LR(15) - 4, 6, - "\022S\021ingle step \022C\021ontinue Co\022m\021mand" ); - - x = LC(-1); - if( display != DB_REGISTERS ) - x = widget_printstring( x + 8, LR(16), 7, "\022R\021egs" ); - if( display != DB_BYTES ) - x = widget_printstring( x + 8, LR(16), 7, "\022B\021ytes" ); - if( display != DB_TEXT ) - x = widget_printstring( x + 8, LR(16), 7, "\022T\021ext" ); - if( display != DB_DISASM ) - x = widget_printstring( x + 8, LR(16), 7, "\022D\021isasm" ); - if( display != DB_BREAKPT ) - x = widget_printstring( x + 8, LR(16), 7, "Brea\022k\021pts" ); - - widget_printstring_right( LC(25) + 4, LR(16), 5, "PC" ); - sprintf( pbuf, "%04X", PC ); - widget_printstring_fixed( LC(26), LR(16), 7, pbuf ); - - widget_printstring_right( LR(35) + 4, LR(16), 5, "Bas\022e\021" ); - sprintf( pbuf, "%d", debugger_output_base ); - widget_printstring( LR(36), LR(16), 7, pbuf ); - - widget_display_lines( LR(0) / 8, 18 ); - - return 0; -} - - -void widget_debugger_keyhandler( input_key key ) -{ - /* Display mode */ - switch ( key ) { - case INPUT_KEY_Escape: /* Close widget */ - widget_end_widget( WIDGET_FINISHED_CANCEL ); - debugger_run(); - break; - - case INPUT_KEY_c: - case INPUT_KEY_Return: /* Close widget */ - case INPUT_KEY_KP_Enter: - widget_end_all( WIDGET_FINISHED_OK ); - debugger_run(); - break; - - case INPUT_KEY_s: /* Single step & reopen widget */ - debugger_mode = DEBUGGER_MODE_HALTED; - widget_end_all( WIDGET_FINISHED_OK ); - break; - - case INPUT_KEY_r: /* Display the registers */ - display = DB_REGISTERS; - widget_debugger_draw( NULL ); - break; - - case INPUT_KEY_b: /* Display a memory dump (bytes) */ - display = DB_BYTES; - widget_debugger_draw( NULL ); - break; - - case INPUT_KEY_t: /* Display a memory dump (text) */ - display = DB_TEXT; - widget_debugger_draw( NULL ); - break; - - case INPUT_KEY_d: /* Display a disassembly */ - display = DB_DISASM; - widget_debugger_draw( NULL ); - break; - - case INPUT_KEY_k: /* Display the breakpoints */ - display = DB_BREAKPT; - widget_debugger_draw( NULL ); - break; - - case INPUT_KEY_e: /* Switch base */ - debugger_output_base = 26 - debugger_output_base; /* 10 or 16 */ - widget_debugger_draw( NULL ); - break; - - case INPUT_KEY_m: /* Enter a command */ - { - widget_text_t text_data; - - text_data.title = "Debugger command"; - text_data.allow = WIDGET_INPUT_ASCII; - text_data.max_length = 63; - text_data.text[0] = 0; - if( !widget_do_text( &text_data ) ) - debugger_command_evaluate( widget_text_text ); - } - break; - - case INPUT_KEY_Up: /* Back one line */ - scroll( -1 ); - break; - - case INPUT_KEY_Down: /* Back one instruction or four lines */ - scroll( 1 ); - break; - - case INPUT_KEY_Page_Up: /* Back eight lines */ - scroll( -8 ); - break; - - case INPUT_KEY_Page_Down: /* Forward eight lines */ - scroll( 8 ); - break; - - case INPUT_KEY_Home: /* To start of memory */ - debugger_memaddr = 0; - scroll( 0 ); - break; - - case INPUT_KEY_End: /* To end of RAM */ - debugger_memaddr = 0; - scroll( -8 ); - break; - - default:; - } -} - -static void show_register0( int x, int y, const char *label, int value ) -{ - char pbuf[8]; - - sprintf( pbuf, "%d", value ); - widget_printstring_right( x - 4, y, 5, label ); - widget_printstring_fixed( x, y, 7, pbuf ); -} - -static void show_register1( int x, int y, const char *label, int value ) -{ - char pbuf[8]; - - sprintf( pbuf, format_8_bit(), value ); - widget_printstring_right( x - 4, y, 5, label ); - widget_printstring_fixed( x, y, 7, pbuf ); -} - -static void show_register2( int x, int y, const char *label, int value ) -{ - char pbuf[8]; - - sprintf( pbuf, format_16_bit(), value ); - widget_printstring_right( x - 4, y, 5, label ); - widget_printstring_fixed( x, y, 7, pbuf ); -} - -static void display_registers( void ) -{ - int source, page_num, writable, contended; - libspectrum_word offset; - size_t block; - char pbuf[16]; - int i, capabilities; - - show_register2( LC(3), LR(0), "AF", AF ); - show_register2( LC(12), LR(0), "AF'", AF_ ); - show_register2( LC(20), LR(0), "SP", SP ); - show_register2( LC(29), LR(0), "PC", PC ); - show_register1( LC(36), LR(0), "R", ( R & 0x7F ) | ( R7 & 0x80 ) ); - - show_register2( LC(3), LR(1), "BC", BC ); - show_register2( LC(12), LR(1), "BC'", BC_ ); - show_register2( LC(20), LR(1), "IX", IX ); - show_register2( LC(29), LR(1), "IY", IY ); - show_register1( LC(36), LR(1), "I", I ); - - show_register2( LC(3), LR(2), "DE", DE ); - show_register2( LC(12), LR(2), "DE'", DE_ ); - show_register0( LC(20), LR(2), "IM", IM ); - show_register0( LC(29), LR(2), "IFF1", IFF1 ); - show_register0( LC(36), LR(2), "IFF2", IFF2 ); - - show_register0( LC(36), LR(2), "IFF2", IFF2 ); - show_register2( LC(3), LR(3), "HL", HL ); - show_register2( LC(12), LR(3), "HL'", HL_ ); - widget_printstring_fixed( LC(20), LR(3), 5, "SZ5H3PNC" ); - show_register0( LC(36), LR(3), "HALTED", z80.halted ); - show_register1( LC(36), LR(4), "ULA", ula_last_byte() ); - - sprintf( pbuf, "%d", tstates ); - widget_printstring_right( LC(12) - 4, LR(4), 5, "Tstates" ); - widget_printstring_fixed( LC(12), LR(4), 7, pbuf ); - for( i = 0; i < 8; ++i ) - pbuf[i] = ( F & ( 0x80 >> i ) ) ? '1' : '0'; - pbuf[8] = 0; - widget_printstring_fixed( LC(20), LR(4), 7, pbuf ); - - capabilities = libspectrum_machine_capabilities( machine_current->machine ); - - if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_AY ) - show_register1( LC(37), LR(4), "AY", - machine_current->ay.current_register ); - - if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_128_MEMORY ) - show_register1( LC(6), LR(5), "128Mem", - machine_current->ram.last_byte ); - - if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_128_MEMORY ) - show_register1( LC(15), LR(5), "+3Mem", - machine_current->ram.last_byte2 ); - - if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_VIDEO || - capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_MEMORY || - capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_SE_MEMORY ) - show_register1( LC(24), LR(5), "TmxDec", scld_last_dec.byte ); - - if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_MEMORY || - capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_SE_MEMORY ) - show_register1( LC(33), LR(5), "TmxHSR", scld_last_hsr ); - - if( settings_current.zxcf_active ) - show_register1( LC(6), LR(5), "ZXCF", zxcf_last_memctl() ); - - source = page_num = writable = contended = -1; - offset = 0; - i = 0; - - for( block = 0; block < MEMORY_PAGES_IN_64K; block++ ) { - memory_page *page = &memory_map_read[block]; - - if( page->source != source || - page->page_num != page_num || - page->offset != offset || - page->writable != writable || - page->contended != contended ) { - - int x = LC(5 + 20 * ( i & 1 ) ), y = LR(6 + ( i / 2 ) ); - - sprintf( pbuf, format_16_bit(), (unsigned)block * MEMORY_PAGE_SIZE ); - widget_printstring_right( x, y, 5, pbuf ); - snprintf( pbuf, sizeof( pbuf ), "%s %d", - memory_source_description( memory_map_read[block].source ), - memory_map_read[block].page_num ); - x = widget_printstring( x + 4, y, 7, pbuf ) + 4; - if( memory_map_read[block].writable ) - x = widget_printstring( x, y, 4, "w" ); - if( memory_map_read[block].contended ) - x = widget_printstring( x, y, 4, "c" ); - - i++; - - source = page->source; - page_num = page->page_num; - writable = page->writable; - contended = page->contended; - offset = page->offset; - } - - /* We expect the next page to have an increased offset */ - offset += MEMORY_PAGE_SIZE; - } -} - - -static void display_bytes( void ) -{ - int x, y; - char pbuf[36]; - - for( y = 0; y < 8; ++y ) { - libspectrum_word addr = debugger_memaddr + y * 8; - - sprintf( pbuf, format_16_bit(), addr ); - widget_printstring_fixed( LC(1), LR(y), 7, pbuf ); - widget_printstring( LC(6), LR(y), 5, ":" ); - - for( x = 0; x < 8; ++x ) { - sprintf( pbuf + x * 4, format_8_bit(), - readbyte_internal( addr + x ) ); - if( x < 7 ) - strcat( pbuf, " " ); - } - widget_printstring_fixed( LC(7), LR(y), 7, pbuf ); - } -} - - -static void display_text( void ) -{ - int x, y; - char pbuf[8]; - - for( y = 0; y < 8; ++y ) { - libspectrum_word addr = debugger_memaddr + y * 32; - - sprintf( pbuf, format_16_bit(), addr ); - widget_printstring_fixed( LC(1), LR(y), 7, pbuf ); - widget_printstring( LC(6), LR(y), 5, ":" ); - - for( x = 0; x < 32; ++x ) - widget_printchar_fixed( LC(x + 8), LR(y), 7, - readbyte_internal( addr + x ) ); - } -} - - -static void display_disasm( void ) -{ - int y; - char pbuf[40]; - libspectrum_word addr = debugger_memaddr; - - for( y = 0; y < 8; ++y ) { - size_t length; - char *spc; - - sprintf( pbuf, format_16_bit(), addr ); - widget_printstring_fixed( LC(1), LR(y), 7, pbuf ); - widget_printstring( LC(6), LR(y), 5, ":" ); - - debugger_disassemble( pbuf, sizeof( pbuf ), &length, addr ); - addr += length; - spc = strchr( pbuf, ' ' ); - if( spc ) - *spc = 0; - widget_printstring( LC(8), LR(y), 7, pbuf ); - if( spc ) { - spc += 1 + strspn( spc + 1, " " ); - widget_printstring( LC(12) + 4, LR(y), 7, spc ); - } - } -} - - -static void display_breakpts( void ) -{ - GSList *ptr; - int i = -breakpt_show; - char pbuf[80], fmt[20]; - - if( i ) - widget_up_arrow( LC(0), LR(0), 7 ); - - for( ptr = debugger_breakpoints; i < 8 && ptr; ptr = ptr->next, ++i ) { - const debugger_breakpoint *bp = ptr->data; - - if( i < 0 ) - continue; - - sprintf( pbuf, "%lu", ( unsigned long )bp->id ); - widget_printstring( LC(1), LR(i), 5, pbuf ); - widget_printstring( LC(6), LR(i), 7, - debugger_breakpoint_type_abbr[bp->type] ); - - switch ( bp->type ) { - case DEBUGGER_BREAKPOINT_TYPE_EXECUTE: - case DEBUGGER_BREAKPOINT_TYPE_READ: - case DEBUGGER_BREAKPOINT_TYPE_WRITE: - if( bp->value.address.source == memory_source_any ) - sprintf( pbuf, format_16_bit(), bp->value.address.offset ); - else { - snprintf( fmt, sizeof( fmt ), "%%s:%s:%s", format_16_bit(), - format_16_bit() ); - snprintf( pbuf, sizeof( pbuf ), fmt, - memory_source_description( bp->value.address.source ), - bp->value.address.page, bp->value.address.offset ); - } - break; - - case DEBUGGER_BREAKPOINT_TYPE_PORT_READ: - case DEBUGGER_BREAKPOINT_TYPE_PORT_WRITE: - sprintf( fmt, "%s:%s", format_16_bit(), format_16_bit() ); - sprintf( pbuf, fmt, bp->value.port.mask, bp->value.port.port ); - break; - - case DEBUGGER_BREAKPOINT_TYPE_TIME: - sprintf( pbuf, "%5d", bp->value.time.tstates ); - break; - - case DEBUGGER_BREAKPOINT_TYPE_EVENT: - sprintf( pbuf, "%s:%s", bp->value.event.type, bp->value.event.detail ); - break; - } - widget_printstring( LC(10), LR(i), 6, pbuf ); - - sprintf( pbuf, "%lu", ( unsigned long )bp->ignore ); - widget_printstring( LC(18) + 4, LR(i), 7, pbuf ); - - sprintf( pbuf, "%s", debugger_breakpoint_life_abbr[bp->life] ); - widget_printstring( LC(23), LR(i), 7, pbuf ); - - if( bp->condition ) { - debugger_expression_deparse( pbuf, sizeof( pbuf ), bp->condition ); - widget_printstring( LC(28) + 4, LR(i), 6, pbuf ); - } - } - - if( !i ) - widget_printstring( LC(1), LR(0), 5, "(No breakpoints)" ); - else if( ptr ) - widget_down_arrow( LC(0), LC(7), 7 ); -} - - -static void scroll( int step ) -{ - switch ( display ) { - case DB_BYTES: - debugger_memaddr += 8 * step; - break; - - case DB_TEXT: - debugger_memaddr += 32 * step; - break; - - case DB_DISASM: - if( step > 0 ) - for( ; step; --step ) { - size_t length; - - debugger_disassemble( NULL, 0, &length, debugger_memaddr ); - debugger_memaddr += length; - } else - for( ; step; ++step ) { - /* For details, see ui/gtk/debugger.c:move_disassembly() */ - size_t i, longest = 1; - - for( i = 1; i <= 8; ++i ) { - size_t length; - - debugger_disassemble( NULL, 0, &length, debugger_memaddr ); - if( length == i ) - longest = i; - } - debugger_memaddr -= longest; - } - break; - - case DB_BREAKPT: - { - int length = g_slist_length( debugger_breakpoints ); - - breakpt_no += step; - if( breakpt_no >= length ) - breakpt_no = length - 1; - if( breakpt_no < 0 ) - breakpt_no = 0; - if( breakpt_no < breakpt_show ) - breakpt_show = breakpt_no; - else if( breakpt_no > breakpt_show + 7 ) - breakpt_show = breakpt_no - 7; - } - break; - - default: - return; - } - - widget_debugger_draw( NULL ); -} diff --git a/fuse/ui/widget/error.c b/fuse/ui/widget/error.c deleted file mode 100644 index 6d9eb0f..0000000 --- a/fuse/ui/widget/error.c +++ /dev/null @@ -1,182 +0,0 @@ -/* error.c: The error reporting widget - Copyright (c) 2002-2005 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include -#include - -#include "fuse.h" -#include "widget_internals.h" - -widget_error_t *error_info; - -int -ui_error_specific( ui_error_level severity, const char *message ) -{ - widget_error_t error_info; - /* Can't output widgets if we don't have a display yet */ - if( !display_ui_initialised ) return 0; - - - error_info.severity = severity; - error_info.message = message; - - fuse_emulation_pause(); - widget_do_error( &error_info ); - fuse_emulation_unpause(); - - return 0; -} - -int widget_error_draw( void *data ) -{ - char **lines; size_t count; - size_t i; - - error_info = (widget_error_t*)data; - if( split_message( error_info->message, &lines, &count, 28 ) ) return 1; - - widget_dialog_with_border( 1, 2, 30, count+2 ); - - switch( error_info->severity ) { - case UI_ERROR_INFO: - widget_printstring( 10, 16, WIDGET_COLOUR_TITLE, "Info" ); - break; - case UI_ERROR_WARNING: - widget_printstring( 10, 16, WIDGET_COLOUR_TITLE, "Warning" ); - break; - case UI_ERROR_ERROR: - widget_printstring( 10, 16, WIDGET_COLOUR_TITLE, "Error" ); - break; - default: - widget_printstring( 10, 16, WIDGET_COLOUR_TITLE, "(Unknown message)" ); - break; - } - - for( i=0; i= line_length ) - message++; - - /* Check we've got room for the word, plus some prefixing space */ - if( position + widget_substringwidth( message, ptr - message ) + 4 - >= line_length ) { - - char **new_lines; size_t i; - - /* If we've filled the screen, stop */ - if( *count == 18 ) return 0; - - new_lines = realloc( (*lines), (*count + 1) * sizeof( char* ) ); - if( new_lines == NULL ) { - for( i=0; i<*count; i++ ) free( (*lines)[i] ); - if(*lines) free( (*lines) ); - return 1; - } - (*lines) = new_lines; - - (*lines)[*count] = malloc( (line_length+1) ); - if( (*lines)[*count] == NULL ) { - for( i=0; i<*count; i++ ) free( (*lines)[i] ); - free( (*lines) ); - return 1; - } - - strncpy( (*lines)[*count], message, ptr - message ); - position = widget_substringwidth( message, ptr - message ); - (*lines)[*count][ptr - message] = '\0'; - - (*count)++; - - } else { /* Enough room on this line */ - - strcat( (*lines)[*count-1], " " ); - (*lines)[*count-1][strlen( (*lines)[*count-1] ) + ptr - message] = '\0'; - strncat( (*lines)[*count-1], message, ptr - message ); - position += widget_substringwidth( message, ptr - message ) + 4; - - } - - } - - return 0; -} - -void -widget_error_keyhandler( input_key key ) -{ - switch( key ) { - - case INPUT_KEY_Escape: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - return; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - widget_end_widget( WIDGET_FINISHED_OK ); - return; - - default: /* Keep gcc happy */ - break; - - } -} diff --git a/fuse/ui/widget/filesel.c b/fuse/ui/widget/filesel.c deleted file mode 100644 index 045a06c..0000000 --- a/fuse/ui/widget/filesel.c +++ /dev/null @@ -1,1023 +0,0 @@ -/* filesel.c: File selection dialog box - Copyright (c) 2001-2015 Matan Ziv-Av, Philip Kendall, Russell Marks, - Marek Januszewski - Copyright (c) 2015 Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include -#include - -#include -#include -#include -#include -#include -#ifdef HAVE_STRINGS_STRCASECMP -#include -#endif /* #ifdef HAVE_STRINGS_STRCASECMP */ -#include -#include - -#ifdef WIN32 -#include -#include -#include -#endif /* #ifdef WIN32 */ - -#include "fuse.h" -#include "ui/ui.h" -#include "utils.h" -#include "widget_internals.h" - -#if defined AMIGA || defined __MORPHOS__ -#include -#include -#include - -struct Library *AslBase; - -#ifndef __MORPHOS__ -struct AslIFace *IAsl; -struct Library *DOSBase; -#endif /* #ifndef __MORPHOS__ */ - -#ifndef __MORPHOS__ -struct DOSIFace *IDOS; -struct Library *ExecBase; -#endif /* #ifndef __MORPHOS__ */ - - -int err = 0; - -char *amiga_asl( char *title, BOOL is_saving ); - -#endif /* ifdef AMIGA */ - -#ifdef __PS3__ -#include -#define chdir(a) 0 -#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) -#endif - -struct widget_dirent **widget_filenames; /* Filenames in the current - directory */ -size_t widget_numfiles; /* The number of files in the current - directory */ - -static const char *title; -static int is_saving; - -#ifdef WIN32 -static int is_drivesel = 0; -static int is_rootdir; -#endif /* #ifdef WIN32 */ - -#define ENTRIES_PER_SCREEN (is_saving ? 32 : 36) - -/* The number of the filename in the top-left corner of the current - display, that of the filename which the `cursor' is on, and that - which it will be on after this keypress */ -static size_t top_left_file, current_file, new_current_file; - -static char *widget_get_filename( const char *title, int saving ); - -static int widget_add_filename( int *allocated, int *number, - struct widget_dirent ***namelist, - const char *name ); -static void widget_scan( char *dir ); -static int widget_select_file( const char *name ); -static int widget_scan_compare( const widget_dirent **a, - const widget_dirent **b ); - -#if !defined AMIGA && !defined __MORPHOS__ -static char* widget_getcwd( void ); -#endif /* ifndef AMIGA */ -static int widget_print_all_filenames( struct widget_dirent **filenames, int n, - int top_left, int current, - const char *dir ); -static int widget_print_filename( struct widget_dirent *filename, int position, - int inverted ); -#ifdef WIN32 -static void widget_filesel_chdrv( void ); -static void widget_filesel_drvlist( void ); -#endif /* #ifdef WIN32 */ -static int widget_filesel_chdir( void ); - -/* The filename to return */ -char* widget_filesel_name; - -/* Should we exit all widgets when we're done with this selector? */ -static int exit_all_widgets; - -static char * -widget_get_filename( const char *title, int saving ) -{ - char *filename = NULL; - - widget_filesel_data data; - - data.exit_all_widgets = 1; - data.title = title; - - if( saving ) { - widget_do_fileselector_save( &data ); - } else { - widget_do_fileselector( &data ); - } - if( widget_filesel_name ) - filename = utils_safe_strdup( widget_filesel_name ); - - return filename; - -} - -char * -ui_get_open_filename( const char *title ) -{ -#if !defined AMIGA && !defined __MORPHOS__ - return widget_get_filename( title, 0 ); -#else - return amiga_asl( title, FALSE ); -#endif -} - -char * -ui_get_save_filename( const char *title ) -{ -#if !defined AMIGA && !defined __MORPHOS__ - return widget_get_filename( title, 1 ); -#else - return amiga_asl( title, TRUE ); -#endif -} - -static int widget_add_filename( int *allocated, int *number, - struct widget_dirent ***namelist, - const char *name ) { - int i; size_t length; - - if( ++*number > *allocated ) { - struct widget_dirent **oldptr = *namelist; - - *namelist = realloc( (*namelist), 2 * *allocated * sizeof(**namelist) ); - if( *namelist == NULL ) { - for( i=0; i<*number-1; i++ ) { - free( oldptr[i]->name ); - free( oldptr[i] ); - } - free( oldptr ); - return -1; - } - *allocated *= 2; - } - - (*namelist)[*number-1] = malloc( sizeof(***namelist) ); - if( !(*namelist)[*number-1] ) { - for( i=0; i<*number-1; i++ ) { - free( (*namelist)[i]->name ); - free( (*namelist)[i] ); - } - free( *namelist ); - *namelist = NULL; - return -1; - } - - length = strlen( name ) + 1; - if( length < 16 ) length = 16; - - (*namelist)[*number-1]->name = malloc( length ); - if( !(*namelist)[*number-1]->name ) { - free( (*namelist)[*number-1] ); - for( i=0; i<*number-1; i++ ) { - free( (*namelist)[i]->name ); - free( (*namelist)[i] ); - } - free( *namelist ); - *namelist = NULL; - return -1; - } - - strncpy( (*namelist)[*number-1]->name, name, length ); - (*namelist)[*number-1]->name[ length - 1 ] = 0; - - return 0; -} - -#if defined AMIGA || defined __MORPHOS__ -char * -amiga_asl( char *title, BOOL is_saving ) { - char *filename; - struct FileRequester *filereq; - -#ifndef __MORPHOS__ - if( AslBase = IExec->OpenLibrary( "asl.library", 52 ) ) { - if( IAsl = ( struct AslIFace * ) IExec->GetInterface( AslBase,"main",1,NULL ) ) { - filereq = IAsl->AllocAslRequestTags( ASL_FileRequest, - ASLFR_RejectIcons,TRUE, - ASLFR_TitleText,title, - ASLFR_DoSaveMode,is_saving, - ASLFR_InitialPattern,"#?.(sna|z80|szx|sp|snp|zxs|tap|tzx|csw|rzx|dsk|trd|scl|mdr|dck|hdf|rom|psg|scr|mlt|png|gz|bz2)", - ASLFR_DoPatterns,TRUE, - TAG_DONE ); - if( err = IAsl->AslRequest( filereq, NULL ) ) { - filename = ( STRPTR ) IExec->AllocVec( 1024, MEMF_CLEAR ); -#else /* #ifndef __MORPHOS__ */ - if( AslBase = OpenLibrary( "asl.library", 0 ) ) { - filereq = AllocAslRequestTags( ASL_FileRequest, - ASLFR_RejectIcons,TRUE, - ASLFR_TitleText,title, - ASLFR_DoSaveMode,is_saving, - ASLFR_InitialPattern,"#?.(sna|z80|szx|sp|snp|zxs|tap|tzx|csw|rzx|dsk|trd|scl|mdr|dck|hdf|rom|psg|scr|mlt|png|gz|bz2)", - ASLFR_DoPatterns,TRUE, - TAG_DONE ); - if( err = AslRequest( filereq, NULL ) ) { - filename = ( STRPTR ) AllocVec( 1024, MEMF_CLEAR ); -#endif /* #ifndef __MORPHOS__ */ - - strcpy( filename,filereq->fr_Drawer ); -#ifndef __MORPHOS__ - IDOS->AddPart( filename, filereq->fr_File, 1024 ); -#else /* #ifndef __MORPHOS__ */ - AddPart( filename, filereq->fr_File, 1024 ); -#endif /* #ifndef __MORPHOS__ */ - widget_filesel_name = utils_safe_strdup( filename ); -#ifndef __MORPHOS__ - IExec->FreeVec( filename ); -#else /* #ifndef __MORPHOS__ */ - FreeVec( filename ); -#endif /* #ifndef __MORPHOS__ */ - err = WIDGET_FINISHED_OK; - } else { - err = WIDGET_FINISHED_CANCEL; - } -#ifndef __MORPHOS__ - IExec->DropInterface( ( struct Interface * )IAsl ); - } - IExec->CloseLibrary( AslBase ); -#else /* #ifndef __MORPHOS__ */ - CloseLibrary( AslBase ); -#endif /* #ifndef __MORPHOS__ */ - } - return widget_filesel_name; -} -#else /* ifdef AMIGA */ - -static int widget_scandir( const char *dir, struct widget_dirent ***namelist, - int (*select_fn)(const char*) ) -{ - compat_dir directory; - - int allocated, number; - int i; - int done = 0; - - *namelist = malloc( 32 * sizeof(**namelist) ); - if( !*namelist ) return -1; - - allocated = 32; number = 0; - - directory = compat_opendir( dir ); - if( !directory ) { - free( *namelist ); - *namelist = NULL; - return -1; - } - -#ifdef WIN32 - /* Assume this is the root directory, unless we find an entry named ".." */ - is_rootdir = 1; -#endif /* #ifdef WIN32 */ - - while( !done ) { - char name[ PATH_MAX ]; - - compat_dir_result_t result = - compat_readdir( directory, name, sizeof( name ) ); - - switch( result ) - { - case COMPAT_DIR_RESULT_OK: - if( select_fn( name ) ) { -#ifdef WIN32 - if( is_rootdir && !strcmp( name, ".." ) ) { - is_rootdir = 0; - } -#endif /* #ifdef WIN32 */ - if( widget_add_filename( &allocated, &number, namelist, name ) ) { - compat_closedir( directory ); - return -1; - } - } - break; - - case COMPAT_DIR_RESULT_END: - done = 1; - break; - - case COMPAT_DIR_RESULT_ERROR: - for( i=0; iname ); - free( (*namelist)[i] ); - } - free( *namelist ); - *namelist = NULL; - compat_closedir( directory ); - return -1; - } - - } - - if( compat_closedir( directory ) ) { - for( i=0; iname ); - free( (*namelist)[i] ); - } - free( *namelist ); - *namelist = NULL; - return -1; - } - -#ifdef WIN32 - if( is_rootdir ) { - /* Add a fake ".." entry for drive selection */ - if( widget_add_filename( &allocated, &number, namelist, ".." ) ) { - return -1; - } - } -#endif /* #ifdef WIN32 */ - - return number; -} - -#ifdef WIN32 -static int widget_scandrives( struct widget_dirent ***namelist ) -{ - int allocated, number; - unsigned long drivemask; - int i; - char drive[3]; - const char *driveletters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - - drive[1] = ':'; - drive[2] = '\0'; - - *namelist = malloc( 32 * sizeof(**namelist) ); - if( !*namelist ) return -1; - - allocated = 32; number = 0; - - drivemask = _getdrives(); - if( !drivemask ) { - free( *namelist ); - *namelist = NULL; - return -1; - } - - for( i = 0; i < 26; i++ ) { - if( drivemask & 1) { - drive[0] = driveletters[i]; - if( widget_add_filename( &allocated, &number, namelist, drive ) ) { - return -1; - } - } - drivemask >>= 1; - } - - return number; -} -#endif - -static void widget_scan( char *dir ) -{ - size_t i; - - /* Free the memory belonging to the files in the previous directory */ - for( i=0; iname ); - free( widget_filenames[i] ); - } - -#ifdef WIN32 - if( dir ) { - widget_numfiles = widget_scandir( dir, &widget_filenames, - widget_select_file ); - } else { - widget_numfiles = widget_scandrives( &widget_filenames ); - } -#else /* #ifdef WIN32 */ - widget_numfiles = widget_scandir( dir, &widget_filenames, - widget_select_file ); -#endif /* #ifdef WIN32 */ - - if( widget_numfiles == (size_t)-1 ) return; - - for( i=0; imode = - path_is_directory( widget_filenames[i]->name ) ? S_IFDIR : 0; - } - - qsort( widget_filenames, widget_numfiles, sizeof(struct widget_dirent*), - (int(*)(const void*,const void*))widget_scan_compare ); - -} - -static int -widget_select_file( const char *name ) -{ - if( !name ) return 0; - - /* Skip current directory */ - if( !strcmp( name, "." ) ) return 0; - -#ifndef WIN32 - /* Skip hidden files/directories */ - if( strlen( name ) > 1 && name[0] == '.' && name[1] != '.' ) return 0; -#endif /* #ifdef WIN32 */ - - return 1; -} - -static int widget_scan_compare( const struct widget_dirent **a, - const struct widget_dirent **b ) -{ - int isdir1 = S_ISDIR( (*a)->mode ), - isdir2 = S_ISDIR( (*b)->mode ); - - if( isdir1 && !isdir2 ) { - return -1; - } else if( isdir2 && !isdir1 ) { - return 1; - } else { - return strcmp( (*a)->name, (*b)->name ); - } - -} -#endif /* ifdef AMIGA */ - -/* File selection widget */ - -static int -widget_filesel_draw( void *data ) -{ - widget_filesel_data *filesel_data = data; - char *directory; - int error; - - exit_all_widgets = filesel_data->exit_all_widgets; - title = filesel_data->title; - -#if !defined AMIGA && !defined __MORPHOS__ -#ifdef WIN32 - if( !is_drivesel ) { - directory = widget_getcwd(); - if( directory == NULL ) return 1; - } else { - directory = NULL; - } -#else /* #ifdef WIN32 */ - directory = widget_getcwd(); - if( directory == NULL ) return 1; -#endif /* #ifdef WIN32 */ - - widget_scan( directory ); - new_current_file = current_file = 0; - top_left_file = 0; - - /* Create the dialog box */ - error = widget_dialog_with_border( 1, 2, 30, 22 ); - if( error ) { - free( directory ); - return error; - } - -#ifdef WIN32 - if( directory == NULL ) { - directory = utils_safe_strdup( "Drive selection" ); - } -#endif /* #ifdef WIN32 */ - - /* Show all the filenames */ - widget_print_all_filenames( widget_filenames, widget_numfiles, - top_left_file, current_file, directory ); - - free( directory ); - -#endif /* ifndef AMIGA */ - - return 0; -} - -int widget_filesel_finish( widget_finish_state finished ) { - - /* Return with null if we didn't finish cleanly */ - if( finished != WIDGET_FINISHED_OK ) { - if( widget_filesel_name ) free( widget_filesel_name ); - widget_filesel_name = NULL; - } - - return 0; -} - -int -widget_filesel_load_draw( void *data ) -{ - is_saving = 0; - return widget_filesel_draw( data ); -} - -int -widget_filesel_save_draw( void *data ) -{ - is_saving = 1; - return widget_filesel_draw( data ); -} - -#if !defined AMIGA && !defined __MORPHOS__ -static char* widget_getcwd( void ) -{ - char *directory; size_t directory_length; - char *ptr; - - directory_length = 64; - directory = malloc( directory_length * sizeof( char ) ); - if( directory == NULL ) { - return NULL; - } - - /* getcwd()/chdir() below stay on the host API: libretro's VFS has no - concept of a current working directory, and libretro-common exposes no - equivalent. This widget is the in-emulator file browser, which the - libretro build never presents - the frontend chooses content. */ - do { - ptr = getcwd( directory, directory_length ); - if( ptr ) break; - if( errno == ERANGE ) { - ptr = directory; - directory_length *= 2; - directory = - (char*)realloc( directory, directory_length * sizeof( char ) ); - if( directory == NULL ) { - free( ptr ); - return NULL; - } - } else { - free( directory ); - return NULL; - } - } while(1); - -#ifdef WIN32 - if( directory[0] && directory[1] == ':' ) { - directory[0] = toupper( directory[0] ); - } -#endif - - return directory; -} - -static int widget_print_all_filenames( struct widget_dirent **filenames, int n, - int top_left, int current, - const char *dir ) -{ - int i; - int error; - - /* Give us a clean box to start with */ - error = widget_dialog_with_border( 1, 2, 30, 22 ); - if( error ) return error; - - widget_printstring( 10, 16, WIDGET_COLOUR_TITLE, title ); - if( widget_stringwidth( dir ) > 223 ) { - char buffer[128]; - int prefix = widget_stringwidth( "..." ) + 1; - while( widget_stringwidth( dir ) > 223 - prefix ) dir++; - snprintf( buffer, sizeof( buffer ), "...%s", dir ); - widget_print_title( 24, WIDGET_COLOUR_FOREGROUND, buffer ); - } else { - widget_print_title( 24, WIDGET_COLOUR_FOREGROUND, dir ); - } - - if( top_left ) widget_up_arrow( 1, 5, WIDGET_COLOUR_FOREGROUND ); - - /* Print the filenames, mostly normally, but with the currently - selected file inverted */ - for( i = top_left; i < n && i < top_left + ENTRIES_PER_SCREEN; i++ ) { - if( i == current ) { - widget_print_filename( filenames[i], i-top_left, 1 ); - } else { - widget_print_filename( filenames[i], i-top_left, 0 ); - } - } - - if( is_saving ) - { - widget_printstring( 12, 22 * 8, WIDGET_COLOUR_FOREGROUND, - "\012RETURN\001 = select" ); - widget_printstring_right( 244, 22 * 8, WIDGET_COLOUR_FOREGROUND, - "\012TAB\001 = enter name" ); - } - - if( i < n ) - widget_down_arrow( 1, is_saving ? 20 : 22, WIDGET_COLOUR_FOREGROUND ); - - /* Display that lot */ - widget_display_lines( 2, 22 ); - - return 0; -} - -/* Print a filename onto the dialog box */ -static int widget_print_filename( struct widget_dirent *filename, int position, - int inverted ) -{ - char buffer[64], suffix[64], *dot = 0; - int width, suffix_width = 0; - int dir = S_ISDIR( filename->mode ); - int truncated = 0, suffix_truncated = 0; - -#define FILENAME_WIDTH 112 -#define MAX_SUFFIX_WIDTH 56 - - int x = (position & 1) ? 132 : 16, - y = 40 + (position >> 1) * 8; - - int foreground = WIDGET_COLOUR_FOREGROUND, - - background = inverted ? WIDGET_COLOUR_HIGHLIGHT - : WIDGET_COLOUR_BACKGROUND; - - widget_rectangle( x, y, FILENAME_WIDTH, 8, background ); - - strncpy( buffer, filename->name, sizeof( buffer ) - dir - 1); - buffer[sizeof( buffer ) - dir - 1] = '\0'; - - if (dir) - dir = widget_charwidth( FUSE_DIR_SEP_CHR ); - else { - /* get filename extension */ - dot = strrchr( filename->name, '.' ); - - /* if .gz or .bz2, we want the previous component too */ - if( dot &&( !strcasecmp( dot, ".gz" ) || !strcasecmp( dot, ".bz2" ) ) ) { - char *olddot = dot; - *olddot = '\0'; - dot = strrchr( filename->name, '.' ); - *olddot = '.'; - if (!dot) - dot = olddot; - } - - /* if the dot is at the start of the name, ignore it */ - if( dot == filename->name ) - dot = 0; - } - - if( dot ) { - /* split filename at extension separator */ - if( dot - filename->name < sizeof( buffer ) ) - buffer[dot - filename->name] = '\0'; - - /* get extension width (for display purposes) */ - snprintf( suffix, sizeof( suffix ), "%s", dot ); - while( ( suffix_width = ( dot && !dir ) - ? widget_stringwidth( suffix ) : 0 ) > 110 ) { - suffix_truncated = 1; - suffix[strlen( suffix ) - 1] = '\0'; - } - } - - while( ( width = widget_stringwidth( buffer ) ) >= - FILENAME_WIDTH - dir - ( dot ? truncated + suffix_width : 0 ) ) { - truncated = 2; - if( suffix_width >= MAX_SUFFIX_WIDTH ) { - suffix_truncated = 2; - suffix[strlen (suffix) - 1] = '\0'; - suffix_width = widget_stringwidth (suffix); - } - else - buffer[strlen (buffer) - 1] = '\0'; - } - if( dir ) - strcat (buffer, FUSE_DIR_SEP_STR ); - - widget_printstring( x + 1, y, foreground, buffer ); - if( truncated ) - widget_rectangle( x + width + 2, y, 1, 8, 4 ); - if( dot ) - widget_printstring( x + width + 2 + truncated, y, - foreground ^ 2, suffix ); - if( suffix_truncated ) - widget_rectangle( x + FILENAME_WIDTH, y, 1, 8, 4 ); - - return 0; -} -#endif /* ifndef AMIGA */ - -#ifdef WIN32 -static void -widget_filesel_chdrv( void ) -{ - char *fn; - - if( chdir( widget_filenames[ current_file ]->name ) ) { - ui_error( UI_ERROR_ERROR, "Could not change directory" ); - return; - } - - is_drivesel = 0; - fn = widget_getcwd(); - widget_scan( fn ); free( fn ); - new_current_file = 0; - /* Force a redisplay of all filenames */ - current_file = 1; top_left_file = 1; -} - -static void -widget_filesel_drvlist( void ) -{ - is_drivesel = 1; - widget_scan( NULL ); - new_current_file = 0; - /* Force a redisplay of all filenames */ - current_file = 1; top_left_file = 1; -} -#endif /* #ifdef WIN32 */ - -static int -widget_filesel_chdir( void ) -{ - char *fn, *ptr; - - /* Get the new directory name */ - fn = widget_getcwd(); - if( fn == NULL ) { - widget_end_widget( WIDGET_FINISHED_CANCEL ); - return 1; - } - ptr = fn; - fn = realloc( fn, - ( strlen( fn ) + 1 + strlen( widget_filenames[ current_file ]->name ) + - 1 ) * sizeof(char) - ); - if( fn == NULL ) { - free( ptr ); - widget_end_widget( WIDGET_FINISHED_CANCEL ); - return 1; - } -#ifndef GEKKO - /* Wii getcwd() already has the slash on the end */ - strcat( fn, FUSE_DIR_SEP_STR ); -#endif /* #ifndef GEKKO */ - strcat( fn, widget_filenames[ current_file ]->name ); - -/* -in Win32 errno resulting from chdir on file is EINVAL which may mean many things -this will not be fixed in mingw - must use native function instead -http://thread.gmane.org/gmane.comp.gnu.mingw.user/9197 -*/ - - if( chdir( fn ) == -1 ) { -#ifndef WIN32 - if( errno == ENOTDIR ) { -#else /* #ifndef WIN32 */ - if( GetFileAttributes( fn ) != FILE_ATTRIBUTE_DIRECTORY ) { -#endif /* #ifndef WIN32 */ - widget_filesel_name = fn; fn = NULL; - if( exit_all_widgets ) { - widget_end_all( WIDGET_FINISHED_OK ); - } else { - widget_end_widget( WIDGET_FINISHED_OK ); - } - } - } else { - widget_scan( fn ); - new_current_file = 0; - /* Force a redisplay of all filenames */ - current_file = 1; top_left_file = 1; - } - - free( fn ); - - return 0; -} - -void -widget_filesel_keyhandler( input_key key ) -{ -#if !defined AMIGA && !defined __MORPHOS__ - char *fn, *ptr; - char *dirtitle; -#endif - - /* If there are no files (possible on the Wii), can't really do anything */ - if( widget_numfiles == 0 ) { - if( key == INPUT_KEY_Escape ) widget_end_widget( WIDGET_FINISHED_CANCEL ); - return; - } - -#if defined AMIGA || defined __MORPHOS__ - if( exit_all_widgets ) { - widget_end_all( err ); - } else { - widget_end_widget( err ); - } -#else /* ifndef AMIGA */ - - new_current_file = current_file; - - switch(key) { - -#if 0 - case INPUT_KEY_Resize: /* Fake keypress used on window resize */ - widget_dialog_with_border( 1, 2, 30, 20 ); - widget_print_all_filenames( widget_filenames, widget_numfiles, - top_left_file, current_file ); - break; -#endif - - case INPUT_KEY_Escape: - case INPUT_JOYSTICK_FIRE_2: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - break; - - case INPUT_KEY_Left: - case INPUT_KEY_5: - case INPUT_KEY_h: - case INPUT_JOYSTICK_LEFT: - if( current_file > 0 ) new_current_file--; - break; - - case INPUT_KEY_Down: - case INPUT_KEY_6: - case INPUT_KEY_j: - case INPUT_JOYSTICK_DOWN: - if( current_file+2 < widget_numfiles ) new_current_file += 2; - break; - - case INPUT_KEY_Up: - case INPUT_KEY_7: /* Up */ - case INPUT_KEY_k: - case INPUT_JOYSTICK_UP: - if( current_file > 1 ) new_current_file -= 2; - break; - - case INPUT_KEY_Right: - case INPUT_KEY_8: - case INPUT_KEY_l: - case INPUT_JOYSTICK_RIGHT: - if( current_file < widget_numfiles-1 ) new_current_file++; - break; - - case INPUT_KEY_Page_Up: - new_current_file = ( current_file > ENTRIES_PER_SCREEN ) ? - current_file - ENTRIES_PER_SCREEN : - 0; - break; - - case INPUT_KEY_Page_Down: - new_current_file = current_file + ENTRIES_PER_SCREEN; - if( new_current_file >= widget_numfiles ) - new_current_file = widget_numfiles - 1; - break; - - case INPUT_KEY_Home: - new_current_file = 0; - break; - - case INPUT_KEY_End: - new_current_file = widget_numfiles - 1; - break; - - case INPUT_KEY_Tab: - if( is_saving ) { - widget_text_t text_data; - text_data.title = title; - text_data.allow = WIDGET_INPUT_ASCII; - text_data.max_length = 30; - text_data.text[0] = 0; - if( widget_do_text( &text_data ) || - !widget_text_text || !*widget_text_text ) - break; - if( !compat_is_absolute_path( widget_text_text ) ) { - /* relative name */ - /* Get current dir name and allocate space for the leafname */ - fn = widget_getcwd(); - ptr = fn; - if( fn ) - fn = realloc( fn, strlen( fn ) + strlen( widget_text_text ) + 2 ); - if( !fn ) { - free( ptr ); - widget_end_widget( WIDGET_FINISHED_CANCEL ); - return; - } - /* Append the leafname and return it */ - strcat( fn, FUSE_DIR_SEP_STR ); - strcat( fn, widget_text_text ); - } else { /* absolute name */ - fn = utils_safe_strdup( widget_text_text ); - } - widget_filesel_name = fn; - if( exit_all_widgets ) { - widget_end_all( WIDGET_FINISHED_OK ); - } else { - widget_end_widget( WIDGET_FINISHED_OK ); - } - } - break; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: -#ifdef WIN32 - if( is_drivesel ) { - widget_filesel_chdrv(); - } else if( is_rootdir && - !strcmp( widget_filenames[ current_file ]->name, ".." ) ) { - widget_filesel_drvlist(); - } else { -#endif /* #ifdef WIN32 */ - if( widget_filesel_chdir() ) return; -#ifdef WIN32 - } -#endif /* #ifdef WIN32 */ - break; - - default: /* Keep gcc happy */ - break; - - } - -#ifdef WIN32 - if( is_drivesel ) { - dirtitle = utils_safe_strdup( "Drive selection" ); - } else { -#endif /* #ifdef WIN32 */ - dirtitle = widget_getcwd(); -#ifdef WIN32 - } -#endif /* #ifdef WIN32 */ - - /* If we moved the cursor */ - if( new_current_file != current_file ) { - - /* If we've got off the top or bottom of the currently displayed - file list, then reset the top-left corner and display the whole - thing */ - if( new_current_file < top_left_file ) { - - top_left_file = new_current_file & ~1; - widget_print_all_filenames( widget_filenames, widget_numfiles, - top_left_file, new_current_file, dirtitle ); - - } else if( new_current_file >= top_left_file+ENTRIES_PER_SCREEN ) { - - top_left_file = new_current_file & ~1; - top_left_file -= ENTRIES_PER_SCREEN - 2; - widget_print_all_filenames( widget_filenames, widget_numfiles, - top_left_file, new_current_file, dirtitle ); - - } else { - - /* Otherwise, print the current file uninverted and the - new current file inverted */ - - widget_print_filename( widget_filenames[ current_file ], - current_file - top_left_file, 0 ); - - widget_print_filename( widget_filenames[ new_current_file ], - new_current_file - top_left_file, 1 ); - - widget_display_lines( 2, 21 ); - } - - /* Reset the current file marker */ - current_file = new_current_file; - - } - - free( dirtitle ); -#endif /* ifdef AMIGA */ -} diff --git a/fuse/ui/widget/fuse.font.sbf b/fuse/ui/widget/fuse.font.sbf deleted file mode 100644 index 65d04f0..0000000 --- a/fuse/ui/widget/fuse.font.sbf +++ /dev/null @@ -1,2232 +0,0 @@ -# . = reset pixel -# 0 = set pixel -# X = no whitespace on right (end of first line only) (not yet implemented) -# -# Left-hand whitespace must be preserved for codes U+0000 through U+007E -# (except U+0060) and for U+00A3 and U+00A9; additionally, these characters -# must be no more than 8 pixels wide. -# -# Other characters do not have left-hand white space, and may be up to 15 -# pixels wide. - -[U+0000] -. -...000 -..0..00 -..0.0.0 -..00..0 -...000 -. -.000000 - -[U+0001] -. -...00 -..0.0 -....0 -....0 -..00000 -. -.000000 - -[U+0002] -. -..0000 -......0 -...000 -..0 -..00000 -. -.000000 - -[U+0003] -. -...000 -..0...0 -....00 -..0...0 -...000 -. -.000000 - -[U+0004] -. -....0 -...00 -..0.0 -..00000 -....0 -. -.000000 - -[U+0005] -. -..00000 -..0 -..0000 -......0 -..0000 -. -.000000 - -[U+0006] -. -...000 -..0 -..0000 -..0...0 -...000 -. -.000000 - -[U+0007] -. -..00000 -......0 -.....0 -....0 -....0 -. -.000000 - -[U+0008] -. -....0 -...0 -..00000 -...0 -....0 -. -.000000 - -[U+0009] -. -....0 -.....0 -..00000 -.....0 -....0 -. -.000000 - -[U+000A] -. -....0 -....0 -..0.0.0 -...000 -....0 -. -.000000 - -[U+000B] -. -....0 -...000 -..0.0.0 -....0 -....0 -. -.000000 - -[U+000C] -. -....0 -...00 -..00000 -...00 -....0 -. -.000000 - -[U+000D] -. -......0 -......0 -...0..0 -..0000 -...0 -. -.000000 - -[U+000E] -. -.....0 -....0.0 -....00 -....0 -..0..00 -. -.000000 - -[U+000F] -. -.....00 -....0 -....00 -....0 -..0.0 -. -.000000 - -[U+0010] -. -..00000 -....0 -....0 -....0 -..00000 -. -.000000 - -[U+0011] -. -..0000 -..0...0 -..0000 -..0 -..0 -. -.000000 - -[U+0012] -. -..00000 -..0 -..0000 -..0 -..0 -. -.000000 - -[U+0013] -. -..0000 -..0...0 -..0000 -..0...0 -..0000 -. -.000000 - -[U+0014] -. -..0...0 -..00.00 -..00.00 -..00.00 -..0...0 -. -.000000 - -[U+0015] -. -...000 -..0...0 -..0...0 -..0...0 -...000 -. -.000000 - -[U+0016] -. -...000 -..0.000 -..0.000 -..0 -...000 -. -.000000 - -[U+0017] -. -...0..0 -....0.0 -..00000 -....0.0 -...0..0 -. -.000000 - -[U+0018] -. -..0..0 -.00.0.0 -..0..0 -..0.0.0 -..0..0 -. -.000000 - -[U+0019] -. -..0..0 -.00.0.0 -..0..00 -..0...0 -..0.00 -. -.000000 - -[U+001A] -. -..0.00 -.00...0 -..0..00 -..0.0.0 -..0..00 -. -.000000 - -[U+001B] -. -..0.0 -.00.0 -..0.00 -..0.0.0 -..0.00 -. -.000000 - -[U+001C] -. -..0 -.00..00 -..0.0 -..0.0 -..0..00 -. -.000000 - -[U+001D] -. -..0...0 -.00...0 -..0..00 -..0.0.0 -..0..00 -. -.000000 - -[U+001E] -. -..0..0 -.00.0.0 -..0.00 -..0.0 -..0..00 -. -.000000 - -[U+001F] -. -..0..00 -.00.0 -..0.00 -..0.0 -..0.0 -. -.000000 - -[U+0020] -[U+00A0] -. -. -. -. -. -. -. -. - -[U+0021] -. -...0 -...0 -...0 -...0 -. -...0 -. - -[U+0022] -. -..0..0 -..0..0 -. -. -. -. -. - -[U+0023] -. -..0..0 -.000000 -..0..0 -..0..0 -.000000 -..0..0 -. - -[U+0024] -. -....0 -..00000 -..0.0 -..00000 -....0.0 -..00000 -....0 - -[U+0025] -. -.00...0 -.00..0 -....0 -...0 -..0..00 -.0...00 -. - -[U+0026] -. -...0 -..0.0 -...0 -..0.0.0 -.0...0 -..000.0 -. - -[U+0027] -. -....0 -...0 -. -. -. -. -. - -[U+0028] -. -.....0 -....0 -....0 -....0 -....0 -.....0 -. - -[U+0029] -. -..0 -...0 -...0 -...0 -...0 -..0 -. - -[U+002A] -. -. -...0.0 -....0 -..00000 -....0 -...0.0 -. - -[U+002B] -. -. -....0 -....0 -..00000 -....0 -....0 -. - -[U+002C] -. -. -. -. -. -....0 -....0 -...0 - -[U+002D] -. -. -. -. -..00000 -. -. -. - -[U+002E] -. -. -. -. -. -...00 -...00 -. - -[U+002F] -. -. -......0 -.....0 -....0 -...0 -..0 -. - -[U+0030] -. -..0000 -.0...00 -.0..0.0 -.0.0..0 -.00...0 -..0000 -. - -[U+0031] -. -...00 -..0.0 -....0 -....0 -....0 -..00000 -. - -[U+0032] -. -..0000 -.0....0 -......0 -..0000 -.0 -.000000 -. - -[U+0033] -. -..0000 -.0....0 -....00 -......0 -.0....0 -..0000 -. - -[U+0034] -. -....0 -...00 -..0.0 -.0..0 -.000000 -....0 -. - -[U+0035] -. -.000000 -.0 -.00000 -......0 -.0....0 -..0000 -. - -[U+0036] -. -..0000 -.0 -.00000 -.0....0 -.0....0 -..0000 -. - -[U+0037] -. -.000000 -......0 -.....0 -....0 -...0 -...0 -. - -[U+0038] -. -..0000 -.0....0 -..0000 -.0....0 -.0....0 -..0000 -. - -[U+0039] -. -..0000 -.0....0 -.0....0 -..00000 -......0 -..0000 -. - -[U+003A] -. -. -. -...0 -. -. -...0 -. - -[U+003B] -. -. -...0 -. -. -...0 -...0 -..0 - -[U+003C] -. -. -.....0 -....0 -...0 -....0 -.....0 -. - -[U+003D] -. -. -. -..00000 -. -..00000 -. -. - -[U+003E] -. -. -...0 -....0 -.....0 -....0 -...0 -. - -[U+003F] -. -..0000 -.0....0 -.....0 -....0 -. -....0 -. - -[U+0040] -. -..0000 -.0..0.0 -.0.0.00 -.0.0000 -.0 -..0000 -. - -[U+0041] -. -..0000 -.0....0 -.0....0 -.000000 -.0....0 -.0....0 -. - -[U+0042] -. -.00000 -.0....0 -.00000 -.0....0 -.0....0 -.00000 -. - -[U+0043] -. -..0000 -.0....0 -.0 -.0 -.0....0 -..0000 -. - -[U+0044] -. -.0000 -.0...0 -.0....0 -.0....0 -.0...0 -.0000 -. - -[U+0045] -. -.000000 -.0 -.00000 -.0 -.0 -.000000 -. - -[U+0046] -. -.000000 -.0 -.00000 -.0 -.0 -.0 -. - -[U+0047] -. -..0000 -.0....0 -.0 -.0..000 -.0....0 -..0000 -. - -[U+0048] -. -.0....0 -.0....0 -.000000 -.0....0 -.0....0 -.0....0 -. - -[U+0049] -. -..00000 -....0 -....0 -....0 -....0 -..00000 -. - -[U+004A] -. -......0 -......0 -......0 -.0....0 -.0....0 -..0000 -. - -[U+004B] -. -.0...0 -.0..0 -.000 -.0..0 -.0...0 -.0....0 -. - -[U+004C] -. -.0 -.0 -.0 -.0 -.0 -.000000 -. - -[U+004D] -. -.0....0 -.00..00 -.0.00.0 -.0....0 -.0....0 -.0....0 -. - -[U+004E] -. -.0....0 -.00...0 -.0.0..0 -.0..0.0 -.0...00 -.0....0 -. - -[U+004F] -. -..0000 -.0....0 -.0....0 -.0....0 -.0....0 -..0000 -. - -[U+0050] -. -.00000 -.0....0 -.0....0 -.00000 -.0 -.0 -. - -[U+0051] -. -..0000 -.0....0 -.0....0 -.0.0..0 -.0..0.0 -..0000 -. - -[U+0052] -. -.00000 -.0....0 -.0....0 -.00000 -.0...0 -.0....0 -. - -[U+0053] -. -..0000 -.0 -..0000 -......0 -.0....0 -..0000 -. - -[U+0054] -. -0000000 -...0 -...0 -...0 -...0 -...0 -. - -[U+0055] -. -.0....0 -.0....0 -.0....0 -.0....0 -.0....0 -..0000 -. - -[U+0056] -. -.0....0 -.0....0 -.0....0 -.0....0 -..0..0 -...00 -. - -[U+0057] -. -.0....0 -.0....0 -.0....0 -.0....0 -.0.00.0 -..0..0 -. - -[U+0058] -. -.0....0 -..0..0 -...00 -...00 -..0..0 -.0....0 -. - -[U+0059] -. -0.....0 -.0...0 -..0.0 -...0 -...0 -...0 -. - -[U+005A] -. -.000000 -.....0 -....0 -...0 -..0 -.000000 -. - -[U+005B] -. -....000 -....0 -....0 -....0 -....0 -....000 -. - -[U+005C] -. -. -.0 -..0 -...0 -....0 -.....0 -. - -[U+005D] -. -.000 -...0 -...0 -...0 -...0 -.000 -. - -[U+005E] -. -...0 -..0.0 -.0...0 -. -. -. -. - -[U+005F] -. -. -. -. -. -. -. -00000000 - -[U+0060] -..0 -...0 -....0 -. -. -. -. -. - -[U+0061] -. -. -..000 -.....0 -..0000 -.0...0 -..0000 -. - -[U+0062] -. -..0 -..0 -..0000 -..0...0 -..0...0 -..0000 -. - -[U+0063] -. -. -...000 -..0 -..0 -..0 -...000 -. - -[U+0064] -. -.....0 -.....0 -..0000 -.0...0 -.0...0 -..0000 -. - -[U+0065] -. -. -..000 -.0...0 -.0000 -.0 -..0000 -. - -[U+0066] -. -....00 -...0 -...00 -...0 -...0 -...0 -. - -[U+0067] -. -. -..0000 -.0...0 -.0...0 -..0000 -.....0 -..000 - -[U+0068] -. -.0 -.0 -.0000 -.0...0 -.0...0 -.0...0 -. - -[U+0069] -. -...0 -. -..00 -...0 -...0 -..000 -. - -[U+006A] -. -.....0 -. -.....0 -.....0 -.....0 -..0..0 -...00 - -[U+006B] -. -..0 -..0.0 -..00 -..00 -..0.0 -..0..0 -. - -[U+006C] -. -...0 -...0 -...0 -...0 -...0 -....00 -. - -[U+006D] -. -. -.00.0 -.0.0.0 -.0.0.0 -.0.0.0 -.0.0.0 -. - -[U+006E] -. -. -.0000 -.0...0 -.0...0 -.0...0 -.0...0 -. - -[U+006F] -. -. -..000 -.0...0 -.0...0 -.0...0 -..000 -. - -[U+0070] -. -. -.0000 -.0...0 -.0...0 -.0000 -.0 -.0 - -[U+0071] -. -. -..0000 -.0...0 -.0...0 -..0000 -.....0 -.....00 - -[U+0072] -. -. -...000 -..0 -..0 -..0 -..0 -. - -[U+0073] -. -. -..000 -.0 -..000 -.....0 -.0000 -. - -[U+0074] -. -...0 -..000 -...0 -...0 -...0 -....00 -. - -[U+0075] -. -. -.0...0 -.0...0 -.0...0 -.0...0 -..000 -. - -[U+0076] -. -. -.0...0 -.0...0 -..0.0 -..0.0 -...0 -. - -[U+0077] -. -. -.0...0 -.0.0.0 -.0.0.0 -.0.0.0 -..0.0 -. - -[U+0078] -. -. -.0...0 -..0.0 -...0 -..0.0 -.0...0 -. - -[U+0079] -. -. -.0...0 -.0...0 -.0...0 -..0000 -.....0 -..000 - -[U+007A] -. -. -.00000 -....0 -...0 -..0 -.00000 -. - -[U+007B] -. -....000 -....0 -..00 -....0 -....0 -....000 -. - -[U+007C] -. -....0 -....0 -....0 -....0 -....0 -....0 -. - -[U+007D] -. -.000 -...0 -....00 -...0 -...0 -.000 -. - -[U+007E] -. -...0.0 -..0.0 -. -. -. -. -. - -[U+00A1] -. -. -0 -. -0 -0 -0 -0 - -[U+00A2] -. -..0 -.000 -0.0 -0.0 -0.0 -.000 -..0 - -[U+00A3] -. -..000 -.0...0 -0000 -.0 -.0 -000000 -. - -[U+00A4] -. -0...0 -.000 -0...0 -0...0 -.000 -0...0 -. - -[U+00A5] -. -0...0 -.0.0 -..0 -.000 -..0 -..0 -. - -[U+00A6] -. -0 -0 -0 -. -0 -0 -0 - -[U+00A7] -. -.000 -0 -.000 -0...0 -.000 -....0 -.000 - -[U+00A8] -00..00 -. -. -. -. -. -. -. - -[U+00A9] -..0000 -.0....0 -0..00..0 -0.0....0 -0.0....0 -0..00..0 -.0....0 -..0000 - -[U+00AA] -. -000 -..00 -00.0 -.000 -. -0000 -. - -[U+00AB] -. -..0...0 -.0...0 -0...0 -0...0 -.0...0 -..0...0 -. - -[U+00AC] -. -00000 -....0 -. -. -. -. -. - -[U+00AD] -. -. -. -00000 -. -. -. -. - -[U+00AE] -..0000 -.0....0 -0.000..0 -0.0..0.0 -0.000..0 -0.0..0.0 -.0....0 -..0000 - -[U+00AF] -. -00000 -. -. -. -. -. -. - -[U+00B0] -. -.00 -0..0 -.00 -. -. -. -. - -[U+00B1] -. -..0 -..0 -00000 -..0 -..0 -00000 -. - -[U+00B2] -. -000 -...0 -.00 -0000 -. -. -. - -[U+00B3] -. -0000 -..0 -...0 -000 -. -. -. - -[U+00B4] -.00 -00 -. -. -. -. -. -. - -[U+00B5] -. -. -.0...0 -.0...0 -.0...0 -.0...0 -.0000 -0 - -[U+00B6] -. -.....0 -.0000 -00..0 -00..0 -.0..0 -.0000 -. - -[U+00B7] -. -. -. -00 -00 -. -. -. - -[U+00B8] -. -. -. -. -. -. -.00 -00 - -[U+00B9] -. -.0 -00 -.0 -000 -. -. -. - -[U+00BA] -. -.00 -0..0 -0..0 -.00 -. -0000 -. - -[U+00BB] -. -0...0 -.0...0 -..0...0 -..0...0 -.0...0 -0...0 -. - -[U+00BC] -. -.0 -00 -.0.0 -.0.0.0 -...000 -.....0 -. - -[U+00BD] -. -.0 -00 -.0.00 -.0...0 -....0 -...000 -. - -[U+00BE] -. -000 -.0 -..0.0 -00..0.0 -....000 -......0 -. - -[U+00BF] -. -. -..0 -. -..0 -.0 -0....0 -.0000 - -[U+00C0] -..0 -...0 -.0000 -0....0 -000000 -0....0 -0....0 -. - -[U+00C1] -...0 -..0 -.0000 -0....0 -000000 -0....0 -0....0 -. - -[U+00C2] -..00 -00..00 -.0000 -0....0 -000000 -0....0 -0....0 -. - -[U+00C3] -..0.0 -.0.0 -.0000 -0....0 -000000 -0....0 -0....0 -. - -[U+00C4] -.0..0 -. -.0000 -0....0 -000000 -0....0 -0....0 -. - -[U+00C5] -..00 -.0..0 -.0000 -0....0 -000000 -0....0 -0....0 -. - -[U+00C6] -. -.00000000 -0...0 -0...0000 -00000 -0...0 -0...00000 -. - -[U+00C7] -. -.0000 -0....0 -0 -0 -0....0 -.0000 -00 - -[U+00C8] -..0 -...0 -000000 -0 -00000 -0 -000000 -. - -[U+00C9] -...0 -..0 -000000 -0 -00000 -0 -000000 -. - -[U+00CA] -..00 -00..00 -000000 -0 -00000 -0 -000000 -. - -[U+00CB] -.0..0 -. -000000 -0 -00000 -0 -000000 -. - -[U+00CC] -.0 -..0 -00000 -..0 -..0 -..0 -00000 -. - -[U+00CD] -...0 -..0 -00000 -..0 -..0 -..0 -00000 -. - -[U+00CE] -..0 -00.00 -00000 -..0 -..0 -..0 -00000 -. - -[U+00CF] -0...0 -. -00000 -..0 -..0 -..0 -00000 -. - -[U+00D0] -. -.0000 -.0...0 -0000..0 -.0....0 -.0...0 -.0000 -. - -[U+00D1] -..0.0 -.0.0 -00...0 -0.0..0 -0..0.0 -0...00 -0....0 -. - -[U+00D2] -..0 -...0 -.0000 -0....0 -0....0 -0....0 -.0000 -. - -[U+00D3] -...0 -..0 -.0000 -0....0 -0....0 -0....0 -.0000 -. - -[U+00D4] -..00 -00..00 -.0000 -0....0 -0....0 -0....0 -.0000 -. - -[U+00D5] -..0.0 -.0.0 -.0000 -0....0 -0....0 -0....0 -.0000 -. - -[U+00D6] -.0..0 -. -.0000 -0....0 -0....0 -0....0 -.0000 -. - -[U+00D7] -. -. -. -0.0 -.0 -0.0 -. -. - -[U+00D8] -.....0 -.0000 -0...00 -0..0.0 -0.0..0 -00...0 -.0000 -0 - -[U+00D9] -..0 -0..0.0 -0....0 -0....0 -0....0 -0....0 -.0000 -. - -[U+00DA] -...0 -0.0..0 -0....0 -0....0 -0....0 -0....0 -.0000 -. - -[U+00DB] -..00 -00..00 -. -0....0 -0....0 -0....0 -.0000 -. - -[U+00DC] -.0..0 -0....0 -0....0 -0....0 -0....0 -0....0 -.0000 -. - -[U+00DD] -....0 -0..0..0 -.0...0 -..0.0 -...0 -...0 -...0 -. - -[U+00DE] -. -000 -.0000 -.0...0 -.0000 -.0 -000 -. - -[U+00DF] -. -.0000 -0....0 -0.000 -0....0 -0....0 -0.000 -0 - -[U+00E0] -.0 -..0 -.000 -....0 -.0000 -0...0 -.0000 -. - -[U+00E1] -...0 -..0 -.000 -....0 -.0000 -0...0 -.0000 -. - -[U+00E2] -..0 -00.00 -.000 -....0 -.0000 -0...0 -.0000 -. - -[U+00E3] -..0.0 -.0.0 -.000 -....0 -.0000 -0...0 -.0000 -. - -[U+00E4] -.0.0 -. -.000 -....0 -.0000 -0...0 -.0000 -. - -[U+00E5] -.00 -0..0 -.000 -....0 -.0000 -0...0 -.0000 -. - -[U+00E6] -. -. -.00000 -...0..0 -.00000 -0..0 -.000000 -. - -[U+00E7] -. -. -.000 -0 -0 -0 -.000 -00 - -[U+00E8] -.0 -..0 -.000 -0...0 -0000 -0 -.0000 -. - -[U+00E9] -...0 -..0 -.000 -0...0 -0000 -0 -.0000 -. - -[U+00EA] -..0 -00.00 -.000 -0...0 -0000 -0 -.0000 -. - -[U+00EB] -.0.0 -. -.000 -0...0 -0000 -0 -.0000 -. - -[U+00EC] -0 -.0 -. -00 -.0 -.0 -000 -. - -[U+00ED] -..0 -.0 -. -00 -.0 -.0 -000 -. - -[U+00EE] -.0 -0.0 -. -00 -.0 -.0 -000 -. - -[U+00EF] -. -0.0 -. -00 -.0 -.0 -000 -. - -[U+00F0] -. -...0 -..0000 -....0 -.0000 -0...0 -.0000 -. - -[U+00F1] -..0.0 -.0.0 -. -0000 -0...0 -0...0 -0...0 -. - -[U+00F2] -.0 -..0 -. -.000 -0...0 -0...0 -.000 -. - -[U+00F3] -...0 -..0 -. -.000 -0...0 -0...0 -.000 -. - -[U+00F4] -..0 -00.00 -. -.000 -0...0 -0...0 -.000 -. - -[U+00F5] -..0.0 -.0.0 -. -.000 -0...0 -0...0 -.000 -. - -[U+00F6] -. -.0.0 -. -.000 -0...0 -0...0 -.000 -. - -[U+00F7] -. -. -..0 -. -00000 -. -..0 -. - -[U+00F8] -. -....0 -.000 -0..00 -0.0.0 -00..0 -.000 -0 - -[U+00F9] -.0 -..0 -. -0...0 -0...0 -0...0 -.000 -. - -[U+00FA] -...0 -..0 -. -0...0 -0...0 -0...0 -.000 -. - -[U+00FB] -..0 -00.00 -. -0...0 -0...0 -0...0 -.000 -. - -[U+00FC] -. -.0.0 -. -0...0 -0...0 -0...0 -.000 -. - -[U+00FD] -...0 -..0 -0...0 -0...0 -0...0 -.0000 -....0 -.000 - -[U+00FE] -. -0 -0 -0000 -0...0 -0000 -0 -0 - -[U+00FF] -.0.0 -. -0...0 -0...0 -0...0 -.0000 -....0 -.000 - diff --git a/fuse/ui/widget/memory.c b/fuse/ui/widget/memory.c deleted file mode 100644 index b7cae8f..0000000 --- a/fuse/ui/widget/memory.c +++ /dev/null @@ -1,99 +0,0 @@ -/* memory.c: memory browser widget - Copyright (c) 2004 Darren Salt - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: linux@youmustbejoking.demon.co.uk - -*/ - -#include - -#include -#include - -#include "compat.h" -#include "debugger/debugger.h" -#include "pokefinder/pokefinder.h" -#include "ui/ui.h" -#include "widget.h" -#include "widget_internals.h" - -static libspectrum_word memaddr = 0; - -#define LC(X) ( (X)*8 - DISPLAY_BORDER_ASPECT_WIDTH ) -#define LR(Y) ( (Y)*8 - DISPLAY_BORDER_HEIGHT ) - -int -widget_memory_draw( void *data ) -{ - int x, y; - char pbuf[36]; - - widget_rectangle( LC(0), LR(0), 40 * 8, 16 * 8 + 4, 1 ); - widget_rectangle( LC(0), LR(16) + 2, 320, 1, 7 ); - - for( y = 0; y < 16; ++y ) { - libspectrum_word addr = memaddr + y * 8; - - sprintf( pbuf, "%04X:", addr ); - widget_printstring_fixed( LC(1), LR(y), 5, pbuf ); - - for( x = 0; x < 8; ++x ) { - libspectrum_byte b = readbyte_internal( addr + x ); - - widget_printchar_fixed( LC(x + 30), LR(y), 7 - (y & 1), b ); - sprintf( pbuf + x * 3, "%02X ", b ); - } - widget_printstring_fixed( LC(6), LR(y), 7 - (y & 1), pbuf ); - } - - widget_display_lines( LR(0) / 8, 17 ); - - return 0; -} - -void -widget_memory_keyhandler( input_key key ) -{ - switch ( key ) { - case INPUT_KEY_Escape: /* Close widget */ - widget_end_widget( WIDGET_FINISHED_CANCEL ); - break; - - case INPUT_KEY_Return: /* Close widget */ - case INPUT_KEY_KP_Enter: - widget_end_all( WIDGET_FINISHED_OK ); - break; - - /* Address selection */ - case INPUT_KEY_Up: - memaddr -= 16; widget_memory_draw( NULL ); break; - case INPUT_KEY_Down: - memaddr += 16; widget_memory_draw( NULL ); break; - case INPUT_KEY_Page_Up: - memaddr -= 128; widget_memory_draw( NULL ); break; - case INPUT_KEY_Page_Down: - memaddr += 128; widget_memory_draw( NULL ); break; - case INPUT_KEY_Home: - memaddr = 0; widget_memory_draw( NULL ); break; - case INPUT_KEY_End: - memaddr = 0xFF80; widget_memory_draw( NULL ); break; - - default:; - } -} diff --git a/fuse/ui/widget/menu.c b/fuse/ui/widget/menu.c deleted file mode 100644 index 22e990e..0000000 --- a/fuse/ui/widget/menu.c +++ /dev/null @@ -1,788 +0,0 @@ -/* menu.c: general menu widget - Copyright (c) 2001-2015 Philip Kendall - Copyright (c) 2015 Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include - -#include "debugger/debugger.h" -#include "event.h" -#include "fuse.h" -#include "keyboard.h" -#include "machine.h" -#include "machines/specplus3.h" -#include "menu.h" -#include "peripherals/dck.h" -#include "peripherals/disk/beta.h" -#include "peripherals/joystick.h" -#include "psg.h" -#include "rzx.h" -#include "screenshot.h" -#include "settings.h" -#include "snapshot.h" -#include "tape.h" -#include "ui/uidisplay.h" -#include "utils.h" -#include "widget_internals.h" -#include "widget.h" - -widget_menu_entry *menu; -static size_t highlight_line = 0; -static size_t count; -static int *current_settings[ 16 ]; - -#define GET_SET_KEY_FUNCTIONS( which ) \ -\ -static void \ -set_key_for_button_ ## which ( int action ) \ -{ \ - *current_settings[ which ] = action; \ - widget_end_all( WIDGET_FINISHED_OK ); \ -} \ -\ -static const char* \ -get_key_name_for_button_ ## which ( void ) \ -{ \ - return keyboard_key_text( *current_settings[ which ] ); \ -} - -GET_SET_KEY_FUNCTIONS( 1 ) -GET_SET_KEY_FUNCTIONS( 2 ) -GET_SET_KEY_FUNCTIONS( 3 ) -GET_SET_KEY_FUNCTIONS( 4 ) -GET_SET_KEY_FUNCTIONS( 5 ) -#ifdef USE_JOYSTICK -GET_SET_KEY_FUNCTIONS( 6 ) -GET_SET_KEY_FUNCTIONS( 7 ) -GET_SET_KEY_FUNCTIONS( 8 ) -#ifndef GEKKO -GET_SET_KEY_FUNCTIONS( 9 ) -GET_SET_KEY_FUNCTIONS( 10 ) -GET_SET_KEY_FUNCTIONS( 11 ) -GET_SET_KEY_FUNCTIONS( 12 ) -GET_SET_KEY_FUNCTIONS( 13 ) -GET_SET_KEY_FUNCTIONS( 14 ) -GET_SET_KEY_FUNCTIONS( 15 ) -#endif /* #ifndef GEKKO */ -#endif /* #ifdef USE_JOYSTICK */ - -#define SUBMENU_KEY_SELECTIONS( which ) \ -\ -static widget_menu_entry submenu_select_number_for_button_ ## which [] = { \ - { "Select a key" }, \ - { "\0120\011", INPUT_KEY_0, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_0 }, \ - { "\0121\011", INPUT_KEY_1, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_1 }, \ - { "\0122\011", INPUT_KEY_2, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_2 }, \ - { "\0123\011", INPUT_KEY_3, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_3 }, \ - { "\0124\011", INPUT_KEY_4, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_4 }, \ - { "\0125\011", INPUT_KEY_5, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_5 }, \ - { "\0126\011", INPUT_KEY_6, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_6 }, \ - { "\0127\011", INPUT_KEY_7, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_7 }, \ - { "\0128\011", INPUT_KEY_8, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_8 }, \ - { "\0129\011", INPUT_KEY_9, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_9 }, \ - { NULL } \ -}; \ -\ -static widget_menu_entry submenu_select_letters1_for_button_ ## which [] = { \ - { "Select a key" }, \ - { "\012A\011", INPUT_KEY_a, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_a }, \ - { "\012B\011", INPUT_KEY_b, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_b }, \ - { "\012C\011", INPUT_KEY_c, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_c }, \ - { "\012D\011", INPUT_KEY_d, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_d }, \ - { "\012E\011", INPUT_KEY_e, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_e }, \ - { "\012F\011", INPUT_KEY_f, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_f }, \ - { "\012G\011", INPUT_KEY_g, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_g }, \ - { "\012H\011", INPUT_KEY_h, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_h }, \ - { "\012I\011", INPUT_KEY_i, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_i }, \ - { "\012J\011", INPUT_KEY_j, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_j }, \ - { "\012K\011", INPUT_KEY_k, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_k }, \ - { "\012L\011", INPUT_KEY_l, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_l }, \ - { "\012M\011", INPUT_KEY_m, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_m }, \ - { NULL } \ -}; \ -\ -static widget_menu_entry submenu_select_letters2_for_button_ ## which [] = { \ - { "Select a key" }, \ - { "\012N\011", INPUT_KEY_n, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_n }, \ - { "\012O\011", INPUT_KEY_o, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_o }, \ - { "\012P\011", INPUT_KEY_p, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_p }, \ - { "\012Q\011", INPUT_KEY_q, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_q }, \ - { "\012R\011", INPUT_KEY_r, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_r }, \ - { "\012S\011", INPUT_KEY_s, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_s }, \ - { "\012T\011", INPUT_KEY_t, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_t }, \ - { "\012U\011", INPUT_KEY_u, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_u }, \ - { "\012V\011", INPUT_KEY_v, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_v }, \ - { "\012W\011", INPUT_KEY_w, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_w }, \ - { "\012X\011", INPUT_KEY_x, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_x }, \ - { "\012Y\011", INPUT_KEY_y, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_y }, \ - { "\012Z\011", INPUT_KEY_z, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_z }, \ - { NULL } \ -}; \ -\ -static widget_menu_entry submenu_select_key_for_button_ ## which [] = { \ - { "Select a key" }, \ - { "\012J\011oystick fire", INPUT_KEY_j, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_JOYSTICK_FIRE }, \ - { "\012N\011umbers...", INPUT_KEY_n, submenu_select_number_for_button_ ## which , NULL, NULL, 0 }, \ - { "\012A\011-M...", INPUT_KEY_a, submenu_select_letters1_for_button_ ## which , NULL, NULL, 0 }, \ - { "N-\012Z\011...", INPUT_KEY_z, submenu_select_letters2_for_button_ ## which , NULL, NULL, 0 }, \ - { "\012S\011pace", INPUT_KEY_s, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_space }, \ - { "\012E\011nter", INPUT_KEY_e, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_Enter }, \ - { "\012C\011aps Shift", INPUT_KEY_c, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_Caps }, \ - { "S\012y\011mbol Shift", INPUT_KEY_y, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_Symbol }, \ - { "N\012o\011thing", INPUT_KEY_o, NULL, set_key_for_button_ ## which, NULL, KEYBOARD_NONE }, \ - { NULL } \ -}; - -SUBMENU_KEY_SELECTIONS( 1 ) -SUBMENU_KEY_SELECTIONS( 2 ) -SUBMENU_KEY_SELECTIONS( 3 ) -SUBMENU_KEY_SELECTIONS( 4 ) -SUBMENU_KEY_SELECTIONS( 5 ) -#ifdef USE_JOYSTICK -SUBMENU_KEY_SELECTIONS( 6 ) -SUBMENU_KEY_SELECTIONS( 7 ) -SUBMENU_KEY_SELECTIONS( 8 ) -#ifndef GEKKO -SUBMENU_KEY_SELECTIONS( 9 ) -SUBMENU_KEY_SELECTIONS( 10 ) -SUBMENU_KEY_SELECTIONS( 11 ) -SUBMENU_KEY_SELECTIONS( 12 ) -SUBMENU_KEY_SELECTIONS( 13 ) -SUBMENU_KEY_SELECTIONS( 14 ) -SUBMENU_KEY_SELECTIONS( 15 ) -#endif /* #ifndef GEKKO */ -#endif /* #ifdef USE_JOYSTICK */ - -#ifdef USE_JOYSTICK -static widget_menu_entry submenu_joystick_buttons[] = { - { "Select joystick button" }, -#ifndef GEKKO - { "Button \0121\011", INPUT_KEY_1, submenu_select_key_for_button_1, NULL, get_key_name_for_button_1, 0 }, - { "Button \0122\011", INPUT_KEY_2, submenu_select_key_for_button_2, NULL, get_key_name_for_button_2, 0 }, - { "Button \0123\011", INPUT_KEY_3, submenu_select_key_for_button_3, NULL, get_key_name_for_button_3, 0 }, - { "Button \0124\011", INPUT_KEY_4, submenu_select_key_for_button_4, NULL, get_key_name_for_button_4, 0 }, - { "Button \0125\011", INPUT_KEY_5, submenu_select_key_for_button_5, NULL, get_key_name_for_button_5, 0 }, - { "Button \0126\011", INPUT_KEY_6, submenu_select_key_for_button_6, NULL, get_key_name_for_button_6, 0 }, - { "Button \0127\011", INPUT_KEY_7, submenu_select_key_for_button_7, NULL, get_key_name_for_button_7, 0 }, - { "Button \0128\011", INPUT_KEY_8, submenu_select_key_for_button_8, NULL, get_key_name_for_button_8, 0 }, - { "Button \0129\011", INPUT_KEY_9, submenu_select_key_for_button_9, NULL, get_key_name_for_button_9, 0 }, - { "Button 1\0120\011", INPUT_KEY_0, submenu_select_key_for_button_10, NULL, get_key_name_for_button_10, 0 }, - { "Button 11(\012a\011)", INPUT_KEY_a, submenu_select_key_for_button_11, NULL, get_key_name_for_button_11, 0 }, - { "Button 12(\012b\011)", INPUT_KEY_b, submenu_select_key_for_button_12, NULL, get_key_name_for_button_12, 0 }, - { "Button 13(\012c\011)", INPUT_KEY_c, submenu_select_key_for_button_13, NULL, get_key_name_for_button_13, 0 }, - { "Button 14(\012d\011)", INPUT_KEY_d, submenu_select_key_for_button_14, NULL, get_key_name_for_button_14, 0 }, - { "Button 15(\012e\011)", INPUT_KEY_e, submenu_select_key_for_button_15, NULL, get_key_name_for_button_15, 0 }, -#else /* #ifndef GEKKO */ - { "Button \0121\011", INPUT_KEY_1, submenu_select_key_for_button_1, NULL, get_key_name_for_button_1, 0 }, - { "Button \0122\011", INPUT_KEY_2, submenu_select_key_for_button_2, NULL, get_key_name_for_button_2, 0 }, - { "Button \012A\011", INPUT_KEY_a, submenu_select_key_for_button_3, NULL, get_key_name_for_button_3, 0 }, - { "Button \012B\011", INPUT_KEY_b, submenu_select_key_for_button_4, NULL, get_key_name_for_button_4, 0 }, - { "Button \012P\011lus", INPUT_KEY_p, submenu_select_key_for_button_5, NULL, get_key_name_for_button_5, 0 }, - { "Button \012M\011inus", INPUT_KEY_m, submenu_select_key_for_button_6, NULL, get_key_name_for_button_6, 0 }, - { "Button \012Z\011 on Nunchuck", INPUT_KEY_z, submenu_select_key_for_button_7, NULL, get_key_name_for_button_7, 0 }, - { "Button \012C\011 on Nunchuck", INPUT_KEY_c, submenu_select_key_for_button_8, NULL, get_key_name_for_button_8, 0 }, -#endif /* #ifndef GEKKO */ - { NULL } -}; -#endif /* #ifdef USE_JOYSTICK */ - -static widget_menu_entry submenu_keyboard_buttons[] = { - { "Select keyboard key" }, - { "Button \012U\011p", INPUT_KEY_u, submenu_select_key_for_button_1, NULL, get_key_name_for_button_1, 0 }, - { "Button \012D\011own", INPUT_KEY_d, submenu_select_key_for_button_2, NULL, get_key_name_for_button_2, 0 }, - { "Button \012L\011eft", INPUT_KEY_l, submenu_select_key_for_button_3, NULL, get_key_name_for_button_3, 0 }, - { "Button \012R\011ight", INPUT_KEY_r, submenu_select_key_for_button_4, NULL, get_key_name_for_button_4, 0 }, - { "Button \012F\011ire", INPUT_KEY_f, submenu_select_key_for_button_5, NULL, get_key_name_for_button_5, 0 }, - { NULL } -}; - -#define MAX_JOYSTICK_TYPES 8 -/* joystick types + title of the window + NULL */ -static widget_menu_entry submenu_types[ MAX_JOYSTICK_TYPES + 2 ]; -static char joystick_names[ MAX_JOYSTICK_TYPES ][ 100 ]; -void set_joystick_type( int action ); - -#define SUBMENU_DEVICE_SELECTIONS( device ) \ -\ -static widget_menu_entry submenu_type_and_mapping_for_ ## device [] = { \ - { "Select type or map buttons" }, \ - { "\012T\011ype", INPUT_KEY_t, submenu_types, NULL, NULL, 0 }, \ - { "\012B\011utton Mapping", INPUT_KEY_b, submenu_ ## device ## _buttons, NULL, NULL, 0 }, \ - { NULL } \ -}; - -#ifdef USE_JOYSTICK -SUBMENU_DEVICE_SELECTIONS( joystick ) -#endif /* #ifdef USE_JOYSTICK */ -SUBMENU_DEVICE_SELECTIONS( keyboard ) - -static void -print_items( void ) -{ - int i; - char buffer[128]; - size_t height = 24; - int width = widget_calculate_menu_width(menu); - int menu_left_edge_x = (DISPLAY_WIDTH_COLS/2-width/2)*8+1; - - for( i = 0; i < count; i++ ) { - int colour; - if( !menu[i+1].text[0] ) { height += 4; continue; } - - snprintf( buffer, sizeof (buffer), "%s", menu[i+1].text ); - colour = menu[i+1].inactive ? - WIDGET_COLOUR_DISABLED : - WIDGET_COLOUR_FOREGROUND; - - if( i == highlight_line ) { - widget_rectangle( menu_left_edge_x, height, width*8-2, 1*8, - WIDGET_COLOUR_HIGHLIGHT ); - } else { - widget_rectangle( menu_left_edge_x, height, width*8-2, 1*8, - WIDGET_COLOUR_BACKGROUND ); - } - - widget_printstring( menu_left_edge_x+8, height, colour, buffer ); - - if( menu[i+1].submenu ) { - widget_draw_submenu_arrow(DISPLAY_BORDER_ASPECT_WIDTH+menu_left_edge_x+ - width*8-9, i*8+49, colour); - } - - if( menu[i+1].detail ) { - size_t detail_width = widget_stringwidth( menu[i+1].detail() ); - int x = menu_left_edge_x + (width-1)*8 - detail_width - 2; - widget_printstring( x, height, WIDGET_COLOUR_DISABLED, menu[i+1].detail() ); - } - - height += 8; - } - - widget_display_lines( 2, count + 2 ); -} - -int widget_menu_draw( void *data ) -{ - widget_menu_entry *ptr; - size_t menu_entries, width, height = 0; - int menu_left_edge_x; - char buffer[128]; - highlight_line = 0; - - menu = (widget_menu_entry*)data; - - /* How many menu items do we have? */ - for( ptr = &menu[1]; ptr->text; ptr++ ) - height += ptr->text[0] ? 2 : 1; - menu_entries = ptr - &menu[1]; - count = menu_entries; - width = widget_calculate_menu_width(menu); - menu_left_edge_x = DISPLAY_WIDTH_COLS/2-width/2; - widget_dialog_with_border( menu_left_edge_x, 2, width, 2 + height / 2 ); - - snprintf( buffer, sizeof( buffer ), "%s", menu->text ); - widget_printstring( menu_left_edge_x*8+2, 16, WIDGET_COLOUR_TITLE, buffer ); - - print_items(); - return 0; -} - -void -widget_menu_keyhandler( input_key key ) -{ - widget_menu_entry *ptr; - int new_highlight_line = 0; - int cursor_pressed = 0; - - switch( key ) { - -#if 0 - case INPUT_KEY_Resize: /* Fake keypress used on window resize */ - widget_menu_draw( menu ); - break; -#endif - - case INPUT_KEY_Escape: - case INPUT_JOYSTICK_FIRE_2: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - return; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: - ptr=&menu[1 + highlight_line]; - if(!ptr->inactive) { - if( ptr->submenu ) { - widget_do_menu( ptr->submenu ); - } else { - ptr->callback( ptr->action ); - } - } - return; - - case INPUT_KEY_Up: - case INPUT_KEY_7: - case INPUT_JOYSTICK_UP: - if ( highlight_line ) { - new_highlight_line = highlight_line - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Down: - case INPUT_KEY_6: - case INPUT_JOYSTICK_DOWN: - if ( highlight_line + 1 < (ptrdiff_t)count ) { - new_highlight_line = highlight_line + 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Home: - new_highlight_line = 0; - ptr = &menu[1 + new_highlight_line]; - while( new_highlight_line < (ptrdiff_t)count - 1 && ptr->inactive ) { - new_highlight_line += 1; - ptr = &menu[1 + new_highlight_line]; - } - cursor_pressed = 1; - break; - - case INPUT_KEY_End: - new_highlight_line = (ptrdiff_t)count - 1; - ptr = &menu[1 + new_highlight_line]; - while( new_highlight_line > 0 && ptr->inactive ) { - new_highlight_line -= 1; - ptr = &menu[1 + new_highlight_line]; - } - cursor_pressed = 1; - break; - - default: /* Keep gcc happy */ - break; - - } - - if( cursor_pressed ) { - highlight_line = new_highlight_line; - print_items(); - return; - } - - for( ptr=&menu[1]; ptr->text; ptr++ ) { - if( !ptr->inactive && key == ptr->key ) { - - if( ptr->submenu ) { - widget_do_menu( ptr->submenu ); - } else { - ptr->callback( ptr->action ); - } - - break; - } - } -} - -/* General callbacks */ - -scaler_type -menu_get_scaler( scaler_available_fn selector ) -{ - size_t count, i; - const char *options[ SCALER_NUM ]; - widget_select_t info; - int error; - - count = 0; info.current = 0; - - for( i = 0; i < SCALER_NUM; i++ ) - if( selector( i ) ) { - if( current_scaler == i ) info.current = count; - options[ count++ ] = scaler_name( i ); - } - - info.title = "Select scaler"; - info.options = options; - info.count = count; - info.finish_all = 1; - - error = widget_do_select( &info ); - if( error ) return SCALER_NUM; - - if( info.result == -1 ) return SCALER_NUM; - - for( i = 0; i < SCALER_NUM; i++ ) - if( selector( i ) && !info.result-- ) return i; - - ui_error( UI_ERROR_ERROR, "widget_select_scaler: ran out of scalers" ); - fuse_abort(); -} - -void -menu_file_exit( int action ) -{ - static int menu_exit_open = 0; - - if( menu_exit_open ) return; - - menu_exit_open = 1; - if( widget_do_query( "Exit Fuse?" ) || !widget_query.confirm ) { - menu_exit_open = 0; - return; - } - - if( menu_check_media_changed() ) { - menu_exit_open = 0; - return; - } - - fuse_exiting = 1; - menu_exit_open = 0; - - widget_end_all( WIDGET_FINISHED_OK ); -} - -void -menu_options_general( int action ) -{ - widget_do_general(); -} - -void -menu_options_media( int action ) -{ - widget_do_media(); -} - -void -menu_options_peripherals_general( int action ) -{ - widget_do_peripherals_general(); -} - -void -menu_options_peripherals_disk( int action ) -{ - widget_do_peripherals_disk(); -} - -void -menu_options_sound( int action ) -{ - widget_do_sound(); -} - -void -menu_options_rzx( int action ) -{ - widget_do_rzx(); -} - -void -menu_options_movie( int action ) -{ - widget_do_movie(); -} - -void -menu_options_diskoptions( int action ) -{ - widget_do_diskoptions(); -} - -void -menu_options_joysticks_select( int action ) -{ - int error = 0; - int i; - - switch( action - 1 ) { - -#ifdef USE_JOYSTICK - case 0: - current_settings[ 0 ] = &( settings_current.joystick_1_output ); - current_settings[ 1 ] = &( settings_current.joystick_1_fire_1 ); - current_settings[ 2 ] = &( settings_current.joystick_1_fire_2 ); - current_settings[ 3 ] = &( settings_current.joystick_1_fire_3 ); - current_settings[ 4 ] = &( settings_current.joystick_1_fire_4 ); - current_settings[ 5 ] = &( settings_current.joystick_1_fire_5 ); - current_settings[ 6 ] = &( settings_current.joystick_1_fire_6 ); - current_settings[ 7 ] = &( settings_current.joystick_1_fire_7 ); - current_settings[ 8 ] = &( settings_current.joystick_1_fire_8 ); - current_settings[ 9 ] = &( settings_current.joystick_1_fire_9 ); - current_settings[ 10 ] = &( settings_current.joystick_1_fire_10 ); - current_settings[ 11 ] = &( settings_current.joystick_1_fire_11 ); - current_settings[ 12 ] = &( settings_current.joystick_1_fire_12 ); - current_settings[ 13 ] = &( settings_current.joystick_1_fire_13 ); - current_settings[ 14 ] = &( settings_current.joystick_1_fire_14 ); - current_settings[ 15 ] = &( settings_current.joystick_1_fire_15 ); - submenu_type_and_mapping_for_joystick[ 1 ].detail = menu_joystick_1_detail; - break; - case 1: - current_settings[ 0 ] = &( settings_current.joystick_2_output ); - current_settings[ 1 ] = &( settings_current.joystick_2_fire_1 ); - current_settings[ 2 ] = &( settings_current.joystick_2_fire_2 ); - current_settings[ 3 ] = &( settings_current.joystick_2_fire_3 ); - current_settings[ 4 ] = &( settings_current.joystick_2_fire_4 ); - current_settings[ 5 ] = &( settings_current.joystick_2_fire_5 ); - current_settings[ 6 ] = &( settings_current.joystick_2_fire_6 ); - current_settings[ 7 ] = &( settings_current.joystick_2_fire_7 ); - current_settings[ 8 ] = &( settings_current.joystick_2_fire_8 ); - current_settings[ 9 ] = &( settings_current.joystick_2_fire_9 ); - current_settings[ 10 ] = &( settings_current.joystick_2_fire_10 ); - current_settings[ 11 ] = &( settings_current.joystick_2_fire_11 ); - current_settings[ 12 ] = &( settings_current.joystick_2_fire_12 ); - current_settings[ 13 ] = &( settings_current.joystick_2_fire_13 ); - current_settings[ 14 ] = &( settings_current.joystick_2_fire_14 ); - current_settings[ 15 ] = &( settings_current.joystick_2_fire_15 ); - submenu_type_and_mapping_for_joystick[ 1 ].detail = menu_joystick_2_detail; - break; -#endif /* #ifdef USE_JOYSTICK */ - - case JOYSTICK_KEYBOARD: - current_settings[ 0 ] = &( settings_current.joystick_keyboard_output ); - current_settings[ 1 ] = &( settings_current.joystick_keyboard_up ); - current_settings[ 2 ] = &( settings_current.joystick_keyboard_down ); - current_settings[ 3 ] = &( settings_current.joystick_keyboard_left ); - current_settings[ 4 ] = &( settings_current.joystick_keyboard_right ); - current_settings[ 5 ] = &( settings_current.joystick_keyboard_fire ); - submenu_type_and_mapping_for_keyboard[ 1 ].detail = menu_keyboard_joystick_detail; - break; - } - - /* Populate joystick names */ - if( JOYSTICK_TYPE_COUNT > MAX_JOYSTICK_TYPES ) - ui_error( UI_ERROR_ERROR, "Not all joystick types are displayed" ); - - submenu_types[ 0 ].text = "Select joystick type"; - for( i = 0; ( i < JOYSTICK_TYPE_COUNT ) && ( i < MAX_JOYSTICK_TYPES ); i++ ) { - char shortcut[ 2 ] = { 'A' + i, '\0' }; - snprintf( ( char * ) joystick_names[ i ], 100, "\012%s\011 %s", shortcut, - joystick_name[ i ] ); - submenu_types[ i + 1 ].text = joystick_names[ i ]; - submenu_types[ i + 1 ].key = INPUT_KEY_a + i; - submenu_types[ i + 1 ].callback = set_joystick_type; - submenu_types[ i + 1 ].action = i; - } - submenu_types[ i + 1 ].text = NULL; - - if( action - 1 == JOYSTICK_KEYBOARD ) - error = widget_do_menu( submenu_type_and_mapping_for_keyboard ); - -#ifdef USE_JOYSTICK - else - error = widget_do_menu( submenu_type_and_mapping_for_joystick ); -#endif /* #ifdef USE_JOYSTICK */ - - if( error ) return; -} - -void -set_joystick_type( int action ) -{ - *current_settings[ 0 ] = action; - widget_end_all( WIDGET_FINISHED_OK ); -} - -/* Options/Select ROMs/ */ -int -menu_select_roms_with_title( const char *title, size_t start, size_t count, - int is_peripheral ) -{ - widget_roms_info info; - - info.title = title; - info.start = start; - info.count = count; - info.is_peripheral = is_peripheral; - info.initialised = 0; - - return widget_do_rom( &info ); -} - -void -menu_machine_reset( int action ) -{ - int hard_reset = action; - const char *message = "Reset?"; - - if( hard_reset ) - message = "Hard reset?"; - - if( widget_do_query( message ) || - !widget_query.confirm ) - return; - - widget_end_all( WIDGET_FINISHED_OK ); - - /* Stop any ongoing RZX */ - rzx_stop_recording(); - rzx_stop_playback( 1 ); - - machine_reset( hard_reset ); -} - -void -menu_machine_select( int action ) -{ - widget_select_t info; - char **options, *buffer; - size_t i; - int error; - libspectrum_machine new_machine; - - options = malloc( machine_count * sizeof( const char * ) ); - if( !options ) { - ui_error( UI_ERROR_ERROR, "out of memory at %s:%d", __FILE__, __LINE__ ); - return; - } - - buffer = malloc( 40 * machine_count ); - if( !buffer ) { - ui_error( UI_ERROR_ERROR, "out of memory at %s:%d", __FILE__, __LINE__ ); - free( options ); - return; - } - - for( i = 0; i < machine_count; i++ ) { - options[i] = &buffer[ i * 40 ]; - snprintf( options[i], 40, "%s", - libspectrum_machine_name( machine_types[i]->machine ) ); - if( machine_current->machine == machine_types[i]->machine ) - info.current = i; - } - - info.title = "Select machine"; - info.options = (const char**)options; - info.count = machine_count; - info.finish_all = 1; - - error = widget_do_select( &info ); - free( buffer ); free( options ); - if( error ) return; - - if( info.result == -1 ) return; - - new_machine = machine_types[ info.result ]->machine; - - if( machine_current->machine != new_machine ) machine_select( new_machine ); -} - -void -menu_machine_debugger( int action ) -{ - debugger_mode = DEBUGGER_MODE_HALTED; - widget_do_debugger(); -} - -void -menu_machine_pokememory( int action ) -{ - widget_do_pokemem(); -} - -void -menu_machine_pokefinder( int action ) -{ - widget_do_pokefinder(); -} - -void -menu_machine_memorybrowser( int action ) -{ - widget_do_memorybrowser(); -} - -void -menu_media_tape_browse( int action ) -{ - widget_do_browse(); -} - -void -menu_help_keyboard( int action ) -{ - utils_file screen; - widget_picture_data info; - - static const char * const filename = "keyboard.scr"; - - if( utils_read_screen( filename, &screen ) ) { - return; - } - - info.filename = filename; - info.screen = screen.buffer; - info.border = 0; - - widget_do_picture( &info ); - - utils_close_file( &screen ); -} - -void -menu_help_about( int action ) -{ - widget_do_about(); -} - -static int -set_active( struct widget_menu_entry *menu, const char *path, int active ) -{ - if( *path == '/' ) path++; - - /* Skip the menu title */ - menu++; - - for( ; menu->text; menu++ ) { - - const char *p = menu->text, *q = path; - - /* Compare the two strings, but skip hotkey-delimiter characters */ - do { - if( *p == 9 || *p == 10 ) p++; - } while( *p && *p++ == *q++ ); - - if( *p ) continue; /* not matched */ - - /* match, but with a submenu */ - if( *q == '/' ) return set_active( menu->submenu, q, active ); - - if( *q ) continue; /* not matched */ - - /* we have a match */ - menu->inactive = !active; - return 0; - } - - return 1; -} - -int -ui_menu_item_set_active( const char *path, int active ) -{ - return set_active( widget_menu, path, active ); -} diff --git a/fuse/ui/widget/menu_data.c b/fuse/ui/widget/menu_data.c deleted file mode 100644 index 8cc92a8..0000000 --- a/fuse/ui/widget/menu_data.c +++ /dev/null @@ -1,934 +0,0 @@ -/* menu_data.c: menu structure for Fuse - Copyright (c) 2004-2007 Philip Kendall, Stuart Brady, Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -/* This file is autogenerated from menu_data.dat by ./menu_data.pl. - Any changes made here will not be preserved. */ - -#include - -#include "menu.h" - -#include "input.h" -#include "ui/widget/options_internals.h" -#include "ui/widget/widget_internals.h" - -static widget_menu_entry menu_file_recording[] = { - { "Recording" }, - { "\012R\011ecord...", INPUT_KEY_r, NULL, menu_file_recording_record, NULL, 0 }, - { "Record from s\012n\011apshot...", INPUT_KEY_n, NULL, menu_file_recording_recordfromsnapshot, NULL, 0 }, - { "\012C\011ontinue recording...", INPUT_KEY_c, NULL, menu_file_recording_continuerecording, NULL, 0 }, - { "\012I\011nsert snapshot", INPUT_KEY_i, NULL, menu_file_recording_insertsnapshot, NULL, 0 }, - { "Roll\012b\011ack", INPUT_KEY_b, NULL, menu_file_recording_rollback, NULL, 0 }, - { "\012P\011lay...", INPUT_KEY_p, NULL, menu_file_recording_play, NULL, 0 }, - { "\012S\011top", INPUT_KEY_s, NULL, menu_file_recording_stop, NULL, 0 }, - { "\012F\011inalise...", INPUT_KEY_f, NULL, menu_file_recording_finalise, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_file_aylogging[] = { - { "AY Logging" }, - { "\012R\011ecord...", INPUT_KEY_r, NULL, menu_file_aylogging_record, NULL, 0 }, - { "\012S\011top", INPUT_KEY_s, NULL, menu_file_aylogging_stop, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_file_screenshot[] = { - { "Screenshot" }, - { "O\012p\011en SCR Screenshot...", INPUT_KEY_p, NULL, menu_file_screenshot_openscrscreenshot, NULL, 0 }, - { "S\012a\011ve Screen as SCR...", INPUT_KEY_a, NULL, menu_file_screenshot_savescreenasscr, NULL, 0 }, - { "Op\012e\011n MLT Screenshot...", INPUT_KEY_e, NULL, menu_file_screenshot_openmltscreenshot, NULL, 0 }, - { "Sa\012v\011e Screen as MLT...", INPUT_KEY_v, NULL, menu_file_screenshot_savescreenasmlt, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_file_movie[] = { - { "Movie" }, - { "\012R\011ecord...", INPUT_KEY_r, NULL, menu_file_movie_record, NULL, 0 }, - { "R\012e\011cord from RZX...", INPUT_KEY_e, NULL, menu_file_movie_record_recordfromrzx, NULL, 0 }, - { "\012P\011ause", INPUT_KEY_p, NULL, menu_file_movie_pause, NULL, 0 }, - { "\012C\011ontinue", INPUT_KEY_c, NULL, menu_file_movie_pause, NULL, 0 }, - { "\012S\011top", INPUT_KEY_s, NULL, menu_file_movie_stop, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_file[] = { - { "File" }, - { "\012O\011pen...", INPUT_KEY_o, NULL, menu_file_open, NULL, 0 }, - { "\012S\011ave Snapshot...", INPUT_KEY_s, NULL, menu_file_savesnapshot, NULL, 0 }, - { "\012R\011ecording", INPUT_KEY_r, menu_file_recording, NULL, NULL, 0 }, - { "A\012Y\011 Logging", INPUT_KEY_y, menu_file_aylogging, NULL, NULL, 0 }, - { "S\012c\011reenshot", INPUT_KEY_c, menu_file_screenshot, NULL, NULL, 0 }, - { "\012M\011ovie", INPUT_KEY_m, menu_file_movie, NULL, NULL, 0 }, - { "Loa\012d\011 binary data...", INPUT_KEY_d, NULL, menu_file_loadbinarydata, NULL, 0 }, - { "Save \012b\011inary data...", INPUT_KEY_b, NULL, menu_file_savebinarydata, NULL, 0 }, - { "E\012x\011it...", INPUT_KEY_x, NULL, menu_file_exit, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_options_peripherals[] = { - { "Peripherals" }, - { "\012G\011eneral...", INPUT_KEY_g, NULL, menu_options_peripherals_general, NULL, 0 }, - { "\012D\011isk...", INPUT_KEY_d, NULL, menu_options_peripherals_disk, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_options_joysticks[] = { - { "Joysticks" }, - { "\012K\011eyboard...", INPUT_KEY_k, NULL, menu_options_joysticks_select, menu_keyboard_joystick_detail, 3 }, - { NULL } -}; - -static widget_menu_entry menu_options_selectroms_machineroms[] = { - { "Machine ROMs" }, - { "Spectrum 1\0126\011K...", INPUT_KEY_6, NULL, menu_options_selectroms_machine_select, NULL, 1 }, - { "Spectrum \0124\0118K...", INPUT_KEY_4, NULL, menu_options_selectroms_machine_select, NULL, 2 }, - { "Spectrum \0121\01128K...", INPUT_KEY_1, NULL, menu_options_selectroms_machine_select, NULL, 3 }, - { "Spectrum +\0122\011...", INPUT_KEY_2, NULL, menu_options_selectroms_machine_select, NULL, 4 }, - { "Spectrum +2\012A\011...", INPUT_KEY_a, NULL, menu_options_selectroms_machine_select, NULL, 5 }, - { "Spectrum +\0123\011...", INPUT_KEY_3, NULL, menu_options_selectroms_machine_select, NULL, 6 }, - { "Spectrum +3\012e\011...", INPUT_KEY_e, NULL, menu_options_selectroms_machine_select, NULL, 7 }, - { "Timex \012T\011C2048...", INPUT_KEY_t, NULL, menu_options_selectroms_machine_select, NULL, 8 }, - { "Timex TC206\0128\011...", INPUT_KEY_8, NULL, menu_options_selectroms_machine_select, NULL, 9 }, - { "Ti\012m\011ex TS2068...", INPUT_KEY_m, NULL, menu_options_selectroms_machine_select, NULL, 10 }, - { "\012P\011entagon 128K...", INPUT_KEY_p, NULL, menu_options_selectroms_machine_select, NULL, 11 }, - { "Pe\012n\011tagon 512K...", INPUT_KEY_n, NULL, menu_options_selectroms_machine_select, NULL, 12 }, - { "Penta\012g\011on 1024K...", INPUT_KEY_g, NULL, menu_options_selectroms_machine_select, NULL, 13 }, - { "S\012c\011orpion ZS 256...", INPUT_KEY_c, NULL, menu_options_selectroms_machine_select, NULL, 14 }, - { "Spectrum \012S\011E...", INPUT_KEY_s, NULL, menu_options_selectroms_machine_select, NULL, 15 }, - { NULL } -}; - -static widget_menu_entry menu_options_selectroms_peripheralroms[] = { - { "Peripheral ROMs" }, - { "\012I\011nterface 1...", INPUT_KEY_i, NULL, menu_options_selectroms_peripheral_select, NULL, 1 }, - { "\012B\011eta 128...", INPUT_KEY_b, NULL, menu_options_selectroms_peripheral_select, NULL, 2 }, - { "+\012D\011...", INPUT_KEY_d, NULL, menu_options_selectroms_peripheral_select, NULL, 3 }, - { "Didaktik \0128\0110...", INPUT_KEY_8, NULL, menu_options_selectroms_peripheral_select, NULL, 4 }, - { "DISCiP\012L\011E...", INPUT_KEY_l, NULL, menu_options_selectroms_peripheral_select, NULL, 5 }, - { "Mu\012l\011tiface One...", INPUT_KEY_l, NULL, menu_options_selectroms_peripheral_select, NULL, 6 }, - { "Multiface \0121\01128...", INPUT_KEY_1, NULL, menu_options_selectroms_peripheral_select, NULL, 7 }, - { "Multiface \0123\011...", INPUT_KEY_3, NULL, menu_options_selectroms_peripheral_select, NULL, 8 }, - { "\012O\011pus Discovery...", INPUT_KEY_o, NULL, menu_options_selectroms_peripheral_select, NULL, 9 }, - { "Specc\012y\011Boot...", INPUT_KEY_y, NULL, menu_options_selectroms_peripheral_select, NULL, 10 }, - { "TT\012X\0112000S...", INPUT_KEY_x, NULL, menu_options_selectroms_peripheral_select, NULL, 11 }, - { "\012u\011Source...", INPUT_KEY_u, NULL, menu_options_selectroms_peripheral_select, NULL, 12 }, - { NULL } -}; - -static widget_menu_entry menu_options_selectroms[] = { - { "Select ROMs" }, - { "\012M\011achine ROMs", INPUT_KEY_m, menu_options_selectroms_machineroms, NULL, NULL, 0 }, - { "\012P\011eripheral ROMs", INPUT_KEY_p, menu_options_selectroms_peripheralroms, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_options[] = { - { "Options" }, - { "\012G\011eneral...", INPUT_KEY_g, NULL, menu_options_general, NULL, 0 }, - { "\012M\011edia...", INPUT_KEY_m, NULL, menu_options_media, NULL, 0 }, - { "\012S\011ound...", INPUT_KEY_s, NULL, menu_options_sound, NULL, 0 }, - { "\012P\011eripherals", INPUT_KEY_p, menu_options_peripherals, NULL, NULL, 0 }, - { "\012R\011ZX...", INPUT_KEY_r, NULL, menu_options_rzx, NULL, 0 }, - { "\012M\011ovie...", INPUT_KEY_m, NULL, menu_options_movie, NULL, 0 }, - { "\012J\011oysticks", INPUT_KEY_j, menu_options_joysticks, NULL, NULL, 0 }, - { "S\012e\011lect ROMs", INPUT_KEY_e, menu_options_selectroms, NULL, NULL, 0 }, - { "\012F\011ilter...", INPUT_KEY_f, NULL, menu_options_filter, menu_filter_detail, 0 }, - { "\012D\011isk options...", INPUT_KEY_d, NULL, menu_options_diskoptions, NULL, 0 }, - { "S\012a\011ve", INPUT_KEY_a, NULL, menu_options_save, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_machine_profiler[] = { - { "Profiler" }, - { "\012S\011tart", INPUT_KEY_s, NULL, menu_machine_profiler_start, NULL, 0 }, - { "\012S\011top", INPUT_KEY_s, NULL, menu_machine_profiler_stop, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_machine[] = { - { "Machine" }, - { "\012R\011eset...", INPUT_KEY_r, NULL, menu_machine_reset, NULL, 0 }, - { "\012H\011ard reset...", INPUT_KEY_h, NULL, menu_machine_reset, NULL, 1 }, - { "\012S\011elect...", INPUT_KEY_s, NULL, menu_machine_select, menu_machine_detail, 0 }, - { "\012D\011ebugger...", INPUT_KEY_d, NULL, menu_machine_debugger, NULL, 0 }, - { "P\012o\011ke Finder...", INPUT_KEY_o, NULL, menu_machine_pokefinder, NULL, 0 }, - { "Po\012k\011e Memory...", INPUT_KEY_k, NULL, menu_machine_pokememory, NULL, 0 }, - { "\012M\011emory Browser...", INPUT_KEY_m, NULL, menu_machine_memorybrowser, NULL, 0 }, - { "Pro\012f\011iler", INPUT_KEY_f, menu_machine_profiler, NULL, NULL, 0 }, - { "\012N\011MI", INPUT_KEY_n, NULL, menu_machine_nmi, NULL, 0 }, - { "Multiface Red \012B\011utton", INPUT_KEY_b, NULL, menu_machine_multifaceredbutton, NULL, 0 }, - { "Didaktik SNA\012P\011", INPUT_KEY_p, NULL, menu_machine_didaktiksnap, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_tape[] = { - { "Tape" }, - { "\012O\011pen...", INPUT_KEY_o, NULL, menu_media_tape_open, NULL, 0 }, - { "\012P\011lay", INPUT_KEY_p, NULL, menu_media_tape_play, NULL, 0 }, - { "\012B\011rowse...", INPUT_KEY_b, NULL, menu_media_tape_browse, NULL, 0 }, - { "\012R\011ewind", INPUT_KEY_r, NULL, menu_media_tape_rewind, NULL, 0 }, - { "\012C\011lear", INPUT_KEY_c, NULL, menu_media_tape_clear, NULL, 0 }, - { "\012W\011rite...", INPUT_KEY_w, NULL, menu_media_tape_write, NULL, 0 }, - { "R\012e\011cord Start", INPUT_KEY_e, NULL, menu_media_tape_recordstart, NULL, 0 }, - { "Recor\012d\011 Stop", INPUT_KEY_d, NULL, menu_media_tape_recordstop, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1_microdrive1_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x131 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x031 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1_microdrive1[] = { - { "Microdrive 1" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x31 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x31 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x31 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x031 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x131 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_interface1_microdrive1_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1_microdrive2_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x132 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x032 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1_microdrive2[] = { - { "Microdrive 2" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x32 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x32 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x32 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x032 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x132 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_interface1_microdrive2_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1_microdrive3_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x133 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x033 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1_microdrive3[] = { - { "Microdrive 3" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x33 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x33 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x33 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x033 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x133 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_interface1_microdrive3_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1_microdrive4_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x134 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x034 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1_microdrive4[] = { - { "Microdrive 4" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x34 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x34 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x34 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x034 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x134 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_interface1_microdrive4_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1_microdrive5_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x135 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x035 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1_microdrive5[] = { - { "Microdrive 5" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x35 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x35 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x35 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x035 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x135 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_interface1_microdrive5_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1_microdrive6_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x136 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x036 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1_microdrive6[] = { - { "Microdrive 6" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x36 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x36 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x36 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x036 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x136 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_interface1_microdrive6_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1_microdrive7_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x137 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x037 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1_microdrive7[] = { - { "Microdrive 7" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x37 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x37 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x37 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x037 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x137 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_interface1_microdrive7_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1_microdrive8_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x138 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x038 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1_microdrive8[] = { - { "Microdrive 8" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x38 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x38 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x38 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x038 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x138 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_interface1_microdrive8_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1_rs232[] = { - { "RS232" }, - { "Plug \012R\011xD", INPUT_KEY_r, NULL, menu_media_if1_rs232, NULL, 0x01 }, - { "\012U\011nplug RxD", INPUT_KEY_u, NULL, menu_media_if1_rs232, NULL, 0x11 }, - { "Plug \012T\011xD", INPUT_KEY_t, NULL, menu_media_if1_rs232, NULL, 0x02 }, - { "Un\012p\011lug TxD", INPUT_KEY_p, NULL, menu_media_if1_rs232, NULL, 0x12 }, - { NULL } -}; - -static widget_menu_entry menu_media_interface1[] = { - { "Interface 1" }, - { "Microdrive \0121\011", INPUT_KEY_1, menu_media_interface1_microdrive1, NULL, NULL, 0 }, - { "Microdrive \0122\011", INPUT_KEY_2, menu_media_interface1_microdrive2, NULL, NULL, 0 }, - { "Microdrive \0123\011", INPUT_KEY_3, menu_media_interface1_microdrive3, NULL, NULL, 0 }, - { "Microdrive \0124\011", INPUT_KEY_4, menu_media_interface1_microdrive4, NULL, NULL, 0 }, - { "Microdrive \0125\011", INPUT_KEY_5, menu_media_interface1_microdrive5, NULL, NULL, 0 }, - { "Microdrive \0126\011", INPUT_KEY_6, menu_media_interface1_microdrive6, NULL, NULL, 0 }, - { "Microdrive \0127\011", INPUT_KEY_7, menu_media_interface1_microdrive7, NULL, NULL, 0 }, - { "Microdrive \0128\011", INPUT_KEY_8, menu_media_interface1_microdrive8, NULL, NULL, 0 }, - { "\012R\011S232", INPUT_KEY_r, menu_media_interface1_rs232, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_3_drivea_flipdisk[] = { - { "Flip disk" }, - { "Turn \012u\011pside down", INPUT_KEY_u, NULL, menu_media_flip, NULL, 0x101 }, - { "Turn \012b\011ack", INPUT_KEY_b, NULL, menu_media_flip, NULL, 0x001 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_3_drivea_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x101 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x001 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_3_drivea[] = { - { "Drive A:" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x01 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x01 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x01 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x001 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x101 }, - { "\012F\011lip disk", INPUT_KEY_f, menu_media_disk_3_drivea_flipdisk, NULL, NULL, 0 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_disk_3_drivea_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_3_driveb_flipdisk[] = { - { "Flip disk" }, - { "Turn \012u\011pside down", INPUT_KEY_u, NULL, menu_media_flip, NULL, 0x102 }, - { "Turn \012b\011ack", INPUT_KEY_b, NULL, menu_media_flip, NULL, 0x002 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_3_driveb_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x102 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x002 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_3_driveb[] = { - { "Drive B:" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x02 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x02 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x02 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x002 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x102 }, - { "\012F\011lip disk", INPUT_KEY_f, menu_media_disk_3_driveb_flipdisk, NULL, NULL, 0 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_disk_3_driveb_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_3[] = { - { "+3" }, - { "Drive \012A\011:", INPUT_KEY_a, menu_media_disk_3_drivea, NULL, menu_plus3a_detail, 0 }, - { "Drive \012B\011:", INPUT_KEY_b, menu_media_disk_3_driveb, NULL, menu_plus3b_detail, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_beta_drivea_flipdisk[] = { - { "Flip disk" }, - { "Turn \012u\011pside down", INPUT_KEY_u, NULL, menu_media_flip, NULL, 0x111 }, - { "Turn \012b\011ack", INPUT_KEY_b, NULL, menu_media_flip, NULL, 0x011 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_beta_drivea_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x111 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x011 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_beta_drivea[] = { - { "Drive A:" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x11 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x11 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x11 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x011 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x111 }, - { "\012F\011lip disk", INPUT_KEY_f, menu_media_disk_beta_drivea_flipdisk, NULL, NULL, 0 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_disk_beta_drivea_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_beta_driveb_flipdisk[] = { - { "Flip disk" }, - { "Turn \012u\011pside down", INPUT_KEY_u, NULL, menu_media_flip, NULL, 0x112 }, - { "Turn \012b\011ack", INPUT_KEY_b, NULL, menu_media_flip, NULL, 0x012 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_beta_driveb_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x112 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x012 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_beta_driveb[] = { - { "Drive B:" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x12 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x12 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x12 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x012 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x112 }, - { "\012F\011lip disk", INPUT_KEY_f, menu_media_disk_beta_driveb_flipdisk, NULL, NULL, 0 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_disk_beta_driveb_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_beta_drivec_flipdisk[] = { - { "Flip disk" }, - { "Turn \012u\011pside down", INPUT_KEY_u, NULL, menu_media_flip, NULL, 0x113 }, - { "Turn \012b\011ack", INPUT_KEY_b, NULL, menu_media_flip, NULL, 0x013 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_beta_drivec_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x113 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x013 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_beta_drivec[] = { - { "Drive C:" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x13 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x13 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x13 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x013 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x113 }, - { "\012F\011lip disk", INPUT_KEY_f, menu_media_disk_beta_drivec_flipdisk, NULL, NULL, 0 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_disk_beta_drivec_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_beta_drived_flipdisk[] = { - { "Flip disk" }, - { "Turn \012u\011pside down", INPUT_KEY_u, NULL, menu_media_flip, NULL, 0x114 }, - { "Turn \012b\011ack", INPUT_KEY_b, NULL, menu_media_flip, NULL, 0x014 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_beta_drived_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x114 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x014 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_beta_drived[] = { - { "Drive D:" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x14 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x14 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x14 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x014 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x114 }, - { "\012F\011lip disk", INPUT_KEY_f, menu_media_disk_beta_drived_flipdisk, NULL, NULL, 0 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_disk_beta_drived_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_beta[] = { - { "Beta" }, - { "Drive \012A\011:", INPUT_KEY_a, menu_media_disk_beta_drivea, NULL, menu_beta128a_detail, 0 }, - { "Drive \012B\011:", INPUT_KEY_b, menu_media_disk_beta_driveb, NULL, menu_beta128b_detail, 0 }, - { "Drive \012C\011:", INPUT_KEY_c, menu_media_disk_beta_drivec, NULL, menu_beta128c_detail, 0 }, - { "Drive \012D\011:", INPUT_KEY_d, menu_media_disk_beta_drived, NULL, menu_beta128d_detail, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_d_drive1_flipdisk[] = { - { "Flip disk" }, - { "Turn \012u\011pside down", INPUT_KEY_u, NULL, menu_media_flip, NULL, 0x121 }, - { "Turn \012b\011ack", INPUT_KEY_b, NULL, menu_media_flip, NULL, 0x021 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_d_drive1_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x121 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x021 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_d_drive1[] = { - { "Drive 1" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x21 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x21 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x21 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x021 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x121 }, - { "\012F\011lip disk", INPUT_KEY_f, menu_media_disk_d_drive1_flipdisk, NULL, NULL, 0 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_disk_d_drive1_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_d_drive2_flipdisk[] = { - { "Flip disk" }, - { "Turn \012u\011pside down", INPUT_KEY_u, NULL, menu_media_flip, NULL, 0x122 }, - { "Turn \012b\011ack", INPUT_KEY_b, NULL, menu_media_flip, NULL, 0x022 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_d_drive2_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x122 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x022 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_d_drive2[] = { - { "Drive 2" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x22 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x22 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x22 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x022 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x122 }, - { "\012F\011lip disk", INPUT_KEY_f, menu_media_disk_d_drive2_flipdisk, NULL, NULL, 0 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_disk_d_drive2_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_d[] = { - { "+D" }, - { "Drive \0121\011", INPUT_KEY_1, menu_media_disk_d_drive1, NULL, menu_plusd1_detail, 0 }, - { "Drive \0122\011", INPUT_KEY_2, menu_media_disk_d_drive2, NULL, menu_plusd2_detail, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_disciple_drive1_flipdisk[] = { - { "Flip disk" }, - { "Turn \012u\011pside down", INPUT_KEY_u, NULL, menu_media_flip, NULL, 0x151 }, - { "Turn \012b\011ack", INPUT_KEY_b, NULL, menu_media_flip, NULL, 0x051 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_disciple_drive1_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x151 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x051 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_disciple_drive1[] = { - { "Drive 1" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x51 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x51 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x51 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x051 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x151 }, - { "\012F\011lip disk", INPUT_KEY_f, menu_media_disk_disciple_drive1_flipdisk, NULL, NULL, 0 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_disk_disciple_drive1_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_disciple_drive2_flipdisk[] = { - { "Flip disk" }, - { "Turn \012u\011pside down", INPUT_KEY_u, NULL, menu_media_flip, NULL, 0x152 }, - { "Turn \012b\011ack", INPUT_KEY_b, NULL, menu_media_flip, NULL, 0x052 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_disciple_drive2_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x152 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x052 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_disciple_drive2[] = { - { "Drive 2" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x52 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x52 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x52 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x052 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x152 }, - { "\012F\011lip disk", INPUT_KEY_f, menu_media_disk_disciple_drive2_flipdisk, NULL, NULL, 0 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_disk_disciple_drive2_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_disciple[] = { - { "DISCiPLE" }, - { "Drive \0121\011", INPUT_KEY_1, menu_media_disk_disciple_drive1, NULL, menu_disciple1_detail, 0 }, - { "Drive \0122\011", INPUT_KEY_2, menu_media_disk_disciple_drive2, NULL, menu_disciple2_detail, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_opus_drive1_flipdisk[] = { - { "Flip disk" }, - { "Turn \012u\011pside down", INPUT_KEY_u, NULL, menu_media_flip, NULL, 0x141 }, - { "Turn \012b\011ack", INPUT_KEY_b, NULL, menu_media_flip, NULL, 0x041 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_opus_drive1_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x141 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x041 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_opus_drive1[] = { - { "Drive 1" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x41 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x41 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x41 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x041 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x141 }, - { "\012F\011lip disk", INPUT_KEY_f, menu_media_disk_opus_drive1_flipdisk, NULL, NULL, 0 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_disk_opus_drive1_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_opus_drive2_flipdisk[] = { - { "Flip disk" }, - { "Turn \012u\011pside down", INPUT_KEY_u, NULL, menu_media_flip, NULL, 0x142 }, - { "Turn \012b\011ack", INPUT_KEY_b, NULL, menu_media_flip, NULL, 0x042 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_opus_drive2_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x142 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x042 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_opus_drive2[] = { - { "Drive 2" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x42 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x42 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x42 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x042 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x142 }, - { "\012F\011lip disk", INPUT_KEY_f, menu_media_disk_opus_drive2_flipdisk, NULL, NULL, 0 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_disk_opus_drive2_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_opus[] = { - { "Opus" }, - { "Drive \0121\011", INPUT_KEY_1, menu_media_disk_opus_drive1, NULL, menu_opus1_detail, 0 }, - { "Drive \0122\011", INPUT_KEY_2, menu_media_disk_opus_drive2, NULL, menu_opus2_detail, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_didaktik80_drivea_flipdisk[] = { - { "Flip disk" }, - { "Turn \012u\011pside down", INPUT_KEY_u, NULL, menu_media_flip, NULL, 0x161 }, - { "Turn \012b\011ack", INPUT_KEY_b, NULL, menu_media_flip, NULL, 0x061 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_didaktik80_drivea_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x161 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x061 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_didaktik80_drivea[] = { - { "Drive A" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x61 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x61 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x61 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x061 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x161 }, - { "\012F\011lip disk", INPUT_KEY_f, menu_media_disk_didaktik80_drivea_flipdisk, NULL, NULL, 0 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_disk_didaktik80_drivea_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_didaktik80_driveb_flipdisk[] = { - { "Flip disk" }, - { "Turn \012u\011pside down", INPUT_KEY_u, NULL, menu_media_flip, NULL, 0x162 }, - { "Turn \012b\011ack", INPUT_KEY_b, NULL, menu_media_flip, NULL, 0x062 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_didaktik80_driveb_writeprotect[] = { - { "Write protect" }, - { "\012E\011nable", INPUT_KEY_e, NULL, menu_media_writeprotect, NULL, 0x162 }, - { "\012D\011isable", INPUT_KEY_d, NULL, menu_media_writeprotect, NULL, 0x062 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_didaktik80_driveb[] = { - { "Drive B" }, - { "Insert \012N\011ew", INPUT_KEY_n, NULL, menu_media_insert_new, NULL, 0x62 }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_insert, NULL, 0x62 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_eject, NULL, 0x62 }, - { "\012S\011ave", INPUT_KEY_s, NULL, menu_media_save, NULL, 0x062 }, - { "Save \012A\011s...", INPUT_KEY_a, NULL, menu_media_save, NULL, 0x162 }, - { "\012F\011lip disk", INPUT_KEY_f, menu_media_disk_didaktik80_driveb_flipdisk, NULL, NULL, 0 }, - { "Write \012p\011rotect", INPUT_KEY_p, menu_media_disk_didaktik80_driveb_writeprotect, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk_didaktik80[] = { - { "Didaktik 80" }, - { "Drive \012A\011", INPUT_KEY_a, menu_media_disk_didaktik80_drivea, NULL, menu_didaktik_a_detail, 0 }, - { "Drive \012B\011", INPUT_KEY_b, menu_media_disk_didaktik80_driveb, NULL, menu_didaktik_b_detail, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_disk[] = { - { "Disk" }, - { "+\0123\011", INPUT_KEY_3, menu_media_disk_3, NULL, NULL, 0 }, - { "\012B\011eta", INPUT_KEY_b, menu_media_disk_beta, NULL, NULL, 0 }, - { "+\012D\011", INPUT_KEY_d, menu_media_disk_d, NULL, NULL, 0 }, - { "DISC\012i\011PLE", INPUT_KEY_i, menu_media_disk_disciple, NULL, NULL, 0 }, - { "\012O\011pus", INPUT_KEY_o, menu_media_disk_opus, NULL, NULL, 0 }, - { "\012D\011idaktik 80", INPUT_KEY_d, menu_media_disk_didaktik80, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_cartridge_timexdock[] = { - { "Timex Dock" }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_cartridge_timexdock_insert, NULL, 0 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_cartridge_timexdock_eject, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_cartridge_interface2[] = { - { "Interface 2" }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_cartridge_interface2_insert, NULL, 0 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_cartridge_interface2_eject, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_cartridge[] = { - { "Cartridge" }, - { "\012T\011imex Dock", INPUT_KEY_t, menu_media_cartridge_timexdock, NULL, NULL, 0 }, - { "\012I\011nterface 2", INPUT_KEY_i, menu_media_cartridge_interface2, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_ide_simple8bit_master[] = { - { "Master" }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_ide_insert, NULL, 1 }, - { "\012C\011ommit", INPUT_KEY_c, NULL, menu_media_ide_commit, NULL, 1 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_ide_eject, NULL, 1 }, - { NULL } -}; - -static widget_menu_entry menu_media_ide_simple8bit_slave[] = { - { "Slave" }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_ide_insert, NULL, 2 }, - { "\012C\011ommit", INPUT_KEY_c, NULL, menu_media_ide_commit, NULL, 2 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_ide_eject, NULL, 2 }, - { NULL } -}; - -static widget_menu_entry menu_media_ide_simple8bit[] = { - { "Simple 8-bit" }, - { "\012M\011aster", INPUT_KEY_m, menu_media_ide_simple8bit_master, NULL, NULL, 0 }, - { "\012S\011lave", INPUT_KEY_s, menu_media_ide_simple8bit_slave, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_ide_zxatasp_master[] = { - { "Master" }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_ide_insert, NULL, 3 }, - { "\012C\011ommit", INPUT_KEY_c, NULL, menu_media_ide_commit, NULL, 3 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_ide_eject, NULL, 3 }, - { NULL } -}; - -static widget_menu_entry menu_media_ide_zxatasp_slave[] = { - { "Slave" }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_ide_insert, NULL, 4 }, - { "\012C\011ommit", INPUT_KEY_c, NULL, menu_media_ide_commit, NULL, 4 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_ide_eject, NULL, 4 }, - { NULL } -}; - -static widget_menu_entry menu_media_ide_zxatasp[] = { - { "ZXATASP" }, - { "\012M\011aster", INPUT_KEY_m, menu_media_ide_zxatasp_master, NULL, NULL, 0 }, - { "\012S\011lave", INPUT_KEY_s, menu_media_ide_zxatasp_slave, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_ide_zxcfcompactflash[] = { - { "ZXCF CompactFlash" }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_ide_insert, NULL, 5 }, - { "\012C\011ommit", INPUT_KEY_c, NULL, menu_media_ide_commit, NULL, 5 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_ide_eject, NULL, 5 }, - { NULL } -}; - -static widget_menu_entry menu_media_ide_divide_master[] = { - { "Master" }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_ide_insert, NULL, 6 }, - { "\012C\011ommit", INPUT_KEY_c, NULL, menu_media_ide_commit, NULL, 6 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_ide_eject, NULL, 6 }, - { NULL } -}; - -static widget_menu_entry menu_media_ide_divide_slave[] = { - { "Slave" }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_ide_insert, NULL, 7 }, - { "\012C\011ommit", INPUT_KEY_c, NULL, menu_media_ide_commit, NULL, 7 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_ide_eject, NULL, 7 }, - { NULL } -}; - -static widget_menu_entry menu_media_ide_divide[] = { - { "DivIDE" }, - { "\012M\011aster", INPUT_KEY_m, menu_media_ide_divide_master, NULL, NULL, 0 }, - { "\012S\011lave", INPUT_KEY_s, menu_media_ide_divide_slave, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media_ide_divmmc[] = { - { "DivMMC" }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_ide_insert, NULL, 8 }, - { "\012C\011ommit", INPUT_KEY_c, NULL, menu_media_ide_commit, NULL, 8 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_ide_eject, NULL, 8 }, - { NULL } -}; - -static widget_menu_entry menu_media_ide_zxmmc[] = { - { "ZXMMC" }, - { "\012I\011nsert...", INPUT_KEY_i, NULL, menu_media_ide_insert, NULL, 9 }, - { "\012C\011ommit", INPUT_KEY_c, NULL, menu_media_ide_commit, NULL, 9 }, - { "\012E\011ject", INPUT_KEY_e, NULL, menu_media_ide_eject, NULL, 9 }, - { NULL } -}; - -static widget_menu_entry menu_media_ide[] = { - { "IDE" }, - { "Simple \0128\011-bit", INPUT_KEY_8, menu_media_ide_simple8bit, NULL, NULL, 0 }, - { "ZX\012A\011TASP", INPUT_KEY_a, menu_media_ide_zxatasp, NULL, NULL, 0 }, - { "ZX\012C\011F CompactFlash", INPUT_KEY_c, menu_media_ide_zxcfcompactflash, NULL, NULL, 0 }, - { "\012D\011ivIDE", INPUT_KEY_d, menu_media_ide_divide, NULL, NULL, 0 }, - { "\012D\011ivMMC", INPUT_KEY_d, menu_media_ide_divmmc, NULL, NULL, 0 }, - { "\012Z\011XMMC", INPUT_KEY_z, menu_media_ide_zxmmc, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_media[] = { - { "Media" }, - { "\012T\011ape", INPUT_KEY_t, menu_media_tape, NULL, menu_tape_detail, 0 }, - { "\012I\011nterface 1", INPUT_KEY_i, menu_media_interface1, NULL, NULL, 0 }, - { "\012D\011isk", INPUT_KEY_d, menu_media_disk, NULL, NULL, 0 }, - { "\012C\011artridge", INPUT_KEY_c, menu_media_cartridge, NULL, NULL, 0 }, - { "ID\012E\011", INPUT_KEY_e, menu_media_ide, NULL, NULL, 0 }, - { NULL } -}; - -static widget_menu_entry menu_help[] = { - { "Help" }, - { "\012K\011eyboard...", INPUT_KEY_k, NULL, menu_help_keyboard, NULL, 0 }, - { "\012A\011bout...", INPUT_KEY_a, NULL, menu_help_about, NULL, 0 }, - { NULL } -}; - -widget_menu_entry widget_menu[] = { - { "Main menu" }, - { "\012F\011ile", INPUT_KEY_f, menu_file, NULL, NULL, 0 }, - { "\012O\011ptions", INPUT_KEY_o, menu_options, NULL, NULL, 0 }, - { "\012M\011achine", INPUT_KEY_m, menu_machine, NULL, NULL, 0 }, - { "M\012e\011dia", INPUT_KEY_e, menu_media, NULL, NULL, 0 }, - { "\012H\011elp", INPUT_KEY_h, menu_help, NULL, NULL, 0 }, - { NULL } -}; - diff --git a/fuse/ui/widget/mkfusefont.pl b/fuse/ui/widget/mkfusefont.pl deleted file mode 100755 index 511ff7c..0000000 --- a/fuse/ui/widget/mkfusefont.pl +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/perl -w - -# mkfusefont.pl: generate Fuse-format font from a .sbf file -# (ASCII representation of a .psf (console font) file) -# Copyright (c) 2004 Darren Salt - -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free -# Software Foundation; either version 2 of the License, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. - -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Author contact information: - -# E-mail: linux@youmustbejoking.demon.co.uk - -use strict; -use POSIX; - -die "sorry, I output binary data\n" if isatty( *STDOUT ); - -my $line; - -MAIN: while( defined( $line = <> ) ) { - chomp $line; - next unless $line =~ /^\[U\+([[:xdigit:]]{4})]$/; - - my @codes = ( hex $1 ); - while( 1 ) { - last MAIN unless defined( $line = <> ); - - chomp $line; - - next MAIN if $line eq '' or $line =~ /^[[:space:]]*#/; - last if $line =~ /^[.0]+$/; - die unless $line =~ /^\[U\+([[:xdigit:]]{4})]$/; - - push @codes, hex $1; - } - @codes = grep { $_ < 0xD800 || ($_ >= 0xE000 && $_ < 0xFFFE) } @codes; - - my @pixmap = ( '','','','', '','','','', '','','','', '','','' ); - my $i; - - for( $i = 0; $i < 8; $i++ ) { - chomp $line; - die unless $line =~ /^[.0]+$/; - $line =~ tr/.0/01/; - die "pixmap line too long" if length ($line) > 15; - $line .= '0' x ( 15 - length $line ); - for( my $j = 0; $j < 15; $j++ ) { $pixmap[$j] .= substr( $line, $j, 1 ); } - - die unless $i == 7 or defined( $line = <> ); - } - - my $left = 0; - pop @pixmap while @pixmap && $pixmap[ -1 ] eq '00000000'; - while( @pixmap && $pixmap[0] eq '00000000' ) { $left++; shift @pixmap; } - my @bitmap = map { oct ('0b'.$_) } @pixmap; - - print pack( "C*", $_ & 255, $_ >> 8, $left | @bitmap << 4, @bitmap ) - foreach @codes; -} diff --git a/fuse/ui/widget/options-header.pl b/fuse/ui/widget/options-header.pl deleted file mode 100755 index b701454..0000000 --- a/fuse/ui/widget/options-header.pl +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/perl -w - -# options-header.pl: generate options dialog boxes -# Copyright (c) 2001-2002,2004 Philip Kendall - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Author contact information: - -# E-mail: philip-fuse@shadowmagic.org.uk - -use strict; - -use Fuse; -use Fuse::Dialog; - -die "No data file specified" unless @ARGV; - -my @dialogs = Fuse::Dialog::read( shift @ARGV ); -my $internal = 1; - -$internal = 0 if( @ARGV && shift( @ARGV ) eq 'public' ); - -if( $internal ) { - print Fuse::GPL( 'options_internals.h: options dialog boxes', - '2001-2002,2004 Philip Kendall' ); -} else { - print Fuse::GPL( 'options.h: options dialog boxes public declarations', - '2001-2002,2004 Philip Kendall' ); -} - -print << "CODE"; - -/* This file is autogenerated from options.dat by options-header.pl. - Do not edit unless you know what you\'re doing! */ - -CODE -if( $internal ) { - print << "CODE"; -#ifndef FUSE_WIDGETOPTIONS_INTERNALS_H -#define FUSE_WIDGETOPTIONS_INTERNALS_H - -#ifndef FUSE_SETTINGS_H -#include "settings.h" -#endif - -#ifndef FUSE_WIDGET_H -#include "ui/widget/widget.h" -#endif - -extern settings_info widget_options_settings; - -CODE -} else { - print << "CODE"; -#ifndef FUSE_OPTIONS_H -#define FUSE_OPTIONS_H - -CODE -} - -if( $internal ) { - foreach( @dialogs ) { - - print << "CODE"; -int widget_$_->{name}_draw( void *data ); -void widget_$_->{name}_keyhandler( input_key key ); - -CODE - } -} else { - foreach( @dialogs ) { - foreach my $widget ( @{ $_->{widgets} } ) { - if( $widget->{type} eq "Combo" ) { - print <<"CODE"; -int option_enumerate_$_->{name}_$widget->{value}( void ); - -CODE - } - } - } -} - -if( $internal ) { - print << "CODE"; -#endif /* #ifndef FUSE_WIDGETOPTIONS_INTERNALS_H */ -CODE -} else { - print << "CODE"; -#endif /* #ifndef FUSE_OPTIONS_H */ -CODE -} diff --git a/fuse/ui/widget/options.c b/fuse/ui/widget/options.c deleted file mode 100644 index 299bed3..0000000 --- a/fuse/ui/widget/options.c +++ /dev/null @@ -1,3004 +0,0 @@ -/* options.c: options dialog boxes - Copyright (c) 2001-2013 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -/* This file is autogenerated from options.dat by options.pl. - Do not edit unless you know what you're doing! */ - -#include - -#ifdef USE_WIDGET - -#include -#include - -#include "display.h" -#include "fuse.h" -#include "options.h" -#include "options_internals.h" -#include "periph.h" -#include "ui/widget/widget_internals.h" -#include "ui/uidisplay.h" - -struct widget_option_entry; - -/* A generic click function */ -typedef void (*widget_option_click_fn)( void ); -typedef void (*widget_option_draw_fn)( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); - -/* A general menu */ -typedef struct widget_option_entry { - const char *text; - int index; - input_key key; /* Which key to activate this option */ - const char *suffix; - const char * const *options; - - widget_option_click_fn click; - widget_option_draw_fn draw; -} widget_option_entry; - -static void -widget_combo_click( const char *title, const char * const *options, char **current, int def ) -{ - int error, i; - widget_select_t sel; - - sel.title = title; - sel.options = options; - sel.current = def; - sel.finish_all = 0; - for( i = 0; options[i] != NULL; i++ ) { - if( *current != NULL && !strcmp( options[ i ], *current ) ) - sel.current = i; - } - sel.count = i; - - error = widget_do_select( &sel ); - - if( !error && sel.result >= 0 ) { - if( *current ) free( *current ); - *current = strdup( options[ sel.result ] ); - } -} - -static int -option_enumerate_combo( const char * const *options, char *value, int def ) { - int i; - if( value != NULL ) { - for( i = 0; options[i] != NULL; i++) { - if( !strcmp( value, options[ i ] ) ) - return i; - } - } - return def; -} - -static const char * const widget_phantom_typist_mode_combo[] = { - "Auto", - "Keyword", - "Keystroke", - "Menu", - "Plus 2A", - "Plus 3", - NULL -}; - -int -option_enumerate_media_phantom_typist_mode( void ) { - return option_enumerate_combo( widget_phantom_typist_mode_combo, - settings_current.phantom_typist_mode, - 0 ); -} - -static const char * const widget_stereo_ay_combo[] = { - "None", - "ACB", - "ABC", - NULL -}; - -int -option_enumerate_sound_stereo_ay( void ) { - return option_enumerate_combo( widget_stereo_ay_combo, - settings_current.stereo_ay, - 0 ); -} - -static const char * const widget_speaker_type_combo[] = { - "TV speaker", - "Beeper", - "Unfiltered", - NULL -}; - -int -option_enumerate_sound_speaker_type( void ) { - return option_enumerate_combo( widget_speaker_type_combo, - settings_current.speaker_type, - 0 ); -} - -static const char * const widget_drive_plus3a_type_combo[] = { - "Single-sided 40 track", - "Double-sided 40 track", - "Single-sided 80 track", - "Double-sided 80 track", - NULL -}; - -int -option_enumerate_diskoptions_drive_plus3a_type( void ) { - return option_enumerate_combo( widget_drive_plus3a_type_combo, - settings_current.drive_plus3a_type, - 0 ); -} - -static const char * const widget_drive_plus3b_type_combo[] = { - "Disabled", - "Single-sided 40 track", - "Double-sided 40 track", - "Single-sided 80 track", - "Double-sided 80 track", - NULL -}; - -int -option_enumerate_diskoptions_drive_plus3b_type( void ) { - return option_enumerate_combo( widget_drive_plus3b_type_combo, - settings_current.drive_plus3b_type, - 4 ); -} - -#define widget_drive_beta128a_type_combo widget_drive_plus3a_type_combo - -int -option_enumerate_diskoptions_drive_beta128a_type( void ) { - return option_enumerate_combo( widget_drive_beta128a_type_combo, - settings_current.drive_beta128a_type, - 3 ); -} - -#define widget_drive_beta128b_type_combo widget_drive_plus3b_type_combo - -int -option_enumerate_diskoptions_drive_beta128b_type( void ) { - return option_enumerate_combo( widget_drive_beta128b_type_combo, - settings_current.drive_beta128b_type, - 4 ); -} - -#define widget_drive_beta128c_type_combo widget_drive_plus3b_type_combo - -int -option_enumerate_diskoptions_drive_beta128c_type( void ) { - return option_enumerate_combo( widget_drive_beta128c_type_combo, - settings_current.drive_beta128c_type, - 4 ); -} - -#define widget_drive_beta128d_type_combo widget_drive_plus3b_type_combo - -int -option_enumerate_diskoptions_drive_beta128d_type( void ) { - return option_enumerate_combo( widget_drive_beta128d_type_combo, - settings_current.drive_beta128d_type, - 4 ); -} - -#define widget_drive_plusd1_type_combo widget_drive_plus3a_type_combo - -int -option_enumerate_diskoptions_drive_plusd1_type( void ) { - return option_enumerate_combo( widget_drive_plusd1_type_combo, - settings_current.drive_plusd1_type, - 3 ); -} - -#define widget_drive_plusd2_type_combo widget_drive_plus3b_type_combo - -int -option_enumerate_diskoptions_drive_plusd2_type( void ) { - return option_enumerate_combo( widget_drive_plusd2_type_combo, - settings_current.drive_plusd2_type, - 4 ); -} - -#define widget_drive_didaktik80a_type_combo widget_drive_plus3a_type_combo - -int -option_enumerate_diskoptions_drive_didaktik80a_type( void ) { - return option_enumerate_combo( widget_drive_didaktik80a_type_combo, - settings_current.drive_didaktik80a_type, - 3 ); -} - -#define widget_drive_didaktik80b_type_combo widget_drive_plus3b_type_combo - -int -option_enumerate_diskoptions_drive_didaktik80b_type( void ) { - return option_enumerate_combo( widget_drive_didaktik80b_type_combo, - settings_current.drive_didaktik80b_type, - 4 ); -} - -#define widget_drive_disciple1_type_combo widget_drive_plus3a_type_combo - -int -option_enumerate_diskoptions_drive_disciple1_type( void ) { - return option_enumerate_combo( widget_drive_disciple1_type_combo, - settings_current.drive_disciple1_type, - 3 ); -} - -#define widget_drive_disciple2_type_combo widget_drive_plus3b_type_combo - -int -option_enumerate_diskoptions_drive_disciple2_type( void ) { - return option_enumerate_combo( widget_drive_disciple2_type_combo, - settings_current.drive_disciple2_type, - 4 ); -} - -#define widget_drive_opus1_type_combo widget_drive_plus3a_type_combo - -int -option_enumerate_diskoptions_drive_opus1_type( void ) { - return option_enumerate_combo( widget_drive_opus1_type_combo, - settings_current.drive_opus1_type, - 0 ); -} - -#define widget_drive_opus2_type_combo widget_drive_plus3b_type_combo - -int -option_enumerate_diskoptions_drive_opus2_type( void ) { - return option_enumerate_combo( widget_drive_opus2_type_combo, - settings_current.drive_opus2_type, - 1 ); -} - -static const char * const widget_disk_try_merge_combo[] = { - "Never", - "With single-sided drives", - "Always", - NULL -}; - -int -option_enumerate_diskoptions_disk_try_merge( void ) { - return option_enumerate_combo( widget_disk_try_merge_combo, - settings_current.disk_try_merge, - 1 ); -} - -static const char * const widget_movie_compr_combo[] = { - "None", - "Lossless", - "High", - NULL -}; - -int -option_enumerate_movie_movie_compr( void ) { - return option_enumerate_combo( widget_movie_compr_combo, - settings_current.movie_compr, - 1 ); -} - -static int widget_general_running = 0; -static void widget_emulation_speed_click( void ); -static void widget_option_emulation_speed_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_frame_rate_click( void ); -static void widget_option_frame_rate_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_issue2_click( void ); -static void widget_option_issue2_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_recreated_spectrum_click( void ); -static void widget_option_recreated_spectrum_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_keyboard_arrows_shifted_click( void ); -static void widget_option_keyboard_arrows_shifted_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_writable_roms_click( void ); -static void widget_option_writable_roms_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_late_timings_click( void ); -static void widget_option_late_timings_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_z80_is_cmos_click( void ); -static void widget_option_z80_is_cmos_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_rs232_handshake_click( void ); -static void widget_option_rs232_handshake_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_bw_tv_click( void ); -static void widget_option_bw_tv_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_pal_tv2x_click( void ); -static void widget_option_pal_tv2x_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_statusbar_click( void ); -static void widget_option_statusbar_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_joy_prompt_click( void ); -static void widget_option_joy_prompt_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_confirm_actions_click( void ); -static void widget_option_confirm_actions_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_autosave_settings_click( void ); -static void widget_option_autosave_settings_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static int widget_media_running = 0; -static void widget_auto_load_click( void ); -static void widget_option_auto_load_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_phantom_typist_mode_click( void ); -static void widget_option_phantom_typist_mode_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_detect_loader_click( void ); -static void widget_option_detect_loader_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_fastload_click( void ); -static void widget_option_fastload_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_tape_traps_click( void ); -static void widget_option_tape_traps_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_accelerate_loader_click( void ); -static void widget_option_accelerate_loader_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_slt_traps_click( void ); -static void widget_option_slt_traps_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_mdr_len_click( void ); -static void widget_option_mdr_len_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_mdr_random_len_click( void ); -static void widget_option_mdr_random_len_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static int widget_peripherals_general_running = 0; -static void widget_joy_kempston_click( void ); -static void widget_option_joy_kempston_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_kempston_mouse_click( void ); -static void widget_option_kempston_mouse_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_mouse_swap_buttons_click( void ); -static void widget_option_mouse_swap_buttons_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_fuller_click( void ); -static void widget_option_fuller_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_melodik_click( void ); -static void widget_option_melodik_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_interface1_click( void ); -static void widget_option_interface1_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_interface2_click( void ); -static void widget_option_interface2_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_multiface1_click( void ); -static void widget_option_multiface1_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_multiface128_click( void ); -static void widget_option_multiface128_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_multiface3_click( void ); -static void widget_option_multiface3_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_multiface1_stealth_click( void ); -static void widget_option_multiface1_stealth_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_printer_click( void ); -static void widget_option_printer_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_zxprinter_click( void ); -static void widget_option_zxprinter_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_specdrum_click( void ); -static void widget_option_specdrum_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_ttx2000s_click( void ); -static void widget_option_ttx2000s_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_usource_click( void ); -static void widget_option_usource_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_covox_click( void ); -static void widget_option_covox_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static int widget_peripherals_disk_running = 0; -static void widget_simpleide_active_click( void ); -static void widget_option_simpleide_active_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_zxatasp_active_click( void ); -static void widget_option_zxatasp_active_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_zxatasp_upload_click( void ); -static void widget_option_zxatasp_upload_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_zxatasp_wp_click( void ); -static void widget_option_zxatasp_wp_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_zxcf_active_click( void ); -static void widget_option_zxcf_active_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_zxcf_upload_click( void ); -static void widget_option_zxcf_upload_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_divide_enabled_click( void ); -static void widget_option_divide_enabled_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_divide_wp_click( void ); -static void widget_option_divide_wp_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_divmmc_enabled_click( void ); -static void widget_option_divmmc_enabled_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_divmmc_wp_click( void ); -static void widget_option_divmmc_wp_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_plusd_click( void ); -static void widget_option_plusd_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_didaktik80_click( void ); -static void widget_option_didaktik80_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_disciple_click( void ); -static void widget_option_disciple_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_beta128_click( void ); -static void widget_option_beta128_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_beta128_48boot_click( void ); -static void widget_option_beta128_48boot_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_opus_click( void ); -static void widget_option_opus_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_zxmmc_enabled_click( void ); -static void widget_option_zxmmc_enabled_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static int widget_rzx_running = 0; -static void widget_rzx_autosaves_click( void ); -static void widget_option_rzx_autosaves_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_rzx_compression_click( void ); -static void widget_option_rzx_compression_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_competition_mode_click( void ); -static void widget_option_competition_mode_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_competition_code_click( void ); -static void widget_option_competition_code_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_embed_snapshot_click( void ); -static void widget_option_embed_snapshot_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static int widget_sound_running = 0; -static void widget_sound_click( void ); -static void widget_option_sound_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_sound_load_click( void ); -static void widget_option_sound_load_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_stereo_ay_click( void ); -static void widget_option_stereo_ay_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_sound_force_8bit_click( void ); -static void widget_option_sound_force_8bit_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_speaker_type_click( void ); -static void widget_option_speaker_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_volume_ay_click( void ); -static void widget_option_volume_ay_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_volume_beeper_click( void ); -static void widget_option_volume_beeper_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_volume_specdrum_click( void ); -static void widget_option_volume_specdrum_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_volume_covox_click( void ); -static void widget_option_volume_covox_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static int widget_diskoptions_running = 0; -static void widget_drive_plus3a_type_click( void ); -static void widget_option_drive_plus3a_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_drive_plus3b_type_click( void ); -static void widget_option_drive_plus3b_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_plus3_detect_speedlock_click( void ); -static void widget_option_plus3_detect_speedlock_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_drive_beta128a_type_click( void ); -static void widget_option_drive_beta128a_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_drive_beta128b_type_click( void ); -static void widget_option_drive_beta128b_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_drive_beta128c_type_click( void ); -static void widget_option_drive_beta128c_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_drive_beta128d_type_click( void ); -static void widget_option_drive_beta128d_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_drive_plusd1_type_click( void ); -static void widget_option_drive_plusd1_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_drive_plusd2_type_click( void ); -static void widget_option_drive_plusd2_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_drive_didaktik80a_type_click( void ); -static void widget_option_drive_didaktik80a_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_drive_didaktik80b_type_click( void ); -static void widget_option_drive_didaktik80b_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_drive_disciple1_type_click( void ); -static void widget_option_drive_disciple1_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_drive_disciple2_type_click( void ); -static void widget_option_drive_disciple2_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_drive_opus1_type_click( void ); -static void widget_option_drive_opus1_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_drive_opus2_type_click( void ); -static void widget_option_drive_opus2_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_disk_try_merge_click( void ); -static void widget_option_disk_try_merge_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_disk_ask_merge_click( void ); -static void widget_option_disk_ask_merge_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static int widget_movie_running = 0; -static void widget_movie_compr_click( void ); -static void widget_option_movie_compr_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -static void widget_movie_stop_after_rzx_click( void ); -static void widget_option_movie_stop_after_rzx_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); - -static widget_option_entry options_general[] = { - { "General Options" }, - { "\012E\001mulation speed", 0, INPUT_KEY_e, "%", NULL, widget_emulation_speed_click, widget_option_emulation_speed_draw }, - { "F\012r\001ame rate (1:n)", 1, INPUT_KEY_r, "frames", NULL, widget_frame_rate_click, widget_option_frame_rate_draw }, - { "Issue \0122\001 keyboard", 2, INPUT_KEY_2, NULL, NULL, widget_issue2_click, widget_option_issue2_draw }, - { "Recrea\012t\001ed ZX Spectrum", 3, INPUT_KEY_t, NULL, NULL, widget_recreated_spectrum_click, widget_option_recreated_spectrum_draw }, - { "Use shift with \012a\001rrow keys", 4, INPUT_KEY_a, NULL, NULL, widget_keyboard_arrows_shifted_click, widget_option_keyboard_arrows_shifted_draw }, - { "Allow \012w\001rites to ROM", 5, INPUT_KEY_w, NULL, NULL, widget_writable_roms_click, widget_option_writable_roms_draw }, - { "Late t\012i\001mings", 6, INPUT_KEY_i, NULL, NULL, widget_late_timings_click, widget_option_late_timings_draw }, - { "\012Z\00180 is CMOS", 7, INPUT_KEY_z, NULL, NULL, widget_z80_is_cmos_click, widget_option_z80_is_cmos_draw }, - { "RS-232 \012h\001andshake", 8, INPUT_KEY_h, NULL, NULL, widget_rs232_handshake_click, widget_option_rs232_handshake_draw }, - { "Black and white T\012V\001", 9, INPUT_KEY_v, NULL, NULL, widget_bw_tv_click, widget_option_bw_tv_draw }, - { "\012P\001AL-TV use TV2x effect", 10, INPUT_KEY_p, NULL, NULL, widget_pal_tv2x_click, widget_option_pal_tv2x_draw }, - { "Show status\012b\001ar", 11, INPUT_KEY_b, NULL, NULL, widget_statusbar_click, widget_option_statusbar_draw }, - { "Snap \012j\001oystick prompt", 12, INPUT_KEY_j, NULL, NULL, widget_joy_prompt_click, widget_option_joy_prompt_draw }, - { "\012C\001onfirm actions", 13, INPUT_KEY_c, NULL, NULL, widget_confirm_actions_click, widget_option_confirm_actions_draw }, - { "A\012u\001to-save settings", 14, INPUT_KEY_u, NULL, NULL, widget_autosave_settings_click, widget_option_autosave_settings_draw }, - { NULL } -}; - -static widget_option_entry options_media[] = { - { "Media Options" }, - { "\012A\001uto-load media", 0, INPUT_KEY_a, NULL, NULL, widget_auto_load_click, widget_option_auto_load_draw }, - { "\012P\001hantom typist mode", 1, INPUT_KEY_p, NULL, widget_phantom_typist_mode_combo, widget_phantom_typist_mode_click, widget_option_phantom_typist_mode_draw }, - { "\012D\001etect loaders", 2, INPUT_KEY_d, NULL, NULL, widget_detect_loader_click, widget_option_detect_loader_draw }, - { "\012F\001astloading", 3, INPUT_KEY_f, NULL, NULL, widget_fastload_click, widget_option_fastload_draw }, - { "Use \012t\001ape traps", 4, INPUT_KEY_t, NULL, NULL, widget_tape_traps_click, widget_option_tape_traps_draw }, - { "Accelerate l\012o\001aders", 5, INPUT_KEY_o, NULL, NULL, widget_accelerate_loader_click, widget_option_accelerate_loader_draw }, - { "Use .s\012l\001t traps", 6, INPUT_KEY_l, NULL, NULL, widget_slt_traps_click, widget_option_slt_traps_draw }, - { "\012M\001DR cartridge len", 7, INPUT_KEY_m, "blocks", NULL, widget_mdr_len_click, widget_option_mdr_len_draw }, - { "Random len\012g\001th MDR cartridge", 8, INPUT_KEY_g, NULL, NULL, widget_mdr_random_len_click, widget_option_mdr_random_len_draw }, - { NULL } -}; - -static widget_option_entry options_peripherals_general[] = { - { "General Peripheral Options" }, - { "\012K\001empston joystick", 0, INPUT_KEY_k, NULL, NULL, widget_joy_kempston_click, widget_option_joy_kempston_draw }, - { "Kempston \012m\001ouse", 1, INPUT_KEY_m, NULL, NULL, widget_kempston_mouse_click, widget_option_kempston_mouse_draw }, - { "\012S\001wap mouse buttons", 2, INPUT_KEY_s, NULL, NULL, widget_mouse_swap_buttons_click, widget_option_mouse_swap_buttons_draw }, - { "\012F\001uller Box", 3, INPUT_KEY_f, NULL, NULL, widget_fuller_click, widget_option_fuller_draw }, - { "M\012e\001lodik", 4, INPUT_KEY_e, NULL, NULL, widget_melodik_click, widget_option_melodik_draw }, - { "\012I\001nterface 1", 5, INPUT_KEY_i, NULL, NULL, widget_interface1_click, widget_option_interface1_draw }, - { "In\012t\001erface 2", 6, INPUT_KEY_t, NULL, NULL, widget_interface2_click, widget_option_interface2_draw }, - { "Mu\012l\001tiface One", 7, INPUT_KEY_l, NULL, NULL, widget_multiface1_click, widget_option_multiface1_draw }, - { "Multiface 12\0128\001", 8, INPUT_KEY_8, NULL, NULL, widget_multiface128_click, widget_option_multiface128_draw }, - { "Multiface \0123\001", 9, INPUT_KEY_3, NULL, NULL, widget_multiface3_click, widget_option_multiface3_draw }, - { "Stealt\012h\001 Multiface One", 10, INPUT_KEY_h, NULL, NULL, widget_multiface1_stealth_click, widget_option_multiface1_stealth_draw }, - { "Emulate \012p\001rinters", 11, INPUT_KEY_p, NULL, NULL, widget_printer_click, widget_option_printer_draw }, - { "\012Z\001X Printer", 12, INPUT_KEY_z, NULL, NULL, widget_zxprinter_click, widget_option_zxprinter_draw }, - { "Spec\012D\001rum interface", 13, INPUT_KEY_d, NULL, NULL, widget_specdrum_click, widget_option_specdrum_draw }, - { "TT\012X\0012000S", 14, INPUT_KEY_x, NULL, NULL, widget_ttx2000s_click, widget_option_ttx2000s_draw }, - { "uSo\012u\001rce", 15, INPUT_KEY_u, NULL, NULL, widget_usource_click, widget_option_usource_draw }, - { "C\012o\001vox interface", 16, INPUT_KEY_o, NULL, NULL, widget_covox_click, widget_option_covox_draw }, - { NULL } -}; - -static widget_option_entry options_peripherals_disk[] = { - { "Disk Peripheral Options" }, - { "Simple \0128\001-bit IDE", 0, INPUT_KEY_8, NULL, NULL, widget_simpleide_active_click, widget_option_simpleide_active_draw }, - { "\012Z\001XATASP interface", 1, INPUT_KEY_z, NULL, NULL, widget_zxatasp_active_click, widget_option_zxatasp_active_draw }, - { "ZXATASP up\012l\001oad", 2, INPUT_KEY_l, NULL, NULL, widget_zxatasp_upload_click, widget_option_zxatasp_upload_draw }, - { "Z\012X\001ATASP write protect", 3, INPUT_KEY_x, NULL, NULL, widget_zxatasp_wp_click, widget_option_zxatasp_wp_draw }, - { "ZX\012C\001F interface", 4, INPUT_KEY_c, NULL, NULL, widget_zxcf_active_click, widget_option_zxcf_active_draw }, - { "ZXCF \012u\001pload", 5, INPUT_KEY_u, NULL, NULL, widget_zxcf_upload_click, widget_option_zxcf_upload_draw }, - { "Div\012I\001DE interface", 6, INPUT_KEY_i, NULL, NULL, widget_divide_enabled_click, widget_option_divide_enabled_draw }, - { "DivIDE \012w\001rite protect", 7, INPUT_KEY_w, NULL, NULL, widget_divide_wp_click, widget_option_divide_wp_draw }, - { "Div\012M\001MC interface", 8, INPUT_KEY_m, NULL, NULL, widget_divmmc_enabled_click, widget_option_divmmc_enabled_draw }, - { "DivMMC w\012r\001ite protect", 9, INPUT_KEY_r, NULL, NULL, widget_divmmc_wp_click, widget_option_divmmc_wp_draw }, - { "+\012D\001 interface", 10, INPUT_KEY_d, NULL, NULL, widget_plusd_click, widget_option_plusd_draw }, - { "Dida\012k\001tik 80 interface", 11, INPUT_KEY_k, NULL, NULL, widget_didaktik80_click, widget_option_didaktik80_draw }, - { "DISCi\012P\001LE interf(a)ce", 12, INPUT_KEY_p, NULL, NULL, widget_disciple_click, widget_option_disciple_draw }, - { "\012B\001eta 128 interface", 13, INPUT_KEY_b, NULL, NULL, widget_beta128_click, widget_option_beta128_draw }, - { "Beta 128 \012a\001uto-boot in 48K machines", 14, INPUT_KEY_a, NULL, NULL, widget_beta128_48boot_click, widget_option_beta128_48boot_draw }, - { "\012O\001pus Discovery interface", 15, INPUT_KEY_o, NULL, NULL, widget_opus_click, widget_option_opus_draw }, - { "ZXMMC i\012n\001terface", 16, INPUT_KEY_n, NULL, NULL, widget_zxmmc_enabled_click, widget_option_zxmmc_enabled_draw }, - { NULL } -}; - -static widget_option_entry options_rzx[] = { - { "RZX Options" }, - { "Create \012a\001utosaves", 0, INPUT_KEY_a, NULL, NULL, widget_rzx_autosaves_click, widget_option_rzx_autosaves_draw }, - { "\012C\001ompress RZX data", 1, INPUT_KEY_c, NULL, NULL, widget_rzx_compression_click, widget_option_rzx_compression_draw }, - { "C\012o\001mpetition mode", 2, INPUT_KEY_o, NULL, NULL, widget_competition_mode_click, widget_option_competition_mode_draw }, - { "Co\012m\001petition code", 3, INPUT_KEY_m, "", NULL, widget_competition_code_click, widget_option_competition_code_draw }, - { "Always \012e\001mbed snapshot", 4, INPUT_KEY_e, NULL, NULL, widget_embed_snapshot_click, widget_option_embed_snapshot_draw }, - { NULL } -}; - -static widget_option_entry options_sound[] = { - { "Sound Options" }, - { "\012S\001ound enabled", 0, INPUT_KEY_s, NULL, NULL, widget_sound_click, widget_option_sound_draw }, - { "\012L\001oading sound", 1, INPUT_KEY_l, NULL, NULL, widget_sound_load_click, widget_option_sound_load_draw }, - { "\012A\001Y stereo separation", 2, INPUT_KEY_a, NULL, widget_stereo_ay_combo, widget_stereo_ay_click, widget_option_stereo_ay_draw }, - { "\012F\001orce 8-bit", 3, INPUT_KEY_f, NULL, NULL, widget_sound_force_8bit_click, widget_option_sound_force_8bit_draw }, - { "Speaker \012t\001ype", 4, INPUT_KEY_t, NULL, widget_speaker_type_combo, widget_speaker_type_click, widget_option_speaker_type_draw }, - { "A\012Y\001 volume", 5, INPUT_KEY_y, "%", NULL, widget_volume_ay_click, widget_option_volume_ay_draw }, - { "B\012e\001eper volume", 6, INPUT_KEY_e, "%", NULL, widget_volume_beeper_click, widget_option_volume_beeper_draw }, - { "Spec\012D\001rum volume", 7, INPUT_KEY_d, "%", NULL, widget_volume_specdrum_click, widget_option_volume_specdrum_draw }, - { "\012C\001ovox volume", 8, INPUT_KEY_c, "%", NULL, widget_volume_covox_click, widget_option_volume_covox_draw }, - { NULL } -}; - -static widget_option_entry options_diskoptions[] = { - { "Drives Setup" }, - { "+\0123\001 Drive A", 0, INPUT_KEY_3, NULL, widget_drive_plus3a_type_combo, widget_drive_plus3a_type_click, widget_option_drive_plus3a_type_draw }, - { "+3 Driv\012e\001 B", 1, INPUT_KEY_e, NULL, widget_drive_plus3b_type_combo, widget_drive_plus3b_type_click, widget_option_drive_plus3b_type_draw }, - { "+3 Detect \012S\001peedlock", 2, INPUT_KEY_s, NULL, NULL, widget_plus3_detect_speedlock_click, widget_option_plus3_detect_speedlock_draw }, - { "Beta 128 Drive \012A\001", 3, INPUT_KEY_a, NULL, widget_drive_beta128a_type_combo, widget_drive_beta128a_type_click, widget_option_drive_beta128a_type_draw }, - { "Beta 128 Drive \012B\001", 4, INPUT_KEY_b, NULL, widget_drive_beta128b_type_combo, widget_drive_beta128b_type_click, widget_option_drive_beta128b_type_draw }, - { "Beta 128 Drive \012C\001", 5, INPUT_KEY_c, NULL, widget_drive_beta128c_type_combo, widget_drive_beta128c_type_click, widget_option_drive_beta128c_type_draw }, - { "Beta 128 Drive \012D\001", 6, INPUT_KEY_d, NULL, widget_drive_beta128d_type_combo, widget_drive_beta128d_type_click, widget_option_drive_beta128d_type_draw }, - { "+D Drive \0121\001", 7, INPUT_KEY_1, NULL, widget_drive_plusd1_type_combo, widget_drive_plusd1_type_click, widget_option_drive_plusd1_type_draw }, - { "+D Drive \0122\001", 8, INPUT_KEY_2, NULL, widget_drive_plusd2_type_combo, widget_drive_plusd2_type_click, widget_option_drive_plusd2_type_draw }, - { "Didaktik \0128\0010 Drive A", 9, INPUT_KEY_8, NULL, widget_drive_didaktik80a_type_combo, widget_drive_didaktik80a_type_click, widget_option_drive_didaktik80a_type_draw }, - { "Dida\012k\001tik 80 Drive B", 10, INPUT_KEY_k, NULL, widget_drive_didaktik80b_type_combo, widget_drive_didaktik80b_type_click, widget_option_drive_didaktik80b_type_draw }, - { "DI\012S\001CiPLE Drive 1", 11, INPUT_KEY_s, NULL, widget_drive_disciple1_type_combo, widget_drive_disciple1_type_click, widget_option_drive_disciple1_type_draw }, - { "DISCiP\012L\001E Drive 2", 12, INPUT_KEY_l, NULL, widget_drive_disciple2_type_combo, widget_drive_disciple2_type_click, widget_option_drive_disciple2_type_draw }, - { "\012O\001pus Drive 1", 13, INPUT_KEY_o, NULL, widget_drive_opus1_type_combo, widget_drive_opus1_type_click, widget_option_drive_opus1_type_draw }, - { "O\012p\001us Drive 2", 14, INPUT_KEY_p, NULL, widget_drive_opus2_type_combo, widget_drive_opus2_type_click, widget_option_drive_opus2_type_draw }, - { "\012T\001ry merge 'B' side of disks", 15, INPUT_KEY_t, NULL, widget_disk_try_merge_combo, widget_disk_try_merge_click, widget_option_disk_try_merge_draw }, - { "Con\012f\001irm merge disk sides", 16, INPUT_KEY_f, NULL, NULL, widget_disk_ask_merge_click, widget_option_disk_ask_merge_draw }, - { NULL } -}; - -static widget_option_entry options_movie[] = { - { "Movie Options" }, - { "Movie \012c\001ompression", 0, INPUT_KEY_c, NULL, widget_movie_compr_combo, widget_movie_compr_click, widget_option_movie_compr_draw }, - { "\012S\001top recording after RZX ends", 1, INPUT_KEY_S, NULL, NULL, widget_movie_stop_after_rzx_click, widget_option_movie_stop_after_rzx_draw }, - { NULL } -}; - -static size_t highlight_line = 0; - -/* General functions used by the options dialogs */ -settings_info widget_options_settings; -int widget_options_print_option( int left_edge, int width, int number, const char* string, int value ); -int widget_options_print_value( int left_edge, int width, int number, int value ); -int widget_options_print_entry( int left_edge, int width, int number, const char *prefix, int value, - const char *suffix ); -int widget_options_print_combo( int left_edge, int width, int number, const char *prefix, - const char * const *options, const char *value, int def ); - -static int widget_options_print_label( int left_edge, int width, int number, const char *string ); -static int widget_options_print_data( int left_edge, int menu_width, int number, const char *string, int tcolor ); -static int widget_calculate_option_width(widget_option_entry *menu); - -static int -widget_options_show_all( widget_option_entry *options, settings_info *show ) -{ - widget_option_entry *ptr; - size_t height = 0; - int menu_width = widget_calculate_option_width( options ); - int menu_left_edge_x; - - /* How many options do we have? */ - for( ptr = &options[1]; ptr->text; ptr++ ) - height ++; - - menu_left_edge_x = DISPLAY_WIDTH_COLS/2-menu_width/2; - - /* Draw the dialog box */ - widget_dialog_with_border( menu_left_edge_x, 2, menu_width, 2 + height ); - - widget_printstring( menu_left_edge_x*8+2, 16, WIDGET_COLOUR_TITLE, options->text ); - - for( ptr = &options[1]; ptr->text; ptr++ ) { - ptr->draw( menu_left_edge_x, menu_width, ptr, show ); - } - - widget_display_lines( 2, 2 + height ); - - return 0; -} - -int -widget_options_print_option( int left_edge, int width, int number, const char* string, int value ) -{ - widget_options_print_label( left_edge, width, number, string ); - widget_options_print_value( left_edge, width, number, value ); - return 0; -} - -static int -widget_options_print_label( int left_edge, int width, int number, const char *string ) -{ - char buffer[128]; - size_t l, w; - int colour = WIDGET_COLOUR_BACKGROUND; - - if( number == highlight_line ) colour = WIDGET_COLOUR_HIGHLIGHT; - widget_rectangle( left_edge*8+1, number*8+24, width*8-2, 1*8, colour ); - - snprintf( buffer, sizeof( buffer ), "%s", string ); - l = strlen( buffer ); - - if( l >= sizeof( buffer ) ) - l = sizeof( buffer ) - 1; - while( ( w = widget_substringwidth( string, l ) ) >= (left_edge+width-2)*8 ) - --l; - buffer[l] = '\0'; - w = widget_printstring( left_edge*8+8, number*8+24, WIDGET_COLOUR_FOREGROUND, buffer ) - - 1; - while ((w += 3) < (left_edge+width-1)*8-2) - widget_putpixel (w, number*8+31, 0); - return 0; -} - -int -widget_options_print_value( int left_edge, int width, int number, int value ) -{ - int colour = WIDGET_COLOUR_BACKGROUND; - int x = (left_edge+width-2)*8-2; - int y = number * 8 + 24; - - if( number == highlight_line ) colour = WIDGET_COLOUR_HIGHLIGHT; - widget_rectangle( x, y, 8, 8, colour ); - widget_print_checkbox( x, y, colour, value ); - widget_display_rasters( y, 8 ); - return 0; -} - -static int -widget_options_print_data( int left_edge, int menu_width, int number, const char *string, int tcolor ) -{ - int colour = WIDGET_COLOUR_BACKGROUND; - size_t width = widget_stringwidth( string ); - int x = (left_edge + menu_width-1)*8 - width - 2; - int y = number * 8 + 24; - - if( number == highlight_line ) colour = WIDGET_COLOUR_HIGHLIGHT; - widget_rectangle( x, y, width, 8, colour ); - widget_printstring( x, y, tcolor, string ); - widget_display_rasters( y, 8 ); - - return 0; -} - -int -widget_options_print_entry( int left_edge, int width, int number, const char *prefix, int value, - const char *suffix ) -{ - char buffer[128]; - widget_options_print_label( left_edge, width, number, prefix ); - snprintf( buffer, sizeof( buffer ), "%d %s", value, suffix ); - return widget_options_print_data( left_edge, width, number, buffer, WIDGET_COLOUR_FOREGROUND ); -} - -int -widget_options_print_combo( int left_edge, int width, int number, const char *prefix, - const char * const *option, const char *value, int def ) -{ - int i = 0; - const char *c; - char buffer[64]; - - c = option[ def ]; - if( value != NULL ) { - while( option[ i ] != NULL ) { - if( !strcmp( option[ i ], value ) ) - c = option[ i ]; - i++; - } - } - widget_options_print_label( left_edge, width, number, prefix ); - snprintf( buffer, sizeof( buffer ), "%s", c ); - return widget_options_print_data( left_edge, width, number, buffer, WIDGET_COLOUR_DISABLED ); -} - -int -widget_options_finish( widget_finish_state finished ) -{ - int error; - int needs_hard_reset; - - /* If we exited normally, actually set the options */ - if( finished == WIDGET_FINISHED_OK ) { - /* Get a copy of current settings */ - settings_info original_settings; - memset( &original_settings, 0, sizeof( settings_info ) ); - settings_copy( &original_settings, &settings_current ); - - /* Apply new options */ - settings_copy( &settings_current, &widget_options_settings ); - - needs_hard_reset = periph_postcheck(); - - if( needs_hard_reset ) { - error = widget_do_query( "Some options need to reset the machine. Reset?" ); - if( !error && !widget_query.confirm ) - settings_copy( &settings_current, &original_settings ); - else - periph_posthook(); - } - else { - /* Bring the peripherals list into sync with the new options */ - periph_posthook(); - } - - settings_free( &original_settings ); - - /* make the needed UI changes */ - uidisplay_hotswap_gfx_mode(); - } - settings_free( &widget_options_settings ); - memset( &widget_options_settings, 0, sizeof( settings_info ) ); - - return 0; -} - -const int options_vert_external_margin = 8; - -static int -widget_calculate_option_width(widget_option_entry *menu) -{ - widget_option_entry *ptr; - int max_width=0; - - if (!menu) { - return 64; - } - - max_width = widget_stringwidth( menu->text )+5*8; - - for( ptr = &menu[1]; ptr->text; ptr++ ) { - int total_width = widget_stringwidth(ptr->text)+3*8; - - /* If this is a number format, leave room for 4 digits as well as the - text */ - if( ptr->suffix ) total_width += widget_stringwidth(ptr->suffix)+4*8; - if( ptr->options ) { - int combo_width = 0; - const char * const *options = ptr->options; - while( *options != NULL ) { - if( combo_width < widget_stringwidth( *options ) ) - combo_width = widget_stringwidth( *options ); - options++; - } - total_width += combo_width; - } - - if (total_width > max_width) - max_width = total_width; - } - - return (max_width+options_vert_external_margin*2)/8; -} - - -int -widget_general_draw( void *data GCC_UNUSED ) -{ - int error; - - if( !widget_general_running ) { /* we want to copy settings, only when start up */ - highlight_line = 0; - /* Get a copy of the current settings */ - settings_copy( &widget_options_settings, &settings_current ); - widget_general_running = 1; - } - - error = widget_options_show_all( options_general, &widget_options_settings ); - if( error ) { settings_free( &widget_options_settings ); return error; } - - return 0; -} - -static void -widget_emulation_speed_click( void ) -{ - widget_text_t text_data; - - text_data.title = "Emulation speed"; - text_data.allow = WIDGET_INPUT_DIGIT; - text_data.max_length = 5; - snprintf( text_data.text, 40, "%d", - widget_options_settings.emulation_speed ); - widget_do_text( &text_data ); - - if( widget_text_text ) { - widget_options_settings.emulation_speed = atoi( widget_text_text ); - } -} - -static void -widget_option_emulation_speed_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_entry( left_edge, width, menu->index, menu->text, show->emulation_speed, - menu->suffix ); -} - -static void -widget_frame_rate_click( void ) -{ - widget_text_t text_data; - - text_data.title = "Frame rate (1:n)"; - text_data.allow = WIDGET_INPUT_DIGIT; - text_data.max_length = 1; - snprintf( text_data.text, 40, "%d", - widget_options_settings.frame_rate ); - widget_do_text( &text_data ); - - if( widget_text_text ) { - widget_options_settings.frame_rate = atoi( widget_text_text ); - } -} - -static void -widget_option_frame_rate_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_entry( left_edge, width, menu->index, menu->text, show->frame_rate, - menu->suffix ); -} - -static void -widget_issue2_click( void ) -{ - widget_options_settings.issue2 = ! widget_options_settings.issue2; -} - -static void -widget_option_issue2_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->issue2 ); -} - -static void -widget_recreated_spectrum_click( void ) -{ - widget_options_settings.recreated_spectrum = ! widget_options_settings.recreated_spectrum; -} - -static void -widget_option_recreated_spectrum_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->recreated_spectrum ); -} - -static void -widget_keyboard_arrows_shifted_click( void ) -{ - widget_options_settings.keyboard_arrows_shifted = ! widget_options_settings.keyboard_arrows_shifted; -} - -static void -widget_option_keyboard_arrows_shifted_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->keyboard_arrows_shifted ); -} - -static void -widget_writable_roms_click( void ) -{ - widget_options_settings.writable_roms = ! widget_options_settings.writable_roms; -} - -static void -widget_option_writable_roms_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->writable_roms ); -} - -static void -widget_late_timings_click( void ) -{ - widget_options_settings.late_timings = ! widget_options_settings.late_timings; -} - -static void -widget_option_late_timings_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->late_timings ); -} - -static void -widget_z80_is_cmos_click( void ) -{ - widget_options_settings.z80_is_cmos = ! widget_options_settings.z80_is_cmos; -} - -static void -widget_option_z80_is_cmos_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->z80_is_cmos ); -} - -static void -widget_rs232_handshake_click( void ) -{ - widget_options_settings.rs232_handshake = ! widget_options_settings.rs232_handshake; -} - -static void -widget_option_rs232_handshake_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->rs232_handshake ); -} - -static void -widget_bw_tv_click( void ) -{ - widget_options_settings.bw_tv = ! widget_options_settings.bw_tv; -} - -static void -widget_option_bw_tv_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->bw_tv ); -} - -static void -widget_pal_tv2x_click( void ) -{ - widget_options_settings.pal_tv2x = ! widget_options_settings.pal_tv2x; -} - -static void -widget_option_pal_tv2x_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->pal_tv2x ); -} - -static void -widget_statusbar_click( void ) -{ - widget_options_settings.statusbar = ! widget_options_settings.statusbar; -} - -static void -widget_option_statusbar_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->statusbar ); -} - -static void -widget_joy_prompt_click( void ) -{ - widget_options_settings.joy_prompt = ! widget_options_settings.joy_prompt; -} - -static void -widget_option_joy_prompt_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->joy_prompt ); -} - -static void -widget_confirm_actions_click( void ) -{ - widget_options_settings.confirm_actions = ! widget_options_settings.confirm_actions; -} - -static void -widget_option_confirm_actions_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->confirm_actions ); -} - -static void -widget_autosave_settings_click( void ) -{ - widget_options_settings.autosave_settings = ! widget_options_settings.autosave_settings; -} - -static void -widget_option_autosave_settings_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->autosave_settings ); -} - -void -widget_general_keyhandler( input_key key ) -{ - int new_highlight_line = 0; - int cursor_pressed = 0; - widget_option_entry *ptr; - int menu_width = widget_calculate_option_width(options_general); - int menu_left_edge_x = DISPLAY_WIDTH_COLS/2-menu_width/2; - - switch( key ) { - -#if 0 - case INPUT_KEY_Resize: /* Fake keypress used on window resize */ - widget_dialog_with_border( 1, 2, 30, 2 + 15 ); - widget_general_show_all( &widget_options_settings ); - break; -#endif - - case INPUT_KEY_Escape: - case INPUT_JOYSTICK_FIRE_2: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - widget_general_running = 0; - break; - - case INPUT_KEY_Up: - case INPUT_KEY_7: - case INPUT_JOYSTICK_UP: - if ( highlight_line ) { - new_highlight_line = highlight_line - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Down: - case INPUT_KEY_6: - case INPUT_JOYSTICK_DOWN: - if ( highlight_line + 1 < 15 ) { - new_highlight_line = highlight_line + 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Home: - if ( highlight_line ) { - new_highlight_line = 0; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_End: - if ( highlight_line + 2 < 15 ) { - new_highlight_line = 15 - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_space: - case INPUT_KEY_0: - case INPUT_JOYSTICK_RIGHT: - options_general[highlight_line+1].click(); - options_general[highlight_line+1].draw( menu_left_edge_x, menu_width, options_general + highlight_line + 1, &widget_options_settings ); - return; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: - widget_end_all( WIDGET_FINISHED_OK ); - widget_general_running = 0; - display_refresh_all(); - return; - - default: /* Keep gcc happy */ - break; - - } - - if( cursor_pressed ) { - int old_highlight_line = highlight_line; - highlight_line = new_highlight_line; - options_general[old_highlight_line+1].draw( menu_left_edge_x, menu_width, options_general + old_highlight_line + 1, &widget_options_settings ); - options_general[highlight_line+1].draw( menu_left_edge_x, menu_width, options_general + highlight_line + 1, &widget_options_settings ); - return; - } - - for( ptr=&options_general[1]; ptr->text != NULL; ptr++ ) { - if( key == ptr->key ) { - int old_highlight_line = highlight_line; - ptr->click(); - highlight_line = ptr->index; - options_general[old_highlight_line+1].draw( menu_left_edge_x, menu_width, options_general + old_highlight_line + 1, &widget_options_settings ); - ptr->draw( menu_left_edge_x, menu_width, ptr, &widget_options_settings ); - break; - } - } -} - -int -widget_media_draw( void *data GCC_UNUSED ) -{ - int error; - - if( !widget_media_running ) { /* we want to copy settings, only when start up */ - highlight_line = 0; - /* Get a copy of the current settings */ - settings_copy( &widget_options_settings, &settings_current ); - widget_media_running = 1; - } - - error = widget_options_show_all( options_media, &widget_options_settings ); - if( error ) { settings_free( &widget_options_settings ); return error; } - - return 0; -} - -static void -widget_auto_load_click( void ) -{ - widget_options_settings.auto_load = ! widget_options_settings.auto_load; -} - -static void -widget_option_auto_load_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->auto_load ); -} - -static void -widget_phantom_typist_mode_click( void ) -{ - widget_combo_click( "Phantom typist mode", widget_phantom_typist_mode_combo, - &widget_options_settings.phantom_typist_mode, - 0 ); -} - -static void -widget_option_phantom_typist_mode_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->phantom_typist_mode, 0 ); -} - -static void -widget_detect_loader_click( void ) -{ - widget_options_settings.detect_loader = ! widget_options_settings.detect_loader; -} - -static void -widget_option_detect_loader_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->detect_loader ); -} - -static void -widget_fastload_click( void ) -{ - widget_options_settings.fastload = ! widget_options_settings.fastload; -} - -static void -widget_option_fastload_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->fastload ); -} - -static void -widget_tape_traps_click( void ) -{ - widget_options_settings.tape_traps = ! widget_options_settings.tape_traps; -} - -static void -widget_option_tape_traps_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->tape_traps ); -} - -static void -widget_accelerate_loader_click( void ) -{ - widget_options_settings.accelerate_loader = ! widget_options_settings.accelerate_loader; -} - -static void -widget_option_accelerate_loader_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->accelerate_loader ); -} - -static void -widget_slt_traps_click( void ) -{ - widget_options_settings.slt_traps = ! widget_options_settings.slt_traps; -} - -static void -widget_option_slt_traps_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->slt_traps ); -} - -static void -widget_mdr_len_click( void ) -{ - widget_text_t text_data; - - text_data.title = "MDR cartridge len"; - text_data.allow = WIDGET_INPUT_DIGIT; - text_data.max_length = 3; - snprintf( text_data.text, 40, "%d", - widget_options_settings.mdr_len ); - widget_do_text( &text_data ); - - if( widget_text_text ) { - widget_options_settings.mdr_len = atoi( widget_text_text ); - } -} - -static void -widget_option_mdr_len_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_entry( left_edge, width, menu->index, menu->text, show->mdr_len, - menu->suffix ); -} - -static void -widget_mdr_random_len_click( void ) -{ - widget_options_settings.mdr_random_len = ! widget_options_settings.mdr_random_len; -} - -static void -widget_option_mdr_random_len_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->mdr_random_len ); -} - -void -widget_media_keyhandler( input_key key ) -{ - int new_highlight_line = 0; - int cursor_pressed = 0; - widget_option_entry *ptr; - int menu_width = widget_calculate_option_width(options_media); - int menu_left_edge_x = DISPLAY_WIDTH_COLS/2-menu_width/2; - - switch( key ) { - -#if 0 - case INPUT_KEY_Resize: /* Fake keypress used on window resize */ - widget_dialog_with_border( 1, 2, 30, 2 + 9 ); - widget_media_show_all( &widget_options_settings ); - break; -#endif - - case INPUT_KEY_Escape: - case INPUT_JOYSTICK_FIRE_2: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - widget_media_running = 0; - break; - - case INPUT_KEY_Up: - case INPUT_KEY_7: - case INPUT_JOYSTICK_UP: - if ( highlight_line ) { - new_highlight_line = highlight_line - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Down: - case INPUT_KEY_6: - case INPUT_JOYSTICK_DOWN: - if ( highlight_line + 1 < 9 ) { - new_highlight_line = highlight_line + 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Home: - if ( highlight_line ) { - new_highlight_line = 0; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_End: - if ( highlight_line + 2 < 9 ) { - new_highlight_line = 9 - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_space: - case INPUT_KEY_0: - case INPUT_JOYSTICK_RIGHT: - options_media[highlight_line+1].click(); - options_media[highlight_line+1].draw( menu_left_edge_x, menu_width, options_media + highlight_line + 1, &widget_options_settings ); - return; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: - widget_end_all( WIDGET_FINISHED_OK ); - widget_media_running = 0; - display_refresh_all(); - return; - - default: /* Keep gcc happy */ - break; - - } - - if( cursor_pressed ) { - int old_highlight_line = highlight_line; - highlight_line = new_highlight_line; - options_media[old_highlight_line+1].draw( menu_left_edge_x, menu_width, options_media + old_highlight_line + 1, &widget_options_settings ); - options_media[highlight_line+1].draw( menu_left_edge_x, menu_width, options_media + highlight_line + 1, &widget_options_settings ); - return; - } - - for( ptr=&options_media[1]; ptr->text != NULL; ptr++ ) { - if( key == ptr->key ) { - int old_highlight_line = highlight_line; - ptr->click(); - highlight_line = ptr->index; - options_media[old_highlight_line+1].draw( menu_left_edge_x, menu_width, options_media + old_highlight_line + 1, &widget_options_settings ); - ptr->draw( menu_left_edge_x, menu_width, ptr, &widget_options_settings ); - break; - } - } -} - -int -widget_peripherals_general_draw( void *data GCC_UNUSED ) -{ - int error; - - if( !widget_peripherals_general_running ) { /* we want to copy settings, only when start up */ - highlight_line = 0; - /* Get a copy of the current settings */ - settings_copy( &widget_options_settings, &settings_current ); - widget_peripherals_general_running = 1; - } - - error = widget_options_show_all( options_peripherals_general, &widget_options_settings ); - if( error ) { settings_free( &widget_options_settings ); return error; } - - return 0; -} - -static void -widget_joy_kempston_click( void ) -{ - widget_options_settings.joy_kempston = ! widget_options_settings.joy_kempston; -} - -static void -widget_option_joy_kempston_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->joy_kempston ); -} - -static void -widget_kempston_mouse_click( void ) -{ - widget_options_settings.kempston_mouse = ! widget_options_settings.kempston_mouse; -} - -static void -widget_option_kempston_mouse_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->kempston_mouse ); -} - -static void -widget_mouse_swap_buttons_click( void ) -{ - widget_options_settings.mouse_swap_buttons = ! widget_options_settings.mouse_swap_buttons; -} - -static void -widget_option_mouse_swap_buttons_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->mouse_swap_buttons ); -} - -static void -widget_fuller_click( void ) -{ - widget_options_settings.fuller = ! widget_options_settings.fuller; -} - -static void -widget_option_fuller_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->fuller ); -} - -static void -widget_melodik_click( void ) -{ - widget_options_settings.melodik = ! widget_options_settings.melodik; -} - -static void -widget_option_melodik_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->melodik ); -} - -static void -widget_interface1_click( void ) -{ - widget_options_settings.interface1 = ! widget_options_settings.interface1; -} - -static void -widget_option_interface1_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->interface1 ); -} - -static void -widget_interface2_click( void ) -{ - widget_options_settings.interface2 = ! widget_options_settings.interface2; -} - -static void -widget_option_interface2_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->interface2 ); -} - -static void -widget_multiface1_click( void ) -{ - widget_options_settings.multiface1 = ! widget_options_settings.multiface1; -} - -static void -widget_option_multiface1_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->multiface1 ); -} - -static void -widget_multiface128_click( void ) -{ - widget_options_settings.multiface128 = ! widget_options_settings.multiface128; -} - -static void -widget_option_multiface128_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->multiface128 ); -} - -static void -widget_multiface3_click( void ) -{ - widget_options_settings.multiface3 = ! widget_options_settings.multiface3; -} - -static void -widget_option_multiface3_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->multiface3 ); -} - -static void -widget_multiface1_stealth_click( void ) -{ - widget_options_settings.multiface1_stealth = ! widget_options_settings.multiface1_stealth; -} - -static void -widget_option_multiface1_stealth_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->multiface1_stealth ); -} - -static void -widget_printer_click( void ) -{ - widget_options_settings.printer = ! widget_options_settings.printer; -} - -static void -widget_option_printer_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->printer ); -} - -static void -widget_zxprinter_click( void ) -{ - widget_options_settings.zxprinter = ! widget_options_settings.zxprinter; -} - -static void -widget_option_zxprinter_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->zxprinter ); -} - -static void -widget_specdrum_click( void ) -{ - widget_options_settings.specdrum = ! widget_options_settings.specdrum; -} - -static void -widget_option_specdrum_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->specdrum ); -} - -static void -widget_ttx2000s_click( void ) -{ - widget_options_settings.ttx2000s = ! widget_options_settings.ttx2000s; -} - -static void -widget_option_ttx2000s_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->ttx2000s ); -} - -static void -widget_usource_click( void ) -{ - widget_options_settings.usource = ! widget_options_settings.usource; -} - -static void -widget_option_usource_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->usource ); -} - -static void -widget_covox_click( void ) -{ - widget_options_settings.covox = ! widget_options_settings.covox; -} - -static void -widget_option_covox_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->covox ); -} - -void -widget_peripherals_general_keyhandler( input_key key ) -{ - int new_highlight_line = 0; - int cursor_pressed = 0; - widget_option_entry *ptr; - int menu_width = widget_calculate_option_width(options_peripherals_general); - int menu_left_edge_x = DISPLAY_WIDTH_COLS/2-menu_width/2; - - switch( key ) { - -#if 0 - case INPUT_KEY_Resize: /* Fake keypress used on window resize */ - widget_dialog_with_border( 1, 2, 30, 2 + 17 ); - widget_peripherals_general_show_all( &widget_options_settings ); - break; -#endif - - case INPUT_KEY_Escape: - case INPUT_JOYSTICK_FIRE_2: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - widget_peripherals_general_running = 0; - break; - - case INPUT_KEY_Up: - case INPUT_KEY_7: - case INPUT_JOYSTICK_UP: - if ( highlight_line ) { - new_highlight_line = highlight_line - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Down: - case INPUT_KEY_6: - case INPUT_JOYSTICK_DOWN: - if ( highlight_line + 1 < 17 ) { - new_highlight_line = highlight_line + 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Home: - if ( highlight_line ) { - new_highlight_line = 0; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_End: - if ( highlight_line + 2 < 17 ) { - new_highlight_line = 17 - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_space: - case INPUT_KEY_0: - case INPUT_JOYSTICK_RIGHT: - options_peripherals_general[highlight_line+1].click(); - options_peripherals_general[highlight_line+1].draw( menu_left_edge_x, menu_width, options_peripherals_general + highlight_line + 1, &widget_options_settings ); - return; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: - widget_end_all( WIDGET_FINISHED_OK ); - widget_peripherals_general_running = 0; - display_refresh_all(); - return; - - default: /* Keep gcc happy */ - break; - - } - - if( cursor_pressed ) { - int old_highlight_line = highlight_line; - highlight_line = new_highlight_line; - options_peripherals_general[old_highlight_line+1].draw( menu_left_edge_x, menu_width, options_peripherals_general + old_highlight_line + 1, &widget_options_settings ); - options_peripherals_general[highlight_line+1].draw( menu_left_edge_x, menu_width, options_peripherals_general + highlight_line + 1, &widget_options_settings ); - return; - } - - for( ptr=&options_peripherals_general[1]; ptr->text != NULL; ptr++ ) { - if( key == ptr->key ) { - int old_highlight_line = highlight_line; - ptr->click(); - highlight_line = ptr->index; - options_peripherals_general[old_highlight_line+1].draw( menu_left_edge_x, menu_width, options_peripherals_general + old_highlight_line + 1, &widget_options_settings ); - ptr->draw( menu_left_edge_x, menu_width, ptr, &widget_options_settings ); - break; - } - } -} - -int -widget_peripherals_disk_draw( void *data GCC_UNUSED ) -{ - int error; - - if( !widget_peripherals_disk_running ) { /* we want to copy settings, only when start up */ - highlight_line = 0; - /* Get a copy of the current settings */ - settings_copy( &widget_options_settings, &settings_current ); - widget_peripherals_disk_running = 1; - } - - error = widget_options_show_all( options_peripherals_disk, &widget_options_settings ); - if( error ) { settings_free( &widget_options_settings ); return error; } - - return 0; -} - -static void -widget_simpleide_active_click( void ) -{ - widget_options_settings.simpleide_active = ! widget_options_settings.simpleide_active; -} - -static void -widget_option_simpleide_active_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->simpleide_active ); -} - -static void -widget_zxatasp_active_click( void ) -{ - widget_options_settings.zxatasp_active = ! widget_options_settings.zxatasp_active; -} - -static void -widget_option_zxatasp_active_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->zxatasp_active ); -} - -static void -widget_zxatasp_upload_click( void ) -{ - widget_options_settings.zxatasp_upload = ! widget_options_settings.zxatasp_upload; -} - -static void -widget_option_zxatasp_upload_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->zxatasp_upload ); -} - -static void -widget_zxatasp_wp_click( void ) -{ - widget_options_settings.zxatasp_wp = ! widget_options_settings.zxatasp_wp; -} - -static void -widget_option_zxatasp_wp_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->zxatasp_wp ); -} - -static void -widget_zxcf_active_click( void ) -{ - widget_options_settings.zxcf_active = ! widget_options_settings.zxcf_active; -} - -static void -widget_option_zxcf_active_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->zxcf_active ); -} - -static void -widget_zxcf_upload_click( void ) -{ - widget_options_settings.zxcf_upload = ! widget_options_settings.zxcf_upload; -} - -static void -widget_option_zxcf_upload_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->zxcf_upload ); -} - -static void -widget_divide_enabled_click( void ) -{ - widget_options_settings.divide_enabled = ! widget_options_settings.divide_enabled; -} - -static void -widget_option_divide_enabled_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->divide_enabled ); -} - -static void -widget_divide_wp_click( void ) -{ - widget_options_settings.divide_wp = ! widget_options_settings.divide_wp; -} - -static void -widget_option_divide_wp_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->divide_wp ); -} - -static void -widget_divmmc_enabled_click( void ) -{ - widget_options_settings.divmmc_enabled = ! widget_options_settings.divmmc_enabled; -} - -static void -widget_option_divmmc_enabled_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->divmmc_enabled ); -} - -static void -widget_divmmc_wp_click( void ) -{ - widget_options_settings.divmmc_wp = ! widget_options_settings.divmmc_wp; -} - -static void -widget_option_divmmc_wp_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->divmmc_wp ); -} - -static void -widget_plusd_click( void ) -{ - widget_options_settings.plusd = ! widget_options_settings.plusd; -} - -static void -widget_option_plusd_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->plusd ); -} - -static void -widget_didaktik80_click( void ) -{ - widget_options_settings.didaktik80 = ! widget_options_settings.didaktik80; -} - -static void -widget_option_didaktik80_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->didaktik80 ); -} - -static void -widget_disciple_click( void ) -{ - widget_options_settings.disciple = ! widget_options_settings.disciple; -} - -static void -widget_option_disciple_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->disciple ); -} - -static void -widget_beta128_click( void ) -{ - widget_options_settings.beta128 = ! widget_options_settings.beta128; -} - -static void -widget_option_beta128_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->beta128 ); -} - -static void -widget_beta128_48boot_click( void ) -{ - widget_options_settings.beta128_48boot = ! widget_options_settings.beta128_48boot; -} - -static void -widget_option_beta128_48boot_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->beta128_48boot ); -} - -static void -widget_opus_click( void ) -{ - widget_options_settings.opus = ! widget_options_settings.opus; -} - -static void -widget_option_opus_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->opus ); -} - -static void -widget_zxmmc_enabled_click( void ) -{ - widget_options_settings.zxmmc_enabled = ! widget_options_settings.zxmmc_enabled; -} - -static void -widget_option_zxmmc_enabled_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->zxmmc_enabled ); -} - -void -widget_peripherals_disk_keyhandler( input_key key ) -{ - int new_highlight_line = 0; - int cursor_pressed = 0; - widget_option_entry *ptr; - int menu_width = widget_calculate_option_width(options_peripherals_disk); - int menu_left_edge_x = DISPLAY_WIDTH_COLS/2-menu_width/2; - - switch( key ) { - -#if 0 - case INPUT_KEY_Resize: /* Fake keypress used on window resize */ - widget_dialog_with_border( 1, 2, 30, 2 + 17 ); - widget_peripherals_disk_show_all( &widget_options_settings ); - break; -#endif - - case INPUT_KEY_Escape: - case INPUT_JOYSTICK_FIRE_2: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - widget_peripherals_disk_running = 0; - break; - - case INPUT_KEY_Up: - case INPUT_KEY_7: - case INPUT_JOYSTICK_UP: - if ( highlight_line ) { - new_highlight_line = highlight_line - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Down: - case INPUT_KEY_6: - case INPUT_JOYSTICK_DOWN: - if ( highlight_line + 1 < 17 ) { - new_highlight_line = highlight_line + 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Home: - if ( highlight_line ) { - new_highlight_line = 0; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_End: - if ( highlight_line + 2 < 17 ) { - new_highlight_line = 17 - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_space: - case INPUT_KEY_0: - case INPUT_JOYSTICK_RIGHT: - options_peripherals_disk[highlight_line+1].click(); - options_peripherals_disk[highlight_line+1].draw( menu_left_edge_x, menu_width, options_peripherals_disk + highlight_line + 1, &widget_options_settings ); - return; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: - widget_end_all( WIDGET_FINISHED_OK ); - widget_peripherals_disk_running = 0; - display_refresh_all(); - return; - - default: /* Keep gcc happy */ - break; - - } - - if( cursor_pressed ) { - int old_highlight_line = highlight_line; - highlight_line = new_highlight_line; - options_peripherals_disk[old_highlight_line+1].draw( menu_left_edge_x, menu_width, options_peripherals_disk + old_highlight_line + 1, &widget_options_settings ); - options_peripherals_disk[highlight_line+1].draw( menu_left_edge_x, menu_width, options_peripherals_disk + highlight_line + 1, &widget_options_settings ); - return; - } - - for( ptr=&options_peripherals_disk[1]; ptr->text != NULL; ptr++ ) { - if( key == ptr->key ) { - int old_highlight_line = highlight_line; - ptr->click(); - highlight_line = ptr->index; - options_peripherals_disk[old_highlight_line+1].draw( menu_left_edge_x, menu_width, options_peripherals_disk + old_highlight_line + 1, &widget_options_settings ); - ptr->draw( menu_left_edge_x, menu_width, ptr, &widget_options_settings ); - break; - } - } -} - -int -widget_rzx_draw( void *data GCC_UNUSED ) -{ - int error; - - if( !widget_rzx_running ) { /* we want to copy settings, only when start up */ - highlight_line = 0; - /* Get a copy of the current settings */ - settings_copy( &widget_options_settings, &settings_current ); - widget_rzx_running = 1; - } - - error = widget_options_show_all( options_rzx, &widget_options_settings ); - if( error ) { settings_free( &widget_options_settings ); return error; } - - return 0; -} - -static void -widget_rzx_autosaves_click( void ) -{ - widget_options_settings.rzx_autosaves = ! widget_options_settings.rzx_autosaves; -} - -static void -widget_option_rzx_autosaves_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->rzx_autosaves ); -} - -static void -widget_rzx_compression_click( void ) -{ - widget_options_settings.rzx_compression = ! widget_options_settings.rzx_compression; -} - -static void -widget_option_rzx_compression_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->rzx_compression ); -} - -static void -widget_competition_mode_click( void ) -{ - widget_options_settings.competition_mode = ! widget_options_settings.competition_mode; -} - -static void -widget_option_competition_mode_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->competition_mode ); -} - -static void -widget_competition_code_click( void ) -{ - widget_text_t text_data; - - text_data.title = "Competition code"; - text_data.allow = WIDGET_INPUT_DIGIT; - text_data.max_length = 8; - snprintf( text_data.text, 40, "%d", - widget_options_settings.competition_code ); - widget_do_text( &text_data ); - - if( widget_text_text ) { - widget_options_settings.competition_code = atoi( widget_text_text ); - } -} - -static void -widget_option_competition_code_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_entry( left_edge, width, menu->index, menu->text, show->competition_code, - menu->suffix ); -} - -static void -widget_embed_snapshot_click( void ) -{ - widget_options_settings.embed_snapshot = ! widget_options_settings.embed_snapshot; -} - -static void -widget_option_embed_snapshot_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->embed_snapshot ); -} - -void -widget_rzx_keyhandler( input_key key ) -{ - int new_highlight_line = 0; - int cursor_pressed = 0; - widget_option_entry *ptr; - int menu_width = widget_calculate_option_width(options_rzx); - int menu_left_edge_x = DISPLAY_WIDTH_COLS/2-menu_width/2; - - switch( key ) { - -#if 0 - case INPUT_KEY_Resize: /* Fake keypress used on window resize */ - widget_dialog_with_border( 1, 2, 30, 2 + 5 ); - widget_rzx_show_all( &widget_options_settings ); - break; -#endif - - case INPUT_KEY_Escape: - case INPUT_JOYSTICK_FIRE_2: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - widget_rzx_running = 0; - break; - - case INPUT_KEY_Up: - case INPUT_KEY_7: - case INPUT_JOYSTICK_UP: - if ( highlight_line ) { - new_highlight_line = highlight_line - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Down: - case INPUT_KEY_6: - case INPUT_JOYSTICK_DOWN: - if ( highlight_line + 1 < 5 ) { - new_highlight_line = highlight_line + 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Home: - if ( highlight_line ) { - new_highlight_line = 0; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_End: - if ( highlight_line + 2 < 5 ) { - new_highlight_line = 5 - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_space: - case INPUT_KEY_0: - case INPUT_JOYSTICK_RIGHT: - options_rzx[highlight_line+1].click(); - options_rzx[highlight_line+1].draw( menu_left_edge_x, menu_width, options_rzx + highlight_line + 1, &widget_options_settings ); - return; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: - widget_end_all( WIDGET_FINISHED_OK ); - widget_rzx_running = 0; - display_refresh_all(); - return; - - default: /* Keep gcc happy */ - break; - - } - - if( cursor_pressed ) { - int old_highlight_line = highlight_line; - highlight_line = new_highlight_line; - options_rzx[old_highlight_line+1].draw( menu_left_edge_x, menu_width, options_rzx + old_highlight_line + 1, &widget_options_settings ); - options_rzx[highlight_line+1].draw( menu_left_edge_x, menu_width, options_rzx + highlight_line + 1, &widget_options_settings ); - return; - } - - for( ptr=&options_rzx[1]; ptr->text != NULL; ptr++ ) { - if( key == ptr->key ) { - int old_highlight_line = highlight_line; - ptr->click(); - highlight_line = ptr->index; - options_rzx[old_highlight_line+1].draw( menu_left_edge_x, menu_width, options_rzx + old_highlight_line + 1, &widget_options_settings ); - ptr->draw( menu_left_edge_x, menu_width, ptr, &widget_options_settings ); - break; - } - } -} - -int -widget_sound_draw( void *data GCC_UNUSED ) -{ - int error; - - if( !widget_sound_running ) { /* we want to copy settings, only when start up */ - highlight_line = 0; - /* Get a copy of the current settings */ - settings_copy( &widget_options_settings, &settings_current ); - widget_sound_running = 1; - } - - error = widget_options_show_all( options_sound, &widget_options_settings ); - if( error ) { settings_free( &widget_options_settings ); return error; } - - return 0; -} - -static void -widget_sound_click( void ) -{ - widget_options_settings.sound = ! widget_options_settings.sound; -} - -static void -widget_option_sound_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->sound ); -} - -static void -widget_sound_load_click( void ) -{ - widget_options_settings.sound_load = ! widget_options_settings.sound_load; -} - -static void -widget_option_sound_load_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->sound_load ); -} - -static void -widget_stereo_ay_click( void ) -{ - widget_combo_click( "AY stereo separation", widget_stereo_ay_combo, - &widget_options_settings.stereo_ay, - 0 ); -} - -static void -widget_option_stereo_ay_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->stereo_ay, 0 ); -} - -static void -widget_sound_force_8bit_click( void ) -{ - widget_options_settings.sound_force_8bit = ! widget_options_settings.sound_force_8bit; -} - -static void -widget_option_sound_force_8bit_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->sound_force_8bit ); -} - -static void -widget_speaker_type_click( void ) -{ - widget_combo_click( "Speaker type", widget_speaker_type_combo, - &widget_options_settings.speaker_type, - 0 ); -} - -static void -widget_option_speaker_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->speaker_type, 0 ); -} - -static void -widget_volume_ay_click( void ) -{ - widget_text_t text_data; - - text_data.title = "AY volume"; - text_data.allow = WIDGET_INPUT_DIGIT; - text_data.max_length = 3; - snprintf( text_data.text, 40, "%d", - widget_options_settings.volume_ay ); - widget_do_text( &text_data ); - - if( widget_text_text ) { - widget_options_settings.volume_ay = atoi( widget_text_text ); - } -} - -static void -widget_option_volume_ay_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_entry( left_edge, width, menu->index, menu->text, show->volume_ay, - menu->suffix ); -} - -static void -widget_volume_beeper_click( void ) -{ - widget_text_t text_data; - - text_data.title = "Beeper volume"; - text_data.allow = WIDGET_INPUT_DIGIT; - text_data.max_length = 3; - snprintf( text_data.text, 40, "%d", - widget_options_settings.volume_beeper ); - widget_do_text( &text_data ); - - if( widget_text_text ) { - widget_options_settings.volume_beeper = atoi( widget_text_text ); - } -} - -static void -widget_option_volume_beeper_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_entry( left_edge, width, menu->index, menu->text, show->volume_beeper, - menu->suffix ); -} - -static void -widget_volume_specdrum_click( void ) -{ - widget_text_t text_data; - - text_data.title = "SpecDrum volume"; - text_data.allow = WIDGET_INPUT_DIGIT; - text_data.max_length = 3; - snprintf( text_data.text, 40, "%d", - widget_options_settings.volume_specdrum ); - widget_do_text( &text_data ); - - if( widget_text_text ) { - widget_options_settings.volume_specdrum = atoi( widget_text_text ); - } -} - -static void -widget_option_volume_specdrum_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_entry( left_edge, width, menu->index, menu->text, show->volume_specdrum, - menu->suffix ); -} - -static void -widget_volume_covox_click( void ) -{ - widget_text_t text_data; - - text_data.title = "Covox volume"; - text_data.allow = WIDGET_INPUT_DIGIT; - text_data.max_length = 3; - snprintf( text_data.text, 40, "%d", - widget_options_settings.volume_covox ); - widget_do_text( &text_data ); - - if( widget_text_text ) { - widget_options_settings.volume_covox = atoi( widget_text_text ); - } -} - -static void -widget_option_volume_covox_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_entry( left_edge, width, menu->index, menu->text, show->volume_covox, - menu->suffix ); -} - -void -widget_sound_keyhandler( input_key key ) -{ - int new_highlight_line = 0; - int cursor_pressed = 0; - widget_option_entry *ptr; - int menu_width = widget_calculate_option_width(options_sound); - int menu_left_edge_x = DISPLAY_WIDTH_COLS/2-menu_width/2; - - switch( key ) { - -#if 0 - case INPUT_KEY_Resize: /* Fake keypress used on window resize */ - widget_dialog_with_border( 1, 2, 30, 2 + 9 ); - widget_sound_show_all( &widget_options_settings ); - break; -#endif - - case INPUT_KEY_Escape: - case INPUT_JOYSTICK_FIRE_2: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - widget_sound_running = 0; - break; - - case INPUT_KEY_Up: - case INPUT_KEY_7: - case INPUT_JOYSTICK_UP: - if ( highlight_line ) { - new_highlight_line = highlight_line - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Down: - case INPUT_KEY_6: - case INPUT_JOYSTICK_DOWN: - if ( highlight_line + 1 < 9 ) { - new_highlight_line = highlight_line + 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Home: - if ( highlight_line ) { - new_highlight_line = 0; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_End: - if ( highlight_line + 2 < 9 ) { - new_highlight_line = 9 - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_space: - case INPUT_KEY_0: - case INPUT_JOYSTICK_RIGHT: - options_sound[highlight_line+1].click(); - options_sound[highlight_line+1].draw( menu_left_edge_x, menu_width, options_sound + highlight_line + 1, &widget_options_settings ); - return; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: - widget_end_all( WIDGET_FINISHED_OK ); - widget_sound_running = 0; - display_refresh_all(); - return; - - default: /* Keep gcc happy */ - break; - - } - - if( cursor_pressed ) { - int old_highlight_line = highlight_line; - highlight_line = new_highlight_line; - options_sound[old_highlight_line+1].draw( menu_left_edge_x, menu_width, options_sound + old_highlight_line + 1, &widget_options_settings ); - options_sound[highlight_line+1].draw( menu_left_edge_x, menu_width, options_sound + highlight_line + 1, &widget_options_settings ); - return; - } - - for( ptr=&options_sound[1]; ptr->text != NULL; ptr++ ) { - if( key == ptr->key ) { - int old_highlight_line = highlight_line; - ptr->click(); - highlight_line = ptr->index; - options_sound[old_highlight_line+1].draw( menu_left_edge_x, menu_width, options_sound + old_highlight_line + 1, &widget_options_settings ); - ptr->draw( menu_left_edge_x, menu_width, ptr, &widget_options_settings ); - break; - } - } -} - -int -widget_diskoptions_draw( void *data GCC_UNUSED ) -{ - int error; - - if( !widget_diskoptions_running ) { /* we want to copy settings, only when start up */ - highlight_line = 0; - /* Get a copy of the current settings */ - settings_copy( &widget_options_settings, &settings_current ); - widget_diskoptions_running = 1; - } - - error = widget_options_show_all( options_diskoptions, &widget_options_settings ); - if( error ) { settings_free( &widget_options_settings ); return error; } - - return 0; -} - -static void -widget_drive_plus3a_type_click( void ) -{ - widget_combo_click( "+3 Drive A", widget_drive_plus3a_type_combo, - &widget_options_settings.drive_plus3a_type, - 0 ); -} - -static void -widget_option_drive_plus3a_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->drive_plus3a_type, 0 ); -} - -static void -widget_drive_plus3b_type_click( void ) -{ - widget_combo_click( "+3 Drive B", widget_drive_plus3b_type_combo, - &widget_options_settings.drive_plus3b_type, - 4 ); -} - -static void -widget_option_drive_plus3b_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->drive_plus3b_type, 4 ); -} - -static void -widget_plus3_detect_speedlock_click( void ) -{ - widget_options_settings.plus3_detect_speedlock = ! widget_options_settings.plus3_detect_speedlock; -} - -static void -widget_option_plus3_detect_speedlock_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->plus3_detect_speedlock ); -} - -static void -widget_drive_beta128a_type_click( void ) -{ - widget_combo_click( "Beta 128 Drive A", widget_drive_beta128a_type_combo, - &widget_options_settings.drive_beta128a_type, - 3 ); -} - -static void -widget_option_drive_beta128a_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->drive_beta128a_type, 3 ); -} - -static void -widget_drive_beta128b_type_click( void ) -{ - widget_combo_click( "Beta 128 Drive B", widget_drive_beta128b_type_combo, - &widget_options_settings.drive_beta128b_type, - 4 ); -} - -static void -widget_option_drive_beta128b_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->drive_beta128b_type, 4 ); -} - -static void -widget_drive_beta128c_type_click( void ) -{ - widget_combo_click( "Beta 128 Drive C", widget_drive_beta128c_type_combo, - &widget_options_settings.drive_beta128c_type, - 4 ); -} - -static void -widget_option_drive_beta128c_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->drive_beta128c_type, 4 ); -} - -static void -widget_drive_beta128d_type_click( void ) -{ - widget_combo_click( "Beta 128 Drive D", widget_drive_beta128d_type_combo, - &widget_options_settings.drive_beta128d_type, - 4 ); -} - -static void -widget_option_drive_beta128d_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->drive_beta128d_type, 4 ); -} - -static void -widget_drive_plusd1_type_click( void ) -{ - widget_combo_click( "+D Drive 1", widget_drive_plusd1_type_combo, - &widget_options_settings.drive_plusd1_type, - 3 ); -} - -static void -widget_option_drive_plusd1_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->drive_plusd1_type, 3 ); -} - -static void -widget_drive_plusd2_type_click( void ) -{ - widget_combo_click( "+D Drive 2", widget_drive_plusd2_type_combo, - &widget_options_settings.drive_plusd2_type, - 4 ); -} - -static void -widget_option_drive_plusd2_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->drive_plusd2_type, 4 ); -} - -static void -widget_drive_didaktik80a_type_click( void ) -{ - widget_combo_click( "Didaktik 80 Drive A", widget_drive_didaktik80a_type_combo, - &widget_options_settings.drive_didaktik80a_type, - 3 ); -} - -static void -widget_option_drive_didaktik80a_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->drive_didaktik80a_type, 3 ); -} - -static void -widget_drive_didaktik80b_type_click( void ) -{ - widget_combo_click( "Didaktik 80 Drive B", widget_drive_didaktik80b_type_combo, - &widget_options_settings.drive_didaktik80b_type, - 4 ); -} - -static void -widget_option_drive_didaktik80b_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->drive_didaktik80b_type, 4 ); -} - -static void -widget_drive_disciple1_type_click( void ) -{ - widget_combo_click( "DISCiPLE Drive 1", widget_drive_disciple1_type_combo, - &widget_options_settings.drive_disciple1_type, - 3 ); -} - -static void -widget_option_drive_disciple1_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->drive_disciple1_type, 3 ); -} - -static void -widget_drive_disciple2_type_click( void ) -{ - widget_combo_click( "DISCiPLE Drive 2", widget_drive_disciple2_type_combo, - &widget_options_settings.drive_disciple2_type, - 4 ); -} - -static void -widget_option_drive_disciple2_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->drive_disciple2_type, 4 ); -} - -static void -widget_drive_opus1_type_click( void ) -{ - widget_combo_click( "Opus Drive 1", widget_drive_opus1_type_combo, - &widget_options_settings.drive_opus1_type, - 0 ); -} - -static void -widget_option_drive_opus1_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->drive_opus1_type, 0 ); -} - -static void -widget_drive_opus2_type_click( void ) -{ - widget_combo_click( "Opus Drive 2", widget_drive_opus2_type_combo, - &widget_options_settings.drive_opus2_type, - 1 ); -} - -static void -widget_option_drive_opus2_type_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->drive_opus2_type, 1 ); -} - -static void -widget_disk_try_merge_click( void ) -{ - widget_combo_click( "Try merge 'B' side of disks", widget_disk_try_merge_combo, - &widget_options_settings.disk_try_merge, - 1 ); -} - -static void -widget_option_disk_try_merge_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->disk_try_merge, 1 ); -} - -static void -widget_disk_ask_merge_click( void ) -{ - widget_options_settings.disk_ask_merge = ! widget_options_settings.disk_ask_merge; -} - -static void -widget_option_disk_ask_merge_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->disk_ask_merge ); -} - -void -widget_diskoptions_keyhandler( input_key key ) -{ - int new_highlight_line = 0; - int cursor_pressed = 0; - widget_option_entry *ptr; - int menu_width = widget_calculate_option_width(options_diskoptions); - int menu_left_edge_x = DISPLAY_WIDTH_COLS/2-menu_width/2; - - switch( key ) { - -#if 0 - case INPUT_KEY_Resize: /* Fake keypress used on window resize */ - widget_dialog_with_border( 1, 2, 30, 2 + 17 ); - widget_diskoptions_show_all( &widget_options_settings ); - break; -#endif - - case INPUT_KEY_Escape: - case INPUT_JOYSTICK_FIRE_2: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - widget_diskoptions_running = 0; - break; - - case INPUT_KEY_Up: - case INPUT_KEY_7: - case INPUT_JOYSTICK_UP: - if ( highlight_line ) { - new_highlight_line = highlight_line - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Down: - case INPUT_KEY_6: - case INPUT_JOYSTICK_DOWN: - if ( highlight_line + 1 < 17 ) { - new_highlight_line = highlight_line + 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Home: - if ( highlight_line ) { - new_highlight_line = 0; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_End: - if ( highlight_line + 2 < 17 ) { - new_highlight_line = 17 - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_space: - case INPUT_KEY_0: - case INPUT_JOYSTICK_RIGHT: - options_diskoptions[highlight_line+1].click(); - options_diskoptions[highlight_line+1].draw( menu_left_edge_x, menu_width, options_diskoptions + highlight_line + 1, &widget_options_settings ); - return; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: - widget_end_all( WIDGET_FINISHED_OK ); - widget_diskoptions_running = 0; - display_refresh_all(); - return; - - default: /* Keep gcc happy */ - break; - - } - - if( cursor_pressed ) { - int old_highlight_line = highlight_line; - highlight_line = new_highlight_line; - options_diskoptions[old_highlight_line+1].draw( menu_left_edge_x, menu_width, options_diskoptions + old_highlight_line + 1, &widget_options_settings ); - options_diskoptions[highlight_line+1].draw( menu_left_edge_x, menu_width, options_diskoptions + highlight_line + 1, &widget_options_settings ); - return; - } - - for( ptr=&options_diskoptions[1]; ptr->text != NULL; ptr++ ) { - if( key == ptr->key ) { - int old_highlight_line = highlight_line; - ptr->click(); - highlight_line = ptr->index; - options_diskoptions[old_highlight_line+1].draw( menu_left_edge_x, menu_width, options_diskoptions + old_highlight_line + 1, &widget_options_settings ); - ptr->draw( menu_left_edge_x, menu_width, ptr, &widget_options_settings ); - break; - } - } -} - -int -widget_movie_draw( void *data GCC_UNUSED ) -{ - int error; - - if( !widget_movie_running ) { /* we want to copy settings, only when start up */ - highlight_line = 0; - /* Get a copy of the current settings */ - settings_copy( &widget_options_settings, &settings_current ); - widget_movie_running = 1; - } - - error = widget_options_show_all( options_movie, &widget_options_settings ); - if( error ) { settings_free( &widget_options_settings ); return error; } - - return 0; -} - -static void -widget_movie_compr_click( void ) -{ - widget_combo_click( "Movie compression", widget_movie_compr_combo, - &widget_options_settings.movie_compr, - 1 ); -} - -static void -widget_option_movie_compr_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->movie_compr, 1 ); -} - -static void -widget_movie_stop_after_rzx_click( void ) -{ - widget_options_settings.movie_stop_after_rzx = ! widget_options_settings.movie_stop_after_rzx; -} - -static void -widget_option_movie_stop_after_rzx_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->movie_stop_after_rzx ); -} - -void -widget_movie_keyhandler( input_key key ) -{ - int new_highlight_line = 0; - int cursor_pressed = 0; - widget_option_entry *ptr; - int menu_width = widget_calculate_option_width(options_movie); - int menu_left_edge_x = DISPLAY_WIDTH_COLS/2-menu_width/2; - - switch( key ) { - -#if 0 - case INPUT_KEY_Resize: /* Fake keypress used on window resize */ - widget_dialog_with_border( 1, 2, 30, 2 + 2 ); - widget_movie_show_all( &widget_options_settings ); - break; -#endif - - case INPUT_KEY_Escape: - case INPUT_JOYSTICK_FIRE_2: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - widget_movie_running = 0; - break; - - case INPUT_KEY_Up: - case INPUT_KEY_7: - case INPUT_JOYSTICK_UP: - if ( highlight_line ) { - new_highlight_line = highlight_line - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Down: - case INPUT_KEY_6: - case INPUT_JOYSTICK_DOWN: - if ( highlight_line + 1 < 2 ) { - new_highlight_line = highlight_line + 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Home: - if ( highlight_line ) { - new_highlight_line = 0; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_End: - if ( highlight_line + 2 < 2 ) { - new_highlight_line = 2 - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_space: - case INPUT_KEY_0: - case INPUT_JOYSTICK_RIGHT: - options_movie[highlight_line+1].click(); - options_movie[highlight_line+1].draw( menu_left_edge_x, menu_width, options_movie + highlight_line + 1, &widget_options_settings ); - return; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: - widget_end_all( WIDGET_FINISHED_OK ); - widget_movie_running = 0; - display_refresh_all(); - return; - - default: /* Keep gcc happy */ - break; - - } - - if( cursor_pressed ) { - int old_highlight_line = highlight_line; - highlight_line = new_highlight_line; - options_movie[old_highlight_line+1].draw( menu_left_edge_x, menu_width, options_movie + old_highlight_line + 1, &widget_options_settings ); - options_movie[highlight_line+1].draw( menu_left_edge_x, menu_width, options_movie + highlight_line + 1, &widget_options_settings ); - return; - } - - for( ptr=&options_movie[1]; ptr->text != NULL; ptr++ ) { - if( key == ptr->key ) { - int old_highlight_line = highlight_line; - ptr->click(); - highlight_line = ptr->index; - options_movie[old_highlight_line+1].draw( menu_left_edge_x, menu_width, options_movie + old_highlight_line + 1, &widget_options_settings ); - ptr->draw( menu_left_edge_x, menu_width, ptr, &widget_options_settings ); - break; - } - } -} - -#endif /* #ifdef USE_WIDGET */ diff --git a/fuse/ui/widget/options.pl b/fuse/ui/widget/options.pl deleted file mode 100755 index 7bc34a6..0000000 --- a/fuse/ui/widget/options.pl +++ /dev/null @@ -1,666 +0,0 @@ -#!/usr/bin/perl -w - -# options.pl: generate options dialog boxes -# Copyright (c) 2001-2015 Philip Kendall, Fredrick Meunier - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Author contact information: - -# E-mail: philip-fuse@shadowmagic.org.uk - -use strict; - -use lib '../perl'; - -use Fuse; -use Fuse::Dialog; - -die "No data file specified" unless @ARGV; - -my %combo_sets; -my %combo_default; -my @dialogs = Fuse::Dialog::read( shift @ARGV ); - -print Fuse::GPL( 'options.c: options dialog boxes', - '2001-2013 Philip Kendall' ) . << "CODE"; - -/* This file is autogenerated from options.dat by options.pl. - Do not edit unless you know what you\'re doing! */ - -#include - -#ifdef USE_WIDGET - -#include -#include - -#include "display.h" -#include "fuse.h" -#include "options.h" -#include "options_internals.h" -#include "periph.h" -#include "ui/widget/widget_internals.h" -#include "ui/uidisplay.h" - -struct widget_option_entry; - -/* A generic click function */ -typedef void (*widget_option_click_fn)( void ); -typedef void (*widget_option_draw_fn)( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); - -/* A general menu */ -typedef struct widget_option_entry { - const char *text; - int index; - input_key key; /* Which key to activate this option */ - const char *suffix; - const char * const *options; - - widget_option_click_fn click; - widget_option_draw_fn draw; -} widget_option_entry; - -static void -widget_combo_click( const char *title, const char * const *options, char **current, int def ) -\{ - int error, i; - widget_select_t sel; - - sel.title = title; - sel.options = options; - sel.current = def; - sel.finish_all = 0; - for( i = 0; options[i] != NULL; i++ ) { - if( *current != NULL && !strcmp( options[ i ], *current ) ) - sel.current = i; - } - sel.count = i; - - error = widget_do_select( &sel ); - - if( !error && sel.result >= 0 ) \{ - if( *current ) free( *current ); - *current = strdup( options[ sel.result ] ); - \} -\} - -static int -option_enumerate_combo( const char * const *options, char *value, int def ) { - int i; - if( value != NULL ) { - for( i = 0; options[i] != NULL; i++) { - if( !strcmp( value, options[ i ] ) ) - return i; - } - } - return def; -} - -CODE - -foreach( @dialogs ) { - foreach my $widget ( @{ $_->{widgets} } ) { - if( $widget->{type} eq "Combo" ) { - my $n = 0; - - foreach( split /\|/, $widget->{data1} ) { - if( s/^\*// ) { - $combo_default{$widget->{value}} = $n; - } - $n++; - } - $widget->{data1} =~ s/^\*//; - $widget->{data1} =~ s/\|\*/|/; - if( not exists( $combo_sets{$widget->{data1}} ) ) { - $combo_sets{$widget->{data1}} = "widget_$widget->{value}_combo"; - - print << "CODE"; -static const char * const widget_$widget->{value}_combo[] = { -CODE - foreach( split /\|/, $widget->{data1} ) { - print << "CODE"; - "$_", -CODE - } - print << "CODE"; - NULL -}; - -CODE - } else { - print << "CODE"; -\#define widget_$widget->{value}_combo $combo_sets{$widget->{data1}} - -CODE - } - print << "CODE"; -int -option_enumerate_$_->{name}_$widget->{value}( void ) { - return option_enumerate_combo( widget_$widget->{value}_combo, - settings_current.$widget->{value}, - $combo_default{$widget->{value}} ); -} - -CODE - } - } -} - -foreach( @dialogs ) { - print "static int widget_$_->{name}_running = 0;\n"; - foreach my $widget ( @{ $_->{widgets} } ) { - if( $widget->{type} eq "Checkbox" or $widget->{type} eq "Entry" or $widget->{type} eq "Combo" ) { - print << "CODE"; -static void widget_$widget->{value}_click( void ); -static void widget_option_$widget->{value}_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ); -CODE - } else { - die "Unknown type `$widget->{type}'"; - } - } -} - -foreach( @dialogs ) { - - my $title = $_->{title}; - $title =~ s/\\0[01][12]//g; - - print << "CODE"; - -static widget_option_entry options_$_->{name}\[\] = \{ - \{ "$_->{title}" \}, -CODE - - my $which = 0; - foreach my $widget ( @{ $_->{widgets} } ) { - - my $text = $widget->{text}; - $text =~ s/\((.)\)/\\012$1\\001/; - - if( $widget->{type} eq "Checkbox" ) { - - print << "CODE"; - \{ "$text", $which, $widget->{key}, NULL, NULL, widget_$widget->{value}_click, widget_option_$widget->{value}_draw \}, -CODE - } elsif( $widget->{type} eq "Entry" ) { - - print << "CODE"; - \{ "$text", $which, $widget->{key}, "$widget->{data2}", NULL, widget_$widget->{value}_click, widget_option_$widget->{value}_draw \}, -CODE - } elsif( $widget->{type} eq "Combo" ) { - - print << "CODE"; - \{ "$text", $which, $widget->{key}, NULL, widget_$widget->{value}_combo, widget_$widget->{value}_click, widget_option_$widget->{value}_draw \}, -CODE - } else { - die "Unknown type `$widget->{type}'"; - } - - $which++; - } - - print << "CODE"; - \{ NULL \} -\}; -CODE - -} - -print << "CODE"; - -static size_t highlight_line = 0; - -/* General functions used by the options dialogs */ -settings_info widget_options_settings; -int widget_options_print_option( int left_edge, int width, int number, const char* string, int value ); -int widget_options_print_value( int left_edge, int width, int number, int value ); -int widget_options_print_entry( int left_edge, int width, int number, const char *prefix, int value, - const char *suffix ); -int widget_options_print_combo( int left_edge, int width, int number, const char *prefix, - const char * const *options, const char *value, int def ); - -static int widget_options_print_label( int left_edge, int width, int number, const char *string ); -static int widget_options_print_data( int left_edge, int menu_width, int number, const char *string, int tcolor ); -static int widget_calculate_option_width(widget_option_entry *menu); - -static int -widget_options_show_all( widget_option_entry *options, settings_info *show ) -\{ - widget_option_entry *ptr; - size_t height = 0; - int menu_width = widget_calculate_option_width( options ); - int menu_left_edge_x; - - /* How many options do we have? */ - for( ptr = &options[1]; ptr->text; ptr++ ) - height ++; - - menu_left_edge_x = DISPLAY_WIDTH_COLS/2-menu_width/2; - - /* Draw the dialog box */ - widget_dialog_with_border( menu_left_edge_x, 2, menu_width, 2 + height ); - - widget_printstring( menu_left_edge_x*8+2, 16, WIDGET_COLOUR_TITLE, options->text ); - - for( ptr = &options[1]; ptr->text; ptr++ ) { - ptr->draw( menu_left_edge_x, menu_width, ptr, show ); - } - - widget_display_lines( 2, 2 + height ); - - return 0; -\} - -int -widget_options_print_option( int left_edge, int width, int number, const char* string, int value ) -{ - widget_options_print_label( left_edge, width, number, string ); - widget_options_print_value( left_edge, width, number, value ); - return 0; -} - -static int -widget_options_print_label( int left_edge, int width, int number, const char *string ) -{ - char buffer[128]; - size_t l, w; - int colour = WIDGET_COLOUR_BACKGROUND; - - if( number == highlight_line ) colour = WIDGET_COLOUR_HIGHLIGHT; - widget_rectangle( left_edge*8+1, number*8+24, width*8-2, 1*8, colour ); - - snprintf( buffer, sizeof( buffer ), "%s", string ); - l = strlen( buffer ); - - if( l >= sizeof( buffer ) ) - l = sizeof( buffer ) - 1; - while( ( w = widget_substringwidth( string, l ) ) >= (left_edge+width-2)*8 ) - --l; - buffer[l] = '\\0'; - w = widget_printstring( left_edge*8+8, number*8+24, WIDGET_COLOUR_FOREGROUND, buffer ) - - 1; - while ((w += 3) < (left_edge+width-1)*8-2) - widget_putpixel (w, number*8+31, 0); - return 0; -} - -int -widget_options_print_value( int left_edge, int width, int number, int value ) -{ - int colour = WIDGET_COLOUR_BACKGROUND; - int x = (left_edge+width-2)*8-2; - int y = number * 8 + 24; - - if( number == highlight_line ) colour = WIDGET_COLOUR_HIGHLIGHT; - widget_rectangle( x, y, 8, 8, colour ); - widget_print_checkbox( x, y, colour, value ); - widget_display_rasters( y, 8 ); - return 0; -} - -static int -widget_options_print_data( int left_edge, int menu_width, int number, const char *string, int tcolor ) -{ - int colour = WIDGET_COLOUR_BACKGROUND; - size_t width = widget_stringwidth( string ); - int x = (left_edge + menu_width-1)*8 - width - 2; - int y = number * 8 + 24; - - if( number == highlight_line ) colour = WIDGET_COLOUR_HIGHLIGHT; - widget_rectangle( x, y, width, 8, colour ); - widget_printstring( x, y, tcolor, string ); - widget_display_rasters( y, 8 ); - - return 0; -} - -int -widget_options_print_entry( int left_edge, int width, int number, const char *prefix, int value, - const char *suffix ) -{ - char buffer[128]; - widget_options_print_label( left_edge, width, number, prefix ); - snprintf( buffer, sizeof( buffer ), "%d %s", value, suffix ); - return widget_options_print_data( left_edge, width, number, buffer, WIDGET_COLOUR_FOREGROUND ); -} - -int -widget_options_print_combo( int left_edge, int width, int number, const char *prefix, - const char * const *option, const char *value, int def ) -{ - int i = 0; - const char *c; - char buffer[64]; - - c = option[ def ]; - if( value != NULL ) { - while( option[ i ] != NULL ) { - if( !strcmp( option[ i ], value ) ) - c = option[ i ]; - i++; - } - } - widget_options_print_label( left_edge, width, number, prefix ); - snprintf( buffer, sizeof( buffer ), "%s", c ); - return widget_options_print_data( left_edge, width, number, buffer, WIDGET_COLOUR_DISABLED ); -} - -int -widget_options_finish( widget_finish_state finished ) -{ - int error; - int needs_hard_reset; - - /* If we exited normally, actually set the options */ - if( finished == WIDGET_FINISHED_OK ) { - /* Get a copy of current settings */ - settings_info original_settings; - memset( &original_settings, 0, sizeof( settings_info ) ); - settings_copy( &original_settings, &settings_current ); - - /* Apply new options */ - settings_copy( &settings_current, &widget_options_settings ); - - needs_hard_reset = periph_postcheck(); - - if( needs_hard_reset ) { - error = widget_do_query( "Some options need to reset the machine. Reset?" ); - if( !error && !widget_query.confirm ) - settings_copy( &settings_current, &original_settings ); - else - periph_posthook(); - } - else { - /* Bring the peripherals list into sync with the new options */ - periph_posthook(); - } - - settings_free( &original_settings ); - - /* make the needed UI changes */ - uidisplay_hotswap_gfx_mode(); - } - settings_free( &widget_options_settings ); - memset( &widget_options_settings, 0, sizeof( settings_info ) ); - - return 0; -} - -const int options_vert_external_margin = 8; - -static int -widget_calculate_option_width(widget_option_entry *menu) -{ - widget_option_entry *ptr; - int max_width=0; - - if (!menu) { - return 64; - } - - max_width = widget_stringwidth( menu->text )+5*8; - - for( ptr = &menu[1]; ptr->text; ptr++ ) { - int total_width = widget_stringwidth(ptr->text)+3*8; - - /* If this is a number format, leave room for 4 digits as well as the - text */ - if( ptr->suffix ) total_width += widget_stringwidth(ptr->suffix)+4*8; - if( ptr->options ) { - int combo_width = 0; - const char * const *options = ptr->options; - while( *options != NULL ) { - if( combo_width < widget_stringwidth( *options ) ) - combo_width = widget_stringwidth( *options ); - options++; - } - total_width += combo_width; - } - - if (total_width > max_width) - max_width = total_width; - } - - return (max_width+options_vert_external_margin*2)/8; -} - -CODE - -foreach( @dialogs ) { - - my $count = @{ $_->{widgets} }; - - print << "CODE"; - -int -widget_$_->{name}_draw( void *data GCC_UNUSED ) -{ - int error; - - if( !widget_$_->{name}_running ) { /* we want to copy settings, only when start up */ - highlight_line = 0; - /* Get a copy of the current settings */ - settings_copy( &widget_options_settings, &settings_current ); - widget_$_->{name}_running = 1; - } - - error = widget_options_show_all( options_$_->{name}, &widget_options_settings ); - if( error ) { settings_free( &widget_options_settings ); return error; } - - return 0; -} - -CODE - - my $which = 0; - foreach my $widget ( @{ $_->{widgets} } ) { - - if( $widget->{type} eq "Checkbox" ) { - - print << "CODE"; -static void -widget_$widget->{value}_click( void ) -\{ - widget_options_settings.$widget->{value} = ! widget_options_settings.$widget->{value}; -\} - -CODE - } elsif( $widget->{type} eq "Entry" ) { - - my $title = $widget->{text}; - $title =~ s/\((.)\)/$1/; - - print << "CODE"; -static void -widget_$widget->{value}_click( void ) -\{ - widget_text_t text_data; - - text_data.title = "$title"; - text_data.allow = WIDGET_INPUT_DIGIT; - text_data.max_length = $widget->{data1}; - snprintf( text_data.text, 40, "%d", - widget_options_settings.$widget->{value} ); - widget_do_text( &text_data ); - - if( widget_text_text ) \{ - widget_options_settings.$widget->{value} = atoi( widget_text_text ); - \} -\} - -CODE - } elsif( $widget->{type} eq "Combo" ) { - - my $title = $widget->{text}; - $title =~ s/\((.)\)/$1/; - - print << "CODE"; -static void -widget_$widget->{value}_click( void ) -\{ - widget_combo_click( "$title", widget_$widget->{value}_combo, - &widget_options_settings.$widget->{value}, - $combo_default{$widget->{value}} ); -\} - -CODE - } else { - die "Unknown type `$widget->{type}'"; - } - - $widget->{text} =~ s/\((.)\)/\\012$1\\001/; - - if( $widget->{type} eq "Checkbox" ) { - - print << "CODE"; -static void -widget_option_$widget->{value}_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -\{ - widget_options_print_option( left_edge, width, menu->index, menu->text, show->$widget->{value} ); -\} - -CODE - } elsif( $widget->{type} eq "Entry" ) { - - print << "CODE"; -static void -widget_option_$widget->{value}_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -\{ - widget_options_print_entry( left_edge, width, menu->index, menu->text, show->$widget->{value}, - menu->suffix ); -\} - -CODE - } elsif( $widget->{type} eq "Combo" ) { - - print << "CODE"; -static void -widget_option_$widget->{value}_draw( int left_edge, int width, struct widget_option_entry *menu, settings_info *show ) -\{ - widget_options_print_combo( left_edge, width, menu->index, menu->text, menu->options, - show->$widget->{value}, $combo_default{$widget->{value}} ); -\} - -CODE - } else { - die "Unknown type `$widget->{type}'"; - } - - $which++; - } - - print << "CODE"; -void -widget_$_->{name}_keyhandler( input_key key ) -\{ - int new_highlight_line = 0; - int cursor_pressed = 0; - widget_option_entry *ptr; - int menu_width = widget_calculate_option_width(options_$_->{name}); - int menu_left_edge_x = DISPLAY_WIDTH_COLS/2-menu_width/2; - - switch( key ) \{ - -#if 0 - case INPUT_KEY_Resize: /* Fake keypress used on window resize */ - widget_dialog_with_border( 1, 2, 30, 2 + $count ); - widget_$_->{name}_show_all( &widget_options_settings ); - break; -#endif - - case INPUT_KEY_Escape: - case INPUT_JOYSTICK_FIRE_2: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - widget_$_->{name}_running = 0; - break; - - case INPUT_KEY_Up: - case INPUT_KEY_7: - case INPUT_JOYSTICK_UP: - if ( highlight_line ) { - new_highlight_line = highlight_line - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Down: - case INPUT_KEY_6: - case INPUT_JOYSTICK_DOWN: - if ( highlight_line + 1 < $count ) { - new_highlight_line = highlight_line + 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Home: - if ( highlight_line ) { - new_highlight_line = 0; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_End: - if ( highlight_line + 2 < $count ) { - new_highlight_line = $count - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_space: - case INPUT_KEY_0: - case INPUT_JOYSTICK_RIGHT: - options_$_->{name}\[highlight_line+1\].click(); - options_$_->{name}\[highlight_line+1\].draw( menu_left_edge_x, menu_width, options_$_->{name} + highlight_line + 1, &widget_options_settings ); - return; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: - widget_end_all( WIDGET_FINISHED_OK ); - widget_$_->{name}_running = 0; - display_refresh_all(); - return; - - default: /* Keep gcc happy */ - break; - - \} - - if( cursor_pressed ) \{ - int old_highlight_line = highlight_line; - highlight_line = new_highlight_line; - options_$_->{name}\[old_highlight_line+1\].draw( menu_left_edge_x, menu_width, options_$_->{name} + old_highlight_line + 1, &widget_options_settings ); - options_$_->{name}\[highlight_line+1\].draw( menu_left_edge_x, menu_width, options_$_->{name} + highlight_line + 1, &widget_options_settings ); - return; - \} - - for( ptr=&options_$_->{name}\[1\]; ptr->text != NULL; ptr++ ) \{ - if( key == ptr->key ) \{ - int old_highlight_line = highlight_line; - ptr->click(); - highlight_line = ptr->index; - options_$_->{name}\[old_highlight_line+1\].draw( menu_left_edge_x, menu_width, options_$_->{name} + old_highlight_line + 1, &widget_options_settings ); - ptr->draw( menu_left_edge_x, menu_width, ptr, &widget_options_settings ); - break; - \} - \} -\} -CODE - -} - -print "\n#endif /* #ifdef USE_WIDGET */\n"; - diff --git a/fuse/ui/widget/options_internals.h b/fuse/ui/widget/options_internals.h deleted file mode 100644 index 0bd01e0..0000000 --- a/fuse/ui/widget/options_internals.h +++ /dev/null @@ -1,64 +0,0 @@ -/* options_internals.h: options dialog boxes - Copyright (c) 2001-2002,2004 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -/* This file is autogenerated from options.dat by options-header.pl. - Do not edit unless you know what you're doing! */ - -#ifndef FUSE_WIDGETOPTIONS_INTERNALS_H -#define FUSE_WIDGETOPTIONS_INTERNALS_H - -#ifndef FUSE_SETTINGS_H -#include "settings.h" -#endif - -#ifndef FUSE_WIDGET_H -#include "ui/widget/widget.h" -#endif - -extern settings_info widget_options_settings; - -int widget_general_draw( void *data ); -void widget_general_keyhandler( input_key key ); - -int widget_media_draw( void *data ); -void widget_media_keyhandler( input_key key ); - -int widget_peripherals_general_draw( void *data ); -void widget_peripherals_general_keyhandler( input_key key ); - -int widget_peripherals_disk_draw( void *data ); -void widget_peripherals_disk_keyhandler( input_key key ); - -int widget_rzx_draw( void *data ); -void widget_rzx_keyhandler( input_key key ); - -int widget_sound_draw( void *data ); -void widget_sound_keyhandler( input_key key ); - -int widget_diskoptions_draw( void *data ); -void widget_diskoptions_keyhandler( input_key key ); - -int widget_movie_draw( void *data ); -void widget_movie_keyhandler( input_key key ); - -#endif /* #ifndef FUSE_WIDGETOPTIONS_INTERNALS_H */ diff --git a/fuse/ui/widget/picture.c b/fuse/ui/widget/picture.c deleted file mode 100644 index 0e59868..0000000 --- a/fuse/ui/widget/picture.c +++ /dev/null @@ -1,68 +0,0 @@ -/* picture.c: Keyboard picture - Copyright (c) 2001-2004 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include "display.h" -#include "ui/uidisplay.h" -#include "widget_internals.h" - -static widget_picture_data *ptr; - -int widget_picture_draw( void* data ) -{ - ptr = (widget_picture_data*)data; - - uidisplay_spectrum_screen( ptr->screen, ptr->border ); - uidisplay_frame_end(); - - return 0; -} - -void -widget_picture_keyhandler( input_key key ) -{ - switch( key ) { - -#if 0 - case INPUT_KEY_Resize: /* Fake keypress used on widget resize */ - widget_picture_draw( ptr ); - break; -#endif - - case INPUT_KEY_Escape: - case INPUT_JOYSTICK_FIRE_2: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - break; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: - widget_end_all( WIDGET_FINISHED_OK ); - break; - - default: /* Keep gcc happy */ - break; - - } -} diff --git a/fuse/ui/widget/pokefinder.c b/fuse/ui/widget/pokefinder.c deleted file mode 100644 index 64d6efe..0000000 --- a/fuse/ui/widget/pokefinder.c +++ /dev/null @@ -1,251 +0,0 @@ -/* pokefinder.c: The poke finder widget - Copyright (c) 2004 Darren Salt - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: linux@youmustbejoking.demon.co.uk - -*/ - -#include - -#include -#include - -#include "compat.h" -#include "debugger/debugger.h" -#include "pokefinder/pokefinder.h" -#include "ui/ui.h" -#include "widget.h" -#include "widget_internals.h" - -#define MAX_POSSIBLE 8 -#define FEW_ENOUGH() (pokefinder_count && pokefinder_count <= MAX_POSSIBLE) - -static int value = 0; -static int possible_page[ MAX_POSSIBLE ]; -static libspectrum_word possible_offset[ MAX_POSSIBLE ]; -static int selected = 0; - -static void update_possible( void ); -static void display_possible( void ); -static void display_value( void ); - -static const char * const title = "Poke finder"; - -int -widget_pokefinder_draw( void *data ) -{ - widget_dialog_with_border( 1, 2, 30, 12 ); - widget_printstring( 10, 16, WIDGET_COLOUR_TITLE, title ); - widget_printstring( 16, 24, WIDGET_COLOUR_FOREGROUND, "Possible: " ); - widget_printstring( 16, 32, WIDGET_COLOUR_FOREGROUND, "Value: " ); - - update_possible(); - display_possible(); - display_value(); - - widget_printstring( 16, 88, WIDGET_COLOUR_FOREGROUND, - "\x0AI\x01nc'd \x0A" "D\x01" "ec'd \x0AS\x01" "earch" ); - widget_printstring( 16, 96, WIDGET_COLOUR_FOREGROUND, "\x0AR\x01" "eset \x0A" "C\x01lose" ); - - widget_display_lines( 2, 12 ); - - return 0; -} - -static void -update_possible( void ) -{ - size_t page, offset, bank, bank_offset, i = 0; - - selected = 0; - - if( !FEW_ENOUGH() ) - return; - - for( page = 0; page < MEMORY_PAGES_IN_16K * SPECTRUM_RAM_PAGES; page++ ) { - memory_page *mapping = &memory_map_ram[page]; - bank = mapping->page_num; - - for( offset = 0; offset < MEMORY_PAGE_SIZE; ++offset ) - if( ! (pokefinder_impossible[page][offset/8] & 1 << (offset & 7)) ) { - bank_offset = mapping->offset + offset; - - possible_page[i] = bank; - possible_offset[i] = bank_offset; - if( ++i == pokefinder_count ) - return; - } - } -} - -static void -display_possible( void ) -{ - char buf[ 32 ]; - - widget_rectangle( 96, 24, 48, 8, WIDGET_COLOUR_BACKGROUND ); - widget_rectangle( 16, 48, 128, 32, WIDGET_COLOUR_BACKGROUND ); - widget_rectangle( 16, 80, 136, 8, WIDGET_COLOUR_BACKGROUND ); - widget_rectangle( 82, 96, 56, 8, WIDGET_COLOUR_BACKGROUND ); - - snprintf( buf, sizeof( buf ), "%lu", (unsigned long)pokefinder_count ); - widget_printstring( 96, 24, WIDGET_COLOUR_FOREGROUND, buf ); - - if( FEW_ENOUGH() ) { - size_t i; - - for( i = 0; i < pokefinder_count; i++ ) { - int x = 2 + (i / 4) * 8; - int y = 6 + (i % 4); - int colour; - - if( i == selected ) { - widget_rectangle( x * 8, y * 8, 56, 8, WIDGET_COLOUR_FOREGROUND ); - colour = WIDGET_COLOUR_BACKGROUND; - } else { - colour = WIDGET_COLOUR_FOREGROUND; - } - - snprintf( buf, sizeof( buf ), "%2d:%04X", possible_page[i], - possible_offset[i] ); - widget_printstring( x * 8, y * 8, colour, buf ); - } - - widget_printstring( 83, 96, WIDGET_COLOUR_FOREGROUND, "\x0A" "B\x01reak" ); - } - - widget_display_lines( 3, 10 ); -} - -static void -display_value( void ) -{ - char buf[16]; - - snprintf( buf, sizeof( buf ), "%d", value ); - widget_rectangle( 72, 32, 24, 8, WIDGET_COLOUR_BACKGROUND ); - widget_printstring( 72, 32, WIDGET_COLOUR_FOREGROUND, buf ); - widget_display_lines( 4, 1 ); -} - -static void -scroll( int step ) -{ - if( !FEW_ENOUGH() ) return; - - selected += step; - if( selected < 0 ) - selected = 0; - else if( selected >= pokefinder_count ) - selected = pokefinder_count - 1; - - display_possible(); -} - -void -widget_pokefinder_keyhandler( input_key key ) -{ - switch ( key ) { - case INPUT_KEY_Escape: /* Close widget */ - widget_end_widget( WIDGET_FINISHED_CANCEL ); - break; - - case INPUT_KEY_c: /* Close widget */ - widget_end_all( WIDGET_FINISHED_OK ); - break; - - case INPUT_KEY_i: /* Search for incremented */ - pokefinder_incremented(); - update_possible(); - display_possible(); - break; - - case INPUT_KEY_d: /* Search for incremented */ - pokefinder_decremented(); - update_possible(); - display_possible(); - break; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_KEY_s: /* Search */ - if( value < 256 ) { - pokefinder_search( value ); - update_possible(); - display_possible(); - } - break; - - case INPUT_KEY_r: /* Reset */ - pokefinder_clear(); - update_possible(); - display_possible(); - break; - - case INPUT_KEY_b: /* Add breakpoint */ - if( FEW_ENOUGH() ) - { - widget_rectangle( 128, 24, 112, 8, WIDGET_COLOUR_BACKGROUND ); - if( debugger_breakpoint_add_address( - DEBUGGER_BREAKPOINT_TYPE_WRITE, memory_source_ram, - possible_page[selected], possible_offset[selected], 0, - DEBUGGER_BREAKPOINT_LIFE_PERMANENT, NULL - ) ) { - widget_printstring( 16, 80, WIDGET_COLOUR_FOREGROUND, - "Breakpoint failed" ); - } else { - widget_printstring( 16, 80, WIDGET_COLOUR_FOREGROUND, - "Breakpoint added" ); - } - widget_display_lines( 10, 1 ); - } - break; - - /* Address selection */ - case INPUT_KEY_Up: scroll( -1 ); break; - case INPUT_KEY_Down: scroll( 1 ); break; - case INPUT_KEY_Left: scroll( -4 ); break; - case INPUT_KEY_Right: scroll( 4 ); break; - case INPUT_KEY_Home: scroll( -20 ); break; - case INPUT_KEY_End: scroll( 20 ); break; - - /* Value alteration */ - case INPUT_KEY_0: - case INPUT_KEY_1: - case INPUT_KEY_2: - case INPUT_KEY_3: - case INPUT_KEY_4: - case INPUT_KEY_5: - case INPUT_KEY_6: - case INPUT_KEY_7: - case INPUT_KEY_8: - case INPUT_KEY_9: - value = (value % 100) * 10 + key - INPUT_KEY_0; - display_value(); - break; - - case INPUT_KEY_BackSpace: /* Value alteration */ - value /= 10; - display_value(); - break; - - default:; - } -} diff --git a/fuse/ui/widget/pokemem.c b/fuse/ui/widget/pokemem.c deleted file mode 100644 index 1f0be3d..0000000 --- a/fuse/ui/widget/pokemem.c +++ /dev/null @@ -1,522 +0,0 @@ -/* pokemem.c: The poke memory widget - Copyright (c) 2011 Philip Kendall, Sergio Baldoví - Copyright (c) 2015 Adrien Destugues - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include - -#include "fuse.h" -#include "menu.h" -#include "pokefinder/pokemem.h" -#include "ui/ui.h" -#include "widget.h" -#include "widget_internals.h" - -typedef struct entry_t { - int checked; - trainer_t *trainer; -} entry_t; - -const char *pokemem_title = "Poke memory"; -const unsigned int page_size = 16; -GArray *store = NULL; -int selected = -1; -int highlight_line = 0; -unsigned int menu_left_edge_x; -unsigned int menu_width; -unsigned int pokemem_count = 0; -unsigned int top_index = 0; - -unsigned int widget_pokemem_calculate_width( void ); -void widget_pokemem_store_new( void ); -void widget_pokemem_store_add( gpointer data, gpointer user_data ); -void widget_pokemem_print_list( unsigned int left_edge, unsigned int width ); -int widget_pokemem_print_trainer( unsigned int left_edge, unsigned int width, - int number, int disabled, int checked, - const char *string ); -void widget_pokemem_update_line( unsigned int left_edge, unsigned int width, - int index ); - -int widget_pokemem_trainer_click( int index ); -void widget_pokemem_ask_value( trainer_t *trainer ); -int widget_pokemem_add_custom_poke( void ); -void widget_pokemem_apply_pokes( void ); - -void -ui_pokemem_selector( const char *filename ) -{ - fuse_emulation_pause(); - - pokemem_read_from_file( filename ); - menu_machine_pokememory( 0 ); - - fuse_emulation_unpause(); -} - -int widget_pokemem_finish( widget_finish_state finished ) -{ - if( finished == WIDGET_FINISHED_OK ) { - widget_pokemem_apply_pokes(); - } - - if( store ) { - g_array_free( store, TRUE ); - store = NULL; - } - - pokemem_count = 0; - - return 0; -} - -int -widget_pokemem_draw( void *data GCC_UNUSED ) -{ - if( !store ) { - pokemem_autoload_pokfile(); - widget_pokemem_store_new(); - } - - menu_width = widget_pokemem_calculate_width(); - menu_left_edge_x = DISPLAY_WIDTH_COLS / 2 - menu_width / 2; - - widget_dialog_with_border( menu_left_edge_x, 2, menu_width, page_size + 4 ); - widget_printstring( menu_left_edge_x * 8 + 2, 16, WIDGET_COLOUR_TITLE, - pokemem_title ); - - widget_pokemem_print_list( menu_left_edge_x, menu_width ); - - widget_printstring( menu_left_edge_x * 8 + 8, ( page_size + 4 ) * 8, - WIDGET_COLOUR_FOREGROUND, "\x0A" "A\x01" "dd" ); - - widget_display_lines( 2, page_size + 4 ); - - return 0; -} - -unsigned int -widget_pokemem_calculate_width( void ) -{ - unsigned int i, width, max_width, text_width; - entry_t *entry; - trainer_t *trainer; - - if( !store ) return 25; - - max_width = 0; - - for( i = 0; i < pokemem_count; i++ ) { - entry = &g_array_index( store, entry_t, i ); - trainer = entry->trainer; - - text_width = widget_stringwidth( trainer->name ) + 3 * 8; - if( text_width > max_width ) max_width = text_width; - } - - width = ( max_width + 16 ) / 8; - if( width < 25 ) - width = 25; - else if( width > 32 ) - width = 32; - - return width; -} - -void -widget_pokemem_print_list( unsigned int left_edge, unsigned int width ) -{ - char buf[32]; - unsigned int i, page_limit; - entry_t *entry; - trainer_t *trainer; - - if( store && pokemem_count ) { - page_limit = top_index + page_size; - - for( i = top_index; i < pokemem_count && i < page_limit; i++ ) { - entry = &g_array_index( store, entry_t, i ); - trainer = entry->trainer; - - snprintf( buf, sizeof( buf ), "%s", trainer->name ); - widget_pokemem_print_trainer( left_edge, width, i - top_index, - trainer->disabled, entry->checked, buf ); - } - - if( top_index ) widget_up_arrow( left_edge, 3, WIDGET_COLOUR_FOREGROUND ); - - if( i < pokemem_count ) - widget_down_arrow( left_edge, page_size + 2, WIDGET_COLOUR_FOREGROUND ); - } - - widget_display_lines( 3, page_size ); -} - -int -widget_pokemem_print_trainer( unsigned int left_edge, unsigned int width, - int number, int disabled, int checked, - const char *string ) -{ - char buffer[128]; - size_t l, w; - int colour = WIDGET_COLOUR_BACKGROUND; - int x; - int y; - - if( number == highlight_line ) colour = WIDGET_COLOUR_HIGHLIGHT; - widget_rectangle( left_edge * 8 + 1, number * 8 + 24, width * 8 - 2, 1 * 8, - colour ); - - snprintf( buffer, sizeof( buffer ), "%s", string ); - l = strlen( buffer ); - - if( l >= sizeof( buffer ) ) - l = sizeof( buffer ) - 1; - while( ( w = widget_substringwidth( string, l ) ) >= ( left_edge+width-2 )*8 ) - --l; - buffer[l] = '\0'; - w = widget_printstring( left_edge * 8 + 9, number * 8 + 24, - WIDGET_COLOUR_FOREGROUND, buffer ) - 1; - while( ( w += 3 ) < ( left_edge + width - 1 ) * 8 - 2 ) - widget_putpixel( w, number * 8 + 31, 0 ); - - /* print check */ - x = ( left_edge + width - 2 ) * 8 - 2; - y = number * 8 + 24; - - widget_rectangle( x, y, 8, 8, colour ); - widget_print_checkbox( x, y, - ( disabled )? WIDGET_COLOUR_FOREGROUND : colour, - checked ); - widget_display_rasters( y, 8 ); - - return 0; -} - -void -widget_pokemem_update_line( unsigned int left_edge, unsigned int width, - int index ) -{ - char buf[32]; - entry_t *entry; - trainer_t *trainer; - - if( !store ) return; - - entry = &g_array_index( store, entry_t, index ); - trainer = entry->trainer; - - snprintf( buf, sizeof( buf ), "%s", trainer->name ); - widget_pokemem_print_trainer( left_edge, width, index - top_index, - trainer->disabled, entry->checked, buf ); - - /* First row in page */ - if( top_index && index == top_index ) - widget_up_arrow( left_edge, 3, WIDGET_COLOUR_FOREGROUND ); - - /* Last row in page */ - if( top_index + page_size < pokemem_count && - ( index - top_index == page_size - 1 ) ) - widget_down_arrow( left_edge, page_size + 2, WIDGET_COLOUR_FOREGROUND ); -} - -void -widget_pokemem_keyhandler( input_key key ) -{ - int new_selected; - - new_selected = selected; - - switch ( key ) { - case INPUT_KEY_Return: /* Do pokes */ - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: - widget_end_all( WIDGET_FINISHED_OK ); - break; - - case INPUT_KEY_Escape: /* Close widget */ - case INPUT_JOYSTICK_FIRE_2: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - return; - - case INPUT_KEY_a: /* Add poke */ - if( !widget_pokemem_add_custom_poke() ) new_selected = pokemem_count - 1; - break; - - case INPUT_KEY_Home: - new_selected = 0; - break; - - case INPUT_KEY_End: - new_selected = pokemem_count - 1; - break; - - case INPUT_KEY_Page_Up: - new_selected = ( selected > page_size )? selected - page_size : 0; - break; - - case INPUT_KEY_Page_Down: - new_selected = selected + page_size; - if( new_selected >= pokemem_count ) new_selected = pokemem_count - 1; - break; - - case INPUT_KEY_Up: - case INPUT_KEY_7: - case INPUT_JOYSTICK_UP: - if( selected ) new_selected = selected - 1; - break; - - case INPUT_KEY_Down: - case INPUT_KEY_6: - case INPUT_JOYSTICK_DOWN: - if( selected + 1 < pokemem_count ) new_selected = selected + 1; - break; - - case INPUT_KEY_space: - case INPUT_KEY_8: - case INPUT_JOYSTICK_RIGHT: - if( !widget_pokemem_trainer_click( selected ) ) - widget_pokemem_update_line( menu_left_edge_x, menu_width, selected ); - return; - - default:; - } - - if( store && new_selected != selected ) { - if( new_selected < top_index ) { - top_index = new_selected; - highlight_line = new_selected - top_index; - widget_pokemem_print_list( menu_left_edge_x, menu_width ); - } - else if( new_selected >= top_index + page_size ) { - top_index = new_selected - page_size + 1; - highlight_line = new_selected - top_index; - widget_pokemem_print_list( menu_left_edge_x, menu_width ); - } else { - /* Otherwise, print the current trainer uninverted and the - new current trainer inverted */ - highlight_line = new_selected - top_index; - if( selected >= 0 ) - widget_pokemem_update_line( menu_left_edge_x, menu_width, selected ); - widget_pokemem_update_line( menu_left_edge_x, menu_width, new_selected ); - widget_display_lines( 3, page_size ); - } - - selected = new_selected; - } -} - -void -widget_pokemem_store_new( void ) -{ - if( !trainer_list ) return; - - store = g_array_new( FALSE, FALSE, sizeof( entry_t ) ); - - if( store ) { - g_slist_foreach( trainer_list, widget_pokemem_store_add, NULL ); - pokemem_count = store->len; - } - - /* Adjust default selection to current data */ - if( pokemem_count == 0 ) { - selected = -1; - top_index = 0; - highlight_line = 0; - } - else if( selected > pokemem_count ) { - selected = 0; - top_index = 0; - highlight_line = 0; - } -} - -void -widget_pokemem_store_add( gpointer data, gpointer user_data GCC_UNUSED ) -{ - trainer_t *trainer = data; - entry_t entry; - - if( !trainer ) return; - - /* Append a new row and fill data */ - entry.checked = trainer->active; - entry.trainer = trainer; - g_array_append_vals( store, &entry, 1 ); -} - -void -widget_pokemem_apply_pokes( void ) -{ - entry_t *entry; - trainer_t *trainer; - unsigned int i; - - if( !store ) return; - - for( i = 0; i < store->len; i++ ) { - entry = &g_array_index( store, entry_t, i ); - trainer = entry->trainer; - - if( entry->checked ) { - pokemem_trainer_activate( trainer ); - } else { - pokemem_trainer_deactivate( trainer ); - } - } -} - -int -widget_pokemem_trainer_click( int index ) -{ - entry_t *entry; - trainer_t *trainer; - - if( !store ) return 1; - - /* Disable incomplete trainers or active without restore value */ - entry = &g_array_index( store, entry_t, index ); - trainer = entry->trainer; - if( trainer->disabled ) return 1; - - /* Toggle current selection */ - entry->checked = !entry->checked; - widget_pokemem_update_line( menu_left_edge_x, menu_width, selected ); - - /* Request user for custom value */ - if( entry->checked && trainer->ask_value ) { - widget_pokemem_ask_value( trainer ); - } - - return 0; -} - -void -widget_pokemem_ask_value( trainer_t *trainer ) -{ - int value; - widget_text_t text_data; - - text_data.title = "Enter trainer value"; - text_data.allow = WIDGET_INPUT_DIGIT; - text_data.max_length = 3; - snprintf( text_data.text, sizeof( text_data.text ), "%d", trainer->value ); - widget_do_text( &text_data ); - - if( widget_text_text ) { - value = atoi( widget_text_text ); - trainer->value = ( value > 255 )? 0 : value; - } -} - -int -widget_pokemem_add_custom_poke( void ) -{ - long b, a, v; - trainer_t *trainer; - entry_t entry; - widget_text_t text_data; - char *endptr; - - /* Bank */ - memset( &text_data, 0, sizeof( widget_text_t ) ); - text_data.title = "Enter bank (optional)"; - text_data.allow = WIDGET_INPUT_DIGIT; - text_data.max_length = 1; - if( widget_do_text( &text_data ) ) return 1; - - if( !widget_text_text ) return 1; - - errno = 0; - b = strtol( widget_text_text, &endptr, 10 ); - - if( errno || b < 0 || b > 8 ) { - ui_error( UI_ERROR_ERROR, "Invalid bank: use an integer from 0 to 8" ); - return 1; - } - - if( endptr == widget_text_text ) b = 8; /* ignore bank by default */ - - /* Address */ - text_data.title = "Enter address / offset"; - text_data.max_length = 5; - if( widget_do_text( &text_data ) ) return 1; - - if( !widget_text_text ) return 1; - - errno = 0; - a = strtol( widget_text_text, &endptr, 10 ); - - if( errno || a < 0 || a > 65535 || endptr == widget_text_text ) { - ui_error( UI_ERROR_ERROR, - "Invalid address: use an integer from 0 to 65535" ); - return 1; - } - - if( b == 8 && a < 16384 ) { - ui_error( UI_ERROR_ERROR, - "Invalid address: use an integer from 16384 to 65535" ); - return 1; - } - - /* Value */ - text_data.title = "Enter value"; - text_data.max_length = 3; - if( widget_do_text( &text_data ) ) return 1; - - if( !widget_text_text ) return 1; - - errno = 0; - v = strtol( widget_text_text, &endptr, 10 ); - - if( errno || v < 0 || v > 256 || endptr == widget_text_text ) { - ui_error( UI_ERROR_ERROR, "Invalid value: use an integer from 0 to 256" ); - return 1; - } - - trainer = pokemem_trainer_list_add( b, a, v ); - if( !trainer ) { - ui_error( UI_ERROR_ERROR, "Cannot add trainer" ); - return 1; - } - - /* Append a new row and fill data */ - entry.trainer = trainer; - entry.checked = trainer->active; - - if( !trainer->active && !trainer->disabled && !trainer->ask_value ) { - entry.checked = 1; - } - - if( !store ) { - store = g_array_new( FALSE, FALSE, sizeof( entry_t ) ); - if( !store ) return 1; - } - - g_array_append_vals( store, &entry, 1 ); - pokemem_count = store->len; - - return 0; -} diff --git a/fuse/ui/widget/query.c b/fuse/ui/widget/query.c deleted file mode 100644 index c3f3d35..0000000 --- a/fuse/ui/widget/query.c +++ /dev/null @@ -1,327 +0,0 @@ -/* query.c: The query widgets - Copyright (c) 2004-2008 Darren Salt, Fredrick Meunier - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: linux@youmustbejoking.demon.co.uk - -*/ - -#include - -#include -#include -#include - -#include "fuse.h" -#include "utils.h" -#include "widget_internals.h" - -widget_query_t widget_query; - -static const char * const title = "Fuse - Confirm"; - -struct widget_query_entry; - -/* A generic click function */ -typedef void (*widget_query_click_fn)( void ); - -/* A general menu */ -typedef struct widget_query_entry { - const char *text; - int index; - input_key key; /* Which key to activate this query */ - - widget_query_click_fn click; -} widget_query_entry; - -static void widget_save_click( void ); -static void widget_dont_save_click( void ); -static void widget_cancel_click( void ); -static void widget_yes_click( void ); -static void widget_no_click( void ); -static void widget_query_line_draw( int left_edge, int width, - struct widget_query_entry *menu, - const char *label ); - -static widget_query_entry query_save[] = { - { "\012S\001ave", 0, INPUT_KEY_s, widget_save_click }, - { "\012D\001on't save", 1, INPUT_KEY_d, widget_dont_save_click }, - { "\012C\001ancel", 2, INPUT_KEY_c, widget_cancel_click }, - { NULL } -}; - -static widget_query_entry query_confirm[] = { - { "\012Y\001es", 0, INPUT_KEY_y, widget_yes_click }, - { "\012N\001o", 1, INPUT_KEY_n, widget_no_click }, - { NULL } -}; - -static void -widget_save_click( void ) -{ - widget_query.save = UI_CONFIRM_SAVE_SAVE; -} - -static void -widget_dont_save_click( void ) -{ - widget_query.save = UI_CONFIRM_SAVE_DONTSAVE; -} - -static void -widget_cancel_click( void ) -{ - widget_query.save = UI_CONFIRM_SAVE_CANCEL; -} - -static void -widget_yes_click( void ) -{ - widget_query.confirm = 1; -} - -static void -widget_no_click( void ) -{ - widget_query.confirm = 0; -} - -static size_t highlight_line = 0; - -static char **message_lines; -static size_t num_message_lines; - -static void -widget_query_line_draw( int left_edge, int width, struct widget_query_entry *menu, - const char *label ) -{ - int colour = WIDGET_COLOUR_BACKGROUND; - int y = (menu->index + num_message_lines) * 8 + 24; - - if( menu->index == highlight_line ) colour = WIDGET_COLOUR_HIGHLIGHT; - widget_rectangle( left_edge*8+1, y, width*8-2, 1*8, colour ); - widget_printstring( left_edge*8+8, y, WIDGET_COLOUR_FOREGROUND, - menu->text ); - widget_display_rasters( y, 8 ); -} - -const int query_vert_external_margin = 8; - -static int -widget_calculate_query_width( const char *title, widget_query_entry *menu, - char **lines, int num_lines ) -{ - widget_query_entry *ptr; - int max_width=0; - int i; - - if (!menu) { - return 64; - } - - max_width = widget_stringwidth( title )+5*8; - - for( ptr = menu; ptr->text; ptr++ ) { - int total_width = widget_stringwidth( ptr->text )+3*8; - - if (total_width > max_width) - max_width = total_width; - } - - for( i=0; i max_width ) - max_width = total_width; - } - - return ( max_width + query_vert_external_margin * 2 ) / 8; -} - -static int -internal_query_draw( widget_query_entry *query, int save, const char *message ) -{ - widget_query_entry *ptr; - size_t height = 0; - int menu_width; - int menu_left_edge_x; - int i; - - if( split_message( message, &message_lines, &num_message_lines, 28 ) ) { - return 1; - } - - menu_width = widget_calculate_query_width( title, query, message_lines, - num_message_lines ); - - height = num_message_lines; - - /* How many options do we have? */ - for( ptr = query; ptr->text; ptr++ ) - height ++; - - menu_left_edge_x = DISPLAY_WIDTH_COLS/2-menu_width/2; - - /* Draw the dialog box */ - widget_dialog_with_border( menu_left_edge_x, 2, menu_width, 2 + height ); - - widget_printstring( menu_left_edge_x*8+2, 16, WIDGET_COLOUR_TITLE, title ); - - for( i=0; itext; ptr++ ) { - widget_query_line_draw( menu_left_edge_x, menu_width, ptr, ptr->text ); - } - - widget_display_lines( 2, 2 + height ); - - return 0; -} - -int -widget_query_draw( void *data ) -{ - highlight_line = 0; - widget_query.confirm = 0; - return internal_query_draw( query_confirm, 0, (const char *) data ); -} - -int -widget_query_save_draw( void *data ) -{ - highlight_line = 0; - widget_query.save = UI_CONFIRM_SAVE_CANCEL; - return internal_query_draw( query_save, 1, (const char *) data ); -} - -static void -widget_query_generic_keyhandler( widget_query_entry *query, int num_entries, - input_key key ) -{ - int new_highlight_line = 0; - int cursor_pressed = 0; - widget_query_entry *ptr; - int menu_width = widget_calculate_query_width( title, query, message_lines, - num_message_lines ); - int menu_left_edge_x = DISPLAY_WIDTH_COLS/2-menu_width/2; - - switch( key ) { - -#if 0 - case INPUT_KEY_Resize: /* Fake keypress used on window resize */ - widget_dialog_with_border( 1, 2, 30, 2 + 20 ); - widget_general_show_all( &widget_options_settings ); - break; -#endif - - case INPUT_KEY_Escape: - case INPUT_JOYSTICK_FIRE_2: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - break; - - case INPUT_KEY_Up: - case INPUT_KEY_7: - case INPUT_JOYSTICK_UP: - if ( highlight_line ) { - new_highlight_line = highlight_line - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Down: - case INPUT_KEY_6: - case INPUT_JOYSTICK_DOWN: - if ( highlight_line < num_entries - 2 ) { - new_highlight_line = highlight_line + 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: - query[highlight_line].click(); - widget_end_all( WIDGET_FINISHED_OK ); - display_refresh_all(); - return; - - default: /* Keep gcc happy */ - break; - - } - - if( cursor_pressed ) { - int old_highlight_line = highlight_line; - highlight_line = new_highlight_line; - widget_query_line_draw( menu_left_edge_x, menu_width, - query + old_highlight_line, - query[old_highlight_line].text ); - widget_query_line_draw( menu_left_edge_x, menu_width, - query + highlight_line, - query[highlight_line].text ); - return; - } - - for( ptr=query; ptr->text != NULL; ptr++ ) { - if( key == ptr->key ) { - int old_highlight_line = highlight_line; - ptr->click(); - highlight_line = ptr->index; - widget_query_line_draw( menu_left_edge_x, menu_width, - query + old_highlight_line, - query[old_highlight_line].text ); - widget_query_line_draw( menu_left_edge_x, menu_width, ptr, - query[highlight_line].text ); - break; - } - } -} - -void -widget_query_keyhandler( input_key key ) -{ - widget_query_generic_keyhandler( query_confirm, - ARRAY_SIZE(query_confirm), - key ); -} - -void -widget_query_save_keyhandler( input_key key ) -{ - widget_query_generic_keyhandler( query_save, - ARRAY_SIZE(query_save), - key ); -} - -int -widget_query_finish( widget_finish_state finished ) -{ - int i; - for( i=0; i - -#include -#include -#include -#include - -#include "fuse.h" -#include "settings.h" -#include "widget_internals.h" - -static settings_info *widget_settings; -static widget_roms_info *info; - -static size_t first_rom, rom_count; -int is_peripheral; - -static void print_rom( int which ); - -int -widget_roms_draw( void *data ) -{ - int i; - char buffer[32]; - char key[] = "\x0A "; - - if( data ) info = data; - - /* Get a copy of the current settings */ - if( !info->initialised ) { - - widget_settings = malloc( sizeof( settings_info ) ); - if( !widget_settings ) { - ui_error( UI_ERROR_ERROR, "out of memory at %s:%d", __FILE__, __LINE__ ); - return 1; - } - - memset( widget_settings, 0, sizeof( settings_info ) ); - settings_copy( widget_settings, &settings_current ); - - info->initialised = 1; - } - - first_rom = info->start; - rom_count = info->count; - is_peripheral = info->is_peripheral; - - /* Blank the main display area */ - widget_dialog_with_border( 1, 2, 30, rom_count + 2 ); - - widget_printstring( 10, 16, WIDGET_COLOUR_TITLE, info->title ); - widget_display_lines( 2, rom_count + 2 ); - - for( i=0; i < info->count; i++ ) { - - snprintf( buffer, sizeof( buffer ), "ROM %d:", i ); - key[1] = 'A' + i; - widget_printstring_right( 24, i*8+24, WIDGET_COLOUR_FOREGROUND, key ); - widget_printstring( 28, i*8+24, WIDGET_COLOUR_FOREGROUND, buffer ); - - print_rom( i ); - } - - return 0; -} - -static void -print_rom( int which ) -{ - const char *setting; - - setting = *( settings_get_rom_setting( widget_settings, - which + first_rom, is_peripheral ) ); - while( widget_stringwidth( setting ) >= 232 - 68 ) - ++setting; - - widget_rectangle( 68, which * 8 + 24, 232 - 68, 8, - WIDGET_COLOUR_BACKGROUND ); - widget_printstring (68, which * 8 + 24, - WIDGET_COLOUR_FOREGROUND, setting ); - widget_display_rasters( which * 8 + 24, 8 ); -} - -void -widget_roms_keyhandler( input_key key ) -{ - switch( key ) { - -#if 0 - case INPUT_KEY_Resize: /* Fake keypress used on window resize */ - widget_roms_draw( NULL ); - break; -#endif - - case INPUT_KEY_Escape: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - return; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - widget_end_all( WIDGET_FINISHED_OK ); - return; - - default: /* Keep gcc happy */ - break; - - } - - if( key >= INPUT_KEY_a && key <= INPUT_KEY_z && - key - INPUT_KEY_a < (ptrdiff_t)rom_count ) { - - char **setting; - char buf[32]; - widget_filesel_data data; - - key -= INPUT_KEY_a; - - snprintf( buf, sizeof( buf ), "%s - ROM %d", info->title, key ); - - data.exit_all_widgets = 0; - data.title = buf; - widget_do_fileselector( &data ); - if( !widget_filesel_name ) return; - - setting = settings_get_rom_setting( widget_settings, key + first_rom, - is_peripheral ); - settings_set_string( setting, widget_filesel_name ); - - print_rom( key ); - } -} - -int -widget_roms_finish( widget_finish_state finished ) -{ - if( finished == WIDGET_FINISHED_OK ) { - settings_copy( &settings_current, widget_settings ); - } - - settings_free( widget_settings ); free( widget_settings ); - return 0; -} diff --git a/fuse/ui/widget/select.c b/fuse/ui/widget/select.c deleted file mode 100644 index 542ddd5..0000000 --- a/fuse/ui/widget/select.c +++ /dev/null @@ -1,211 +0,0 @@ -/* select.c: generic selection widget - Copyright (c) 2001-2004 Philip Kendall, Witold Filipczyk - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include - -#include "widget_internals.h" - -/* Data for drawing the cursor */ -static size_t highlight_line; - -const char *title; -const char * const *options; -static int finish_all; -static size_t count; -static int *result; - -static void print_item (int left_edge, int width, int index, int colour) -{ - char key[] = "\x0A "; - key[1] = 'A' + index; - left_edge = ( left_edge + 1 ) * 8 + 1; - left_edge = widget_printstring_ms( left_edge, index * 8 + 24, colour, key ); - left_edge = widget_printstring( left_edge + 1, index * 8 + 24, colour, ": " ); - widget_printstring( left_edge + 1, index * 8 + 24, colour, options[index] ); -} - -const int select_vert_external_margin = 8; - -static int -widget_calculate_select_width( const char* title ) -{ - int i; - int max_width = widget_stringwidth( title )+5*8; - /* Leave room for the option labels we'll be adding */ - int label_width = widget_stringwidth( "A: " ); - - for( i = 0; i < count; i++ ) { - int total_width = label_width + widget_stringwidth( options[i] ) + 3 * 8; - if( total_width > max_width ) - max_width = total_width; - } - - return ( max_width + select_vert_external_margin * 2 ) / 8; -} - -int -widget_select_draw( void *data ) -{ - int i; - size_t width; - int menu_left_edge_x; - - if( data ) { - - widget_select_t *ptr = data; - - title = ptr->title; - options = ptr->options; - count = ptr->count; - result = &( ptr->result ); - finish_all = ptr->finish_all; - - highlight_line = ptr->current; - - } - - width = widget_calculate_select_width( title ); - menu_left_edge_x = DISPLAY_WIDTH_COLS/2-width/2; - - /* Blank the main display area */ - widget_dialog_with_border( menu_left_edge_x, 2, width, count + 2 ); - - widget_printstring( menu_left_edge_x*8+2, 16, WIDGET_COLOUR_TITLE, title ); - - for( i = 0; i < count; i++ ) { - if( i == highlight_line ) { - widget_rectangle( menu_left_edge_x*8+1, i*8+24, width*8-2, 1*8, WIDGET_COLOUR_HIGHLIGHT ); - } - print_item( menu_left_edge_x, width, i, WIDGET_COLOUR_FOREGROUND ); - } - - widget_display_lines( 2, count + 2 ); - - return 0; -} - -void -widget_select_keyhandler( input_key key ) -{ - int new_highlight_line = 0; - int cursor_pressed = 0; - size_t width = widget_calculate_select_width( title ); - int menu_left_edge_x = DISPLAY_WIDTH_COLS/2-width/2; - - switch( key ) { - -#if 0 - case INPUT_KEY_Resize: /* Fake keypress used on window resize */ - widget_select_draw( NULL ); - break; -#endif - - case INPUT_KEY_Escape: - case INPUT_JOYSTICK_FIRE_2: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - return; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - case INPUT_JOYSTICK_FIRE_1: - widget_end_widget( WIDGET_FINISHED_OK ); - return; - - case INPUT_KEY_Up: - case INPUT_KEY_7: - case INPUT_JOYSTICK_UP: - if ( highlight_line ) { - new_highlight_line = highlight_line - 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Down: - case INPUT_KEY_6: - case INPUT_JOYSTICK_DOWN: - if ( highlight_line + 1 < (ptrdiff_t)count ) { - new_highlight_line = highlight_line + 1; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_Home: - if ( highlight_line ) { - new_highlight_line = 0; - cursor_pressed = 1; - } - break; - - case INPUT_KEY_End: - if ( highlight_line + 2 < (ptrdiff_t)count ) { - new_highlight_line = (ptrdiff_t)count - 1; - cursor_pressed = 1; - } - break; - - default: /* Keep gcc happy */ - break; - - } - - if( cursor_pressed || - ( key >= INPUT_KEY_a && key <= INPUT_KEY_z && - key - INPUT_KEY_a < (ptrdiff_t)count ) - ) { - - /* Remove the old highlight */ - widget_rectangle( menu_left_edge_x * 8 + 1, highlight_line * 8 + 24, - width * 8 - 2, 1 * 8, WIDGET_COLOUR_BACKGROUND ); - print_item( menu_left_edge_x, width, highlight_line, - WIDGET_COLOUR_FOREGROUND ); - - /* draw the new one */ - if( cursor_pressed ) { - highlight_line = new_highlight_line; - } else { - highlight_line = key - INPUT_KEY_a; - } - - widget_rectangle( menu_left_edge_x * 8 + 1, highlight_line * 8 + 24, - width * 8 - 2, 1 * 8, WIDGET_COLOUR_HIGHLIGHT ); - print_item( menu_left_edge_x, width, highlight_line, WIDGET_COLOUR_FOREGROUND ); - - widget_display_lines( 2, count + 2 ); - } -} - -int widget_select_finish( widget_finish_state finished ) -{ - if( finished == WIDGET_FINISHED_OK ) { - *result = highlight_line; - if( finish_all ) - widget_end_all( WIDGET_FINISHED_OK ); - } else { - *result = -1; - } - - return 0; -} diff --git a/fuse/ui/widget/text.c b/fuse/ui/widget/text.c deleted file mode 100644 index f16a218..0000000 --- a/fuse/ui/widget/text.c +++ /dev/null @@ -1,177 +0,0 @@ -/* text.c: simple text entry widget - Copyright (c) 2002-2005 Philip Kendall - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include "widget_internals.h" - -char *widget_text_text = NULL; /* What we return the text in */ - -static const char *title; /* The window title */ -static widget_text_input_allow allow; -static unsigned int max_length; - -#define WIDGET_TEXT_LENGTH 64 -static char text[WIDGET_TEXT_LENGTH]; /* The current entry text */ - -static int widget_text_draw_text( void ); -static void delete_character( void ); -static void append_character( char c ); - -int -widget_text_draw( void *data ) -{ - widget_text_t* text_data = data; - - if( data ) { - title = text_data->title; - allow = text_data->allow; - max_length = text_data->max_length; - snprintf( text, sizeof( text ), "%s", text_data->text ); - } - - widget_dialog_with_border( 1, 2, 30, 3 ); - - widget_printstring( 10, 16, WIDGET_COLOUR_TITLE, title ); - widget_printstring_right( 12, 28, 5, "[" ); - widget_printstring( 244, 28, 5, "]" ); - - widget_display_lines( 2, 3 ); - - return widget_text_draw_text(); -} - -static int -widget_text_draw_text( void ) -{ - int width; - const char *tptr; - - widget_rectangle( 12, 28, 232, 8, WIDGET_COLOUR_BACKGROUND ); - - tptr = text - 1; - do { - width = widget_stringwidth (++tptr); - } while (width > 28 * 8 - 4); - - if( tptr != text ) - widget_rectangle( 14, 29, 1, 6, 5 ); - - widget_printstring( 16, 28, WIDGET_COLOUR_FOREGROUND, tptr ); - widget_rectangle( 17 + width, 35, 4, 1, 5 ); - - widget_display_rasters( 28, 8 ); - return 0; -} - -void -widget_text_keyhandler( input_key key ) -{ - switch( key ) { - - case INPUT_KEY_BackSpace: /* Backspace generates DEL which is Caps + 0 */ - delete_character(); widget_text_draw_text(); - return; - - case INPUT_KEY_Escape: - widget_end_widget( WIDGET_FINISHED_CANCEL ); - return; - - case INPUT_KEY_Return: - case INPUT_KEY_KP_Enter: - widget_end_widget( WIDGET_FINISHED_OK ); - return; - - default: /* Keep gcc happy */ - break; - - } - - /* Input validation. - * We rely on various INPUT_KEY_* being mapped directly onto ASCII. - */ - - /* FIXME: we *don't* want keypresses filtered through the input layer */ - - /* First, return if the character isn't printable ASCII. */ - if( key < ' ' || key > '~' ) return; - - /* Return if the key isn't valid. */ - switch( allow ) { - case WIDGET_INPUT_ASCII: - break; - case WIDGET_INPUT_DIGIT: - if( !isdigit( key ) ) return; - break; - case WIDGET_INPUT_ALPHA: - if( !isalpha( key ) ) return; - break; - case WIDGET_INPUT_ALNUM: - if( !isdigit( key ) && !isalpha( key ) ) return; - break; - } - - /* If we've got this far, we have a valid key */ - append_character( key ); - - widget_text_draw_text(); -} - -static void -delete_character( void ) -{ - size_t length = strlen( text ); - - if( length ) text[ length - 1 ] = '\0'; -} - -static void -append_character( char c ) -{ - size_t length = strlen( text ); - - if( length < WIDGET_TEXT_LENGTH - 1 && length < max_length ) { - text[ length ] = c; text[ length + 1 ] = '\0'; - } -} - -int -widget_text_finish( widget_finish_state finished ) -{ - if( finished == WIDGET_FINISHED_OK ) { - - widget_text_text = - libspectrum_renew( char, widget_text_text, strlen( text ) + 1 ); - - strcpy( widget_text_text, text ); - } else { - free( widget_text_text ); - widget_text_text = NULL; - } - - return 0; -} diff --git a/fuse/ui/widget/widget.c b/fuse/ui/widget/widget.c deleted file mode 100644 index f052ceb..0000000 --- a/fuse/ui/widget/widget.c +++ /dev/null @@ -1,848 +0,0 @@ -/* widget.c: Simple dialog boxes for all user interfaces. - Copyright (c) 2001-2005 Matan Ziv-Av, Philip Kendall, Russell Marks - Copyright (c) 2015 Stuart Brady - Copyright (c) 2015 Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include -#ifndef __PS3__ -#include -#endif -#include -#include -#include - -#include -#include -#include - -#include "fuse.h" -#include "display.h" -#include "machine.h" -#include "ui/uidisplay.h" -#include "keyboard.h" -#include "menu.h" -#include "periph.h" -#include "peripherals/joystick.h" -#include "pokefinder/pokefinder.h" -#include "screenshot.h" -#include "timer/timer.h" -#include "ui/widget/options_internals.h" -#include "ui/widget/widget_internals.h" -#include "utils.h" - -#ifdef WIN32 -#include -#endif - -/* Bitmap font storage */ -typedef struct { - libspectrum_byte bitmap[15], left, width, defined; -} widget_font_character; - -static widget_font_character *widget_font[1] = {0}; - -static const widget_font_character default_invalid = { - { 0x7E, 0xDF, 0x9F, 0xB5, 0xA5, 0x8F, 0xDF, 0x7E }, 0, 8, 1 -}; /* "(?)" (inv) */ - -static const widget_font_character default_unknown = { - { 0x7C, 0xDE, 0xBE, 0xAA, 0xDE, 0x7C }, 1, 6, 1 -}; /* "(?)" */ - -static const widget_font_character default_keyword = { - { 0x7C, 0x82, 0xEE, 0xD6, 0xBA, 0x7C }, 1, 6, 1 -}; /* "(K)" */ - -/* The current widget keyhandler */ -widget_keyhandler_fn widget_keyhandler; - -/* The data used for recursive widgets */ -typedef struct widget_recurse_t { - - widget_type type; /* Which type of widget are we? */ - void *data; /* What data were we passed? */ - - int finished; /* Have we finished this widget yet? */ - -} widget_recurse_t; - -static widget_recurse_t widget_return[10]; /* The stack to recurse on */ - -static int widget_read_font( const char *filename ) -{ - utils_file file; - int error; - int i; - - error = utils_read_auxiliary_file( filename, &file, UTILS_AUXILIARY_WIDGET ); - if( error == -1 ) { - ui_error( UI_ERROR_ERROR, "couldn't find font file '%s'", filename ); - return 1; - } - if( error ) return error; - - i = 0; - while( i < file.length ) { - int code, page, left, width; - - if( i + 3 > file.length ) { - ui_error( UI_ERROR_ERROR, "font contains invalid character" ); - utils_close_file( &file ); - return 1; - } - - code = file.buffer[i]; - page = file.buffer[i+1]; - if( page == 0 && ( code == 0xA3 || ( code < 0x7F && code != 0x60 ) ) ) { - left = file.buffer[i+2] & 7; - } else { - left = -1; - } - width = file.buffer[i+2] >> 4 & 15; - - /* weed out invalid character codes and misdefined characters */ - if( page != 0 /* we don't currently have more than page 0 */ - || i + 3 + width > file.length || (left >= 0 && left + width > 8) ) - { - ui_error( UI_ERROR_ERROR, "font contains invalid character" ); - utils_close_file( &file ); - return 1; - } - - if( !widget_font[page] ) - { - widget_font[page] = calloc( 256, sizeof( widget_font_character ) ); - if( !widget_font[page] ) - { - ui_error( UI_ERROR_ERROR, "out of memory" ); - utils_close_file( &file ); - return 1; - } - } - - widget_font[page][code].defined = 1; - widget_font[page][code].left = left < 0 ? 0 : left; - widget_font[page][code].width = width ? width : 3; - memcpy( &widget_font[page][code].bitmap, &file.buffer[i+3], width ); - - i += 3 + width; - } - - utils_close_file( &file ); - - return 0; -} - -static const widget_font_character * -widget_char( int pp ) -{ - if( pp < 0 || pp >= 256 ) return &default_invalid; - if( !widget_font[pp >> 8] || !widget_font[pp >> 8][pp & 255].defined ) - return &default_unknown; - return &widget_font[ pp >> 8 ][ pp & 255 ]; -} - -static int -printchar( int x, int y, int col, int ch ) -{ - int mx, my; - const widget_font_character *bitmap = widget_char( ch ); - - for( mx = 0; mx < bitmap->width; mx++ ) { - int b = bitmap->bitmap[mx]; - for( my = 0; my < 8; my++ ) - if( b & 128 >> my ) widget_putpixel( x + mx, y + my, col ); - } - - return x + bitmap->width + 1; -} - -int -widget_printstring1( int x, int y, int col, const char *s, int ms ) -{ - int ms_x, c; - int shadow = 0; - if( !s ) return x; - - ms_x = x; - while( x < 256 + DISPLAY_BORDER_ASPECT_WIDTH - && ( c = *(libspectrum_byte *)s++ ) != 0 ) { - if( col == WIDGET_COLOUR_DISABLED && c < 26 ) continue; - if( col != WIDGET_COLOUR_DISABLED ) { - if( c && c < 17 ) { col = c - 1; continue; } - if( c < 26 ) { shadow = c - 17; continue; } - } - - if( shadow && col ) { - printchar( x - 1, y, shadow - 1, c ); - printchar( x + 1, y, shadow - 1, c ); - printchar( x, y - 1, shadow - 1, c ); - printchar( x, y + 1, shadow - 1, c ); - printchar( x + 1, y + 1, shadow - 1, c ); - x = printchar( x, y, (col & 7) ^ 8, c ); - } else - x = printchar( x, y, col, c ); - - if( ms ) - ms_x = x = ms_x + 8; - } - return x; -} - -int -widget_printstring_fixed( int x, int y, int col, const char *s ) -{ - int c; - - if( !s ) return x; - - while( x < 256 + DISPLAY_BORDER_ASPECT_WIDTH - && ( c = *(libspectrum_byte *)s++ ) != 0 ) { - widget_printchar_fixed(x, y, col, c); - x += 8; - } - return x; -} - -void -widget_printchar_fixed( int x, int y, int col, int c ) -{ - int mx, my; - int inverse = 0; - const widget_font_character *bitmap; - - if( c < 128 ) - bitmap = widget_char( c ); - else if( c < 144 ) { - if( c & 1 ) widget_rectangle( x + 4, y , 4, 4, col ); - if( c & 2 ) widget_rectangle( x , y , 4, 4, col ); - if( c & 4 ) widget_rectangle( x + 4, y + 4, 4, 4, col ); - if( c & 8 ) widget_rectangle( x , y + 4, 4, 4, col ); - return; - } else if( c < 165 ) { - inverse = 1; - bitmap = widget_char( c - 144 + 'A' ); - } else { - bitmap = &default_keyword; - } - - x += bitmap->left; - for( mx = 0; mx < bitmap->width; mx++ ) { - int b = bitmap->bitmap[mx]; - if( inverse ) b = ~b; - for( my = 0; my < 8; my++ ) - if( b & 128 >> my ) widget_putpixel( x + mx, y + my, col ); - } -} - -void widget_print_title( int y, int col, const char *s ) -{ - char buffer[128]; - snprintf( buffer, sizeof( buffer ), "\x0A%s", s ); - widget_printstring1( 128 - widget_stringwidth( buffer ) / 2, y, col, buffer, - 0 ); -} - -void widget_printstring_right( int x, int y, int col, const char *s ) -{ - widget_printstring1( x - widget_stringwidth( s ), y, col, s, 0 ); -} - -size_t widget_stringwidth( const char *s ) -{ - return widget_substringwidth( s, UINT_MAX ); -} - -size_t widget_substringwidth( const char *s, size_t count ) -{ - size_t width = 0; - int c; - - if( !s || !count ) - return 0; - - while( count-- && (c = *(libspectrum_byte *)s++) != 0 ) { - if( c < 18 ) - continue; - width += widget_char( c )->width + 1; - } - return width - 1; -} - -size_t widget_charwidth( int c ) -{ - return widget_char( c )->width; -} - -void widget_rectangle( int x, int y, int w, int h, int col ) -{ - int mx, my; - - for( my = 0; my < h; my++ ) - for( mx = 0; mx < w; mx++ ) - widget_putpixel( x + mx, y + my, col ); -} - -void -widget_draw_line_horiz(int x, int y, int length, int colour ) -{ - int i; - - for (i=0; i DISPLAY_SCREEN_WIDTH - 1 ) - w = DISPLAY_SCREEN_WIDTH - x; - - if( y + h > DISPLAY_SCREEN_HEIGHT - 1 ) - h = DISPLAY_SCREEN_HEIGHT - y; - - for (v=0; vtimex ? 2 : 1; - - uidisplay_area( 0, scale * ( DISPLAY_BORDER_HEIGHT + y ), - scale * DISPLAY_ASPECT_WIDTH, scale * h ); - uidisplay_frame_end(); -} - -/* Global initialisation/end routines */ - -int widget_init( void ) -{ - int error; - - error = widget_read_font( "fuse.font" ); - if( error ) return error; - - widget_filenames = NULL; - widget_numfiles = 0; - - ui_menu_activate( UI_MENU_ITEM_AY_LOGGING, 0 ); - ui_menu_activate( UI_MENU_ITEM_FILE_MOVIE_RECORDING, 0 ); - ui_menu_activate( UI_MENU_ITEM_MACHINE_PROFILER, 0 ); - ui_menu_activate( UI_MENU_ITEM_RECORDING, 0 ); - ui_menu_activate( UI_MENU_ITEM_RECORDING_ROLLBACK, 0 ); - ui_menu_activate( UI_MENU_ITEM_TAPE_RECORDING, 0 ); -#ifdef HAVE_LIB_XML2 - ui_menu_activate( UI_MENU_ITEM_FILE_SVG_CAPTURE, 0 ); -#endif - return 0; -} - -int widget_end( void ) -{ - size_t i; - - if( widget_filenames ) { - for( i=0; iname ); - free( widget_filenames[i] ); - } - free( widget_filenames ); - } - - /* we don't currently have more than page 0 */ - free( widget_font[0] ); - - return 0; -} - -/* General widget routine */ - -int widget_do( widget_type which, void *data ) -{ - /* If we don't have a UI yet, we can't output widgets */ - if( !display_ui_initialised ) return 1; - - if( which == WIDGET_TYPE_QUERY && !settings_current.confirm_actions ) { - widget_query.confirm = 1; - return 0; - } - - if( ui_widget_level == -1 ) uidisplay_frame_save(); - - /* We're now one widget level deeper */ - ui_widget_level++; - - /* Store what type of widget we are and what data we were given */ - widget_return[ui_widget_level].type = which; - widget_return[ui_widget_level].data = data; - - uidisplay_frame_restore(); - - /* Draw this widget */ - widget_data[ which ].draw( data ); - - /* Set up the keyhandler for this widget */ - widget_keyhandler = widget_data[which].keyhandler; - - /* Process this widget until it returns */ - widget_return[ui_widget_level].finished = 0; - while( ! widget_return[ui_widget_level].finished ) { - - /* Go to sleep for a bit */ - timer_sleep( 10 ); - - /* Process any events */ - ui_event(); - } - - /* Do any post-widget processing if it exists */ - if( widget_data[which].finish ) { - widget_data[which].finish( widget_return[ui_widget_level].finished ); - } - - uidisplay_frame_restore(); - - /* Now return to the previous widget level */ - ui_widget_level--; - - if( ui_widget_level >= 0 ) { - - /* If we're going back to another widget, set up its keyhandler and - draw it again, unless it's already finished */ - if( ! widget_return[ui_widget_level].finished ) { - widget_keyhandler = - widget_data[ widget_return[ui_widget_level].type ].keyhandler; - widget_data[ widget_return[ui_widget_level].type ].draw( - widget_return[ui_widget_level].data - ); - } - - } else { - - /* Refresh the Spectrum's display, including the border */ - display_refresh_all(); - - } - - return 0; -} - -/* End the currently running widget */ -int -widget_end_widget( widget_finish_state state ) -{ - widget_return[ ui_widget_level ].finished = state; - return 0; -} - -/* End all currently running widgets */ -int widget_end_all( widget_finish_state state ) -{ - int i; - - for( i=0; i<=ui_widget_level; i++ ) - widget_return[i].finished = state; - - return 0; -} - -void -widget_finish( void ) -{ - widget_end_all( WIDGET_FINISHED_OK ); -} - -int widget_dialog( int x, int y, int width, int height ) -{ - widget_rectangle( 8*x, 8*y, 8*width, 8*height, WIDGET_COLOUR_BACKGROUND ); - return 0; -} - -static void -widget_draw_speccy_rainbow_bar(int x, int y) -{ - int i = 0; - int cur_x = x - 8; - - for (i = 0; i < 8; i++) { - widget_draw_line_horiz(cur_x, y + i, 8, 10); /* bright red */ - widget_draw_line_horiz(cur_x + 8, y + i, 8, 14); /* bright yellow */ - widget_draw_line_horiz(cur_x + 16, y + i, 8, 12); /* bright green */ - widget_draw_line_horiz(cur_x + 24, y + i, 8, 13); /* bright cyan */ - cur_x--; - } -} - -const int menu_vert_external_margin = 8; - -int -widget_calculate_menu_width(widget_menu_entry *menu) -{ - widget_menu_entry *ptr; - int max_width=0; - - if (!menu) { - return 64; - } - - max_width = widget_stringwidth( menu->text )+5*8; - - for( ptr = &menu[1]; ptr->text; ptr++ ) { - int total_width = widget_stringwidth(ptr->text)+8; - - if( ptr->submenu ) { - total_width += 3*8; - } - - /* If this has extra details, leave room for the extra text */ - if( ptr->detail ) total_width += widget_stringwidth( ptr->detail() )+2*8; - - if (total_width > max_width) - max_width = total_width; - } - - return (max_width+menu_vert_external_margin*2)/8; -} - - -int widget_dialog_with_border( int x, int y, int width, int height ) -{ - int ink = WIDGET_COLOUR_FOREGROUND; - int paper = WIDGET_COLOUR_BACKGROUND; - - x += DISPLAY_BORDER_WIDTH_COLS; - y += DISPLAY_BORDER_HEIGHT_COLS; - - widget_draw_rectangle_solid(8*x + 1, 8*y + 1, 8*width - 2, - 8*height - 2, paper); - widget_draw_rectangle_solid(8*x + 1, 8*y + 1, 8*width - 2, 7*1, ink); - widget_draw_rectangle_outline_rounded(8*x, 8*y, 8*width, 8*height, ink); - - widget_draw_speccy_rainbow_bar(8*x + 8*width - 32, 8*y); - - return 0; -} - -void -widget_putpixel( int x, int y, int colour ) -{ - uidisplay_putpixel( x + DISPLAY_BORDER_ASPECT_WIDTH, y + DISPLAY_BORDER_HEIGHT, - colour ); -} - -/* The widgets actually available. Make sure the order here matches the - order defined in enum widget_type (widget.h) */ - -widget_t widget_data[] = { - - { widget_filesel_load_draw, widget_filesel_finish, widget_filesel_keyhandler }, - { widget_filesel_save_draw, widget_filesel_finish, widget_filesel_keyhandler }, - { widget_general_draw, widget_options_finish, widget_general_keyhandler }, - { widget_picture_draw, NULL, widget_picture_keyhandler }, - { widget_about_draw, NULL, widget_about_keyhandler }, - { widget_menu_draw, NULL, widget_menu_keyhandler }, - { widget_select_draw, widget_select_finish, widget_select_keyhandler }, - { widget_media_draw, widget_options_finish, widget_media_keyhandler }, - { widget_sound_draw, widget_options_finish, widget_sound_keyhandler }, - { widget_error_draw, NULL, widget_error_keyhandler }, - { widget_rzx_draw, widget_options_finish, widget_rzx_keyhandler }, - { widget_movie_draw, widget_options_finish, widget_movie_keyhandler }, - { widget_browse_draw, widget_browse_finish, widget_browse_keyhandler }, - { widget_text_draw, widget_text_finish, widget_text_keyhandler }, - { widget_debugger_draw, NULL, widget_debugger_keyhandler }, - { widget_pokefinder_draw, NULL, widget_pokefinder_keyhandler }, - { widget_pokemem_draw, widget_pokemem_finish, widget_pokemem_keyhandler }, - { widget_memory_draw, NULL, widget_memory_keyhandler }, - { widget_roms_draw, widget_roms_finish, widget_roms_keyhandler }, - { widget_peripherals_general_draw, widget_options_finish, widget_peripherals_general_keyhandler }, - { widget_peripherals_disk_draw, widget_options_finish, widget_peripherals_disk_keyhandler }, - { widget_query_draw, widget_query_finish, widget_query_keyhandler }, - { widget_query_save_draw,widget_query_finish, widget_query_save_keyhandler }, - { widget_diskoptions_draw, widget_options_finish, widget_diskoptions_keyhandler }, - { widget_binary_draw, widget_binary_finish, widget_binary_keyhandler }, -}; - -#ifndef UI_SDL -#ifndef UI_X -/* The statusbar handling functions */ -/* TODO: make these do something useful */ -int -ui_statusbar_update( ui_statusbar_item item, ui_statusbar_state state ) -{ - return 0; -} - -int -ui_statusbar_update_speed( float speed ) -{ - return 0; -} -#endif -#endif /* #ifndef UI_SDL */ - -/* Tape browser update function. The dialog box is created every time it - is displayed, so no need to do anything here */ -int -ui_tape_browser_update( ui_tape_browser_update_type change, - libspectrum_tape_block *block ) -{ - return 0; -} - -ui_confirm_save_t -ui_confirm_save_specific( const char *message ) -{ - if( !settings_current.confirm_actions ) return UI_CONFIRM_SAVE_DONTSAVE; - - if( widget_do_query_save( message ) ) - return UI_CONFIRM_SAVE_CANCEL; - return widget_query.confirm; -} - -int -ui_query( const char *message ) -{ - widget_do_query( message ); - return widget_query.save; -} - -/* FIXME: make this do something useful */ -int -ui_get_rollback_point( GSList *points ) -{ - return -1; -} - -ui_confirm_joystick_t -ui_confirm_joystick( libspectrum_joystick libspectrum_type, int inputs ) -{ - widget_select_t info; - int error; - char title[80]; - - if(( !settings_current.joy_prompt ) && (inputs & LIBSPECTRUM_JOYSTICK_INPUT_JOYSTICK_1)) - return UI_CONFIRM_JOYSTICK_JOYSTICK_1; - - if( !settings_current.joy_prompt ) return UI_CONFIRM_JOYSTICK_NONE; - - snprintf( title, sizeof( title ), "Configure %s joystick", - libspectrum_joystick_name( libspectrum_type ) ); - - info.title = title; - info.options = joystick_connection; - info.count = JOYSTICK_CONN_COUNT; - info.current = UI_CONFIRM_JOYSTICK_NONE; - info.finish_all = 1; - - error = widget_do_select( &info ); - if( error ) return UI_CONFIRM_JOYSTICK_NONE; - - return (ui_confirm_joystick_t)info.result; -} - -int -ui_widgets_reset( void ) -{ - pokefinder_clear(); - return 0; -} - -void -ui_popup_menu( int native_key ) -{ - switch( native_key ) { - case INPUT_KEY_F1: - fuse_emulation_pause(); - widget_do_menu( widget_menu ); - fuse_emulation_unpause(); - break; - case INPUT_KEY_F2: - fuse_emulation_pause(); - menu_file_savesnapshot( 0 ); - fuse_emulation_unpause(); - break; - case INPUT_KEY_F3: - fuse_emulation_pause(); - menu_file_open( 0 ); - fuse_emulation_unpause(); - break; - case INPUT_KEY_F4: - fuse_emulation_pause(); - menu_options_general( 0 ); - fuse_emulation_unpause(); - break; - case INPUT_KEY_F5: - fuse_emulation_pause(); - menu_machine_reset( 0 ); - fuse_emulation_unpause(); - break; - case INPUT_KEY_F6: - fuse_emulation_pause(); - menu_media_tape_write( 0 ); - fuse_emulation_unpause(); - break; - case INPUT_KEY_F7: - fuse_emulation_pause(); - menu_media_tape_open( 0 ); - fuse_emulation_unpause(); - break; - case INPUT_KEY_F8: - menu_media_tape_play( 0 ); - break; - case INPUT_KEY_F9: - fuse_emulation_pause(); - menu_machine_select( 0 ); - fuse_emulation_unpause(); - break; - case INPUT_KEY_F10: - fuse_emulation_pause(); - menu_file_exit( 0 ); - fuse_emulation_unpause(); - break; - - default: break; /* Remove gcc warning */ - - } -} - -void -ui_widget_keyhandler( int native_key ) -{ - widget_keyhandler( native_key ); -} diff --git a/fuse/ui/widget/widget.h b/fuse/ui/widget/widget.h deleted file mode 100644 index 9f3c384..0000000 --- a/fuse/ui/widget/widget.h +++ /dev/null @@ -1,322 +0,0 @@ -/* widget.h: Simple dialog boxes for all user interfaces. - Copyright (c) 2001-2004 Matan Ziv-Av, Philip Kendall - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#ifndef FUSE_WIDGET_H -#define FUSE_WIDGET_H - -#include "input.h" -#include "ui/scaler/scaler.h" -#include "ui/ui.h" - -/* Code called at start and end of emulation */ -int widget_init( void ); -int widget_end( void ); - -/* The various widgets which are available */ -typedef enum widget_type { - - WIDGET_TYPE_FILESELECTOR, /* File selector (load) */ - WIDGET_TYPE_FILESELECTOR_SAVE,/* File selector (save) */ - WIDGET_TYPE_GENERAL, /* General options */ - WIDGET_TYPE_PICTURE, /* Keyboard picture */ - WIDGET_TYPE_ABOUT, /* About info */ - WIDGET_TYPE_MENU, /* General menu */ - WIDGET_TYPE_SELECT, /* Select machine */ - WIDGET_TYPE_MEDIA, /* Media options */ - WIDGET_TYPE_SOUND, /* Sound options */ - WIDGET_TYPE_ERROR, /* Error report */ - WIDGET_TYPE_RZX, /* RZX options */ - WIDGET_TYPE_MOVIE, /* Movie options */ - WIDGET_TYPE_BROWSE, /* Browse tape */ - WIDGET_TYPE_TEXT, /* Text entry widget */ - WIDGET_TYPE_DEBUGGER, /* Debugger widget */ - WIDGET_TYPE_POKEFINDER, /* Poke finder widget */ - WIDGET_TYPE_POKEMEM, /* Poke memory widget */ - WIDGET_TYPE_MEMORYBROWSER, /* Memory browser widget */ - WIDGET_TYPE_ROM, /* ROM selector widget */ - WIDGET_TYPE_PERIPHERALS_GENERAL, /* General peripherals options */ - WIDGET_TYPE_PERIPHERALS_DISK, /* Disk peripherals options */ - WIDGET_TYPE_QUERY, /* Query (yes/no) */ - WIDGET_TYPE_QUERY_SAVE, /* Query (save/don't save/cancel) */ - WIDGET_TYPE_DISKOPTIONS, /* Disk options widget */ - WIDGET_TYPE_BINARY, /* Binary load/save */ -} widget_type; - -/* Activate a widget */ -int widget_do( widget_type which, void *data ); - -/* Finish with widgets for now */ -void widget_finish( void ); - -/* A function to handle keypresses */ -typedef void (*widget_keyhandler_fn)( input_key key ); - -/* The current widget keyhandler */ -extern widget_keyhandler_fn widget_keyhandler; - -/* Widget-specific bits */ - -/* Menu widget */ - -/* A generic callback function */ -typedef void (*widget_menu_callback_fn)( int action ); - -/* A generic menu detail callback function */ -typedef const char* (*widget_menu_detail_callback_fn)( void ); - -/* A general menu */ -typedef struct widget_menu_entry { - const char *text; /* Menu entry text */ - input_key key; /* Which key to activate this widget */ - - struct widget_menu_entry *submenu; - widget_menu_callback_fn callback; - widget_menu_detail_callback_fn detail; - - int action; - int inactive; - -} widget_menu_entry; - -/* The main menu as activated with F1 */ -extern widget_menu_entry widget_menu[]; - -/* Get the maximum menu width to use in pixels */ -int widget_calculate_menu_width( widget_menu_entry *menu ); - -/* The name returned from the file selector */ -extern char* widget_filesel_name; - -/* Select a machine */ -int widget_select_machine( void *data ); - -/* The error widget data type */ - -typedef struct widget_error_t { - ui_error_level severity; - const char *message; -} widget_error_t; - -#ifndef __PS3__ -typedef struct widget_filesel_data widget_filesel_data; -typedef struct widget_picture_data widget_picture_data; -typedef struct widget_text_t widget_text_t; -typedef struct widget_select_t widget_select_t; -typedef struct widget_roms_info widget_roms_info; -#else -typedef struct widget_filesel_data { - int exit_all_widgets; - const char *title; -} widget_filesel_data; -typedef struct widget_picture_data { - const char *filename; - libspectrum_byte *screen; - int border; -} widget_picture_data; -typedef enum widget_text_input_allow { - WIDGET_INPUT_ASCII, - WIDGET_INPUT_DIGIT, - WIDGET_INPUT_ALPHA, - WIDGET_INPUT_ALNUM -} widget_text_input_allow; -typedef struct widget_text_t { - const char *title; - widget_text_input_allow allow; - unsigned int max_length; - char text[40]; -} widget_text_t; - -typedef struct widget_roms_info { - - int initialised; - - const char *title; - size_t start, count; - int is_peripheral; - -} widget_roms_info; -typedef struct widget_select_t { - - const char *title; /* Dialog title */ - const char * const *options; /* The available options */ - size_t count; /* The number of options */ - size_t current; /* Which option starts active? */ - - int result; /* What was selected? ( -1 if dialog cancelled ) */ - int finish_all; /* close all widget or not */ - -} widget_select_t; -#endif - -/* File selector (load) */ -static inline int widget_do_fileselector( widget_filesel_data *data ) -{ - return widget_do( WIDGET_TYPE_FILESELECTOR, data ); -} - -/* File selector (save) */ -static inline int widget_do_fileselector_save( widget_filesel_data *data ) -{ - return widget_do( WIDGET_TYPE_FILESELECTOR_SAVE, data ); -} - -/* General options */ -static inline int widget_do_general( void ) -{ - return widget_do( WIDGET_TYPE_GENERAL, NULL ); -} - -/* Keyboard picture */ -static inline int widget_do_picture( widget_picture_data *data ) -{ - return widget_do( WIDGET_TYPE_PICTURE, data ); -} - -/* About fuse widget */ -static inline int widget_do_about( void ) -{ - return widget_do( WIDGET_TYPE_ABOUT, NULL ); -} - -/* General menu */ -static inline int widget_do_menu( widget_menu_entry *data ) -{ - return widget_do( WIDGET_TYPE_MENU, data ); -} - -/* Select machine */ -static inline int widget_do_select( widget_select_t *data ) -{ - return widget_do( WIDGET_TYPE_SELECT, data ); -} - -/* Media options */ -static inline int widget_do_media( void ) -{ - return widget_do( WIDGET_TYPE_MEDIA, NULL ); -} - -/* Sound options */ -static inline int widget_do_sound( void ) -{ - return widget_do( WIDGET_TYPE_SOUND, NULL ); -} - -/* Error report */ -static inline int widget_do_error( widget_error_t *data ) -{ - return widget_do( WIDGET_TYPE_ERROR, data ); -} - -/* RZX options */ -static inline int widget_do_rzx( void ) -{ - return widget_do( WIDGET_TYPE_RZX, NULL ); -} - -/* Movie options */ -static inline int widget_do_movie( void ) -{ - return widget_do( WIDGET_TYPE_MOVIE, NULL ); -} - -/* Browse tape */ -static inline int widget_do_browse( void ) -{ - return widget_do( WIDGET_TYPE_BROWSE, NULL ); -} - -/* Text entry widget */ -static inline int widget_do_text( widget_text_t *data ) -{ - return widget_do( WIDGET_TYPE_TEXT, data ); -} - -/* Debugger widget */ -static inline int widget_do_debugger( void ) -{ - return widget_do( WIDGET_TYPE_DEBUGGER, NULL ); -} - -/* Poke finder widget */ -static inline int widget_do_pokefinder( void ) -{ - return widget_do( WIDGET_TYPE_POKEFINDER, NULL ); -} - -/* Poke memory widget */ -static inline int widget_do_pokemem( void ) -{ - return widget_do( WIDGET_TYPE_POKEMEM, NULL ); -} - -/* Memory browser widget */ -static inline int widget_do_memorybrowser( void ) -{ - return widget_do( WIDGET_TYPE_MEMORYBROWSER, NULL ); -} - -/* ROM selector widget */ -static inline int widget_do_rom( widget_roms_info *data ) -{ - return widget_do( WIDGET_TYPE_ROM, data ); -} - -/* General peripherals options */ -static inline int widget_do_peripherals_general( void ) -{ - return widget_do( WIDGET_TYPE_PERIPHERALS_GENERAL, NULL ); -} - -/* Disk peripherals options */ -static inline int widget_do_peripherals_disk( void ) -{ - return widget_do( WIDGET_TYPE_PERIPHERALS_DISK, NULL ); -} - -/* Query (yes/no) */ -static inline int widget_do_query( const char *message ) -{ - return widget_do( WIDGET_TYPE_QUERY, (void *)message ); -} - -/* Query (save/don't save/cancel) */ -static inline int widget_do_query_save( const char *message ) -{ - return widget_do( WIDGET_TYPE_QUERY_SAVE, (void *)message ); -} - -/* Disk options widget */ -static inline int widget_do_diskoptions( void ) -{ - return widget_do( WIDGET_TYPE_DISKOPTIONS, NULL ); -} - -/* Binary load/save widget */ -static inline int widget_do_binary( void ) -{ - return widget_do( WIDGET_TYPE_BINARY, NULL ); -} - -#endif /* #ifndef FUSE_WIDGET_H */ diff --git a/fuse/ui/widget/widget_internals.h b/fuse/ui/widget/widget_internals.h deleted file mode 100644 index d5f9059..0000000 --- a/fuse/ui/widget/widget_internals.h +++ /dev/null @@ -1,292 +0,0 @@ -/* widget_internals.h: Functions internal to the widget code - Copyright (c) 2001-2005 Matan Ziv-Av, Philip Kendall - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#ifndef FUSE_WIDGET_INTERNALS_H -#define FUSE_WIDGET_INTERNALS_H - -#include -#include - -#include - -#include "settings.h" -#include "widget.h" - -/* The default colours used in the widget */ -#define WIDGET_COLOUR_DISABLED 7 /* White */ -#define WIDGET_COLOUR_BACKGROUND 15 /* Bright White */ -#define WIDGET_COLOUR_FOREGROUND 0 /* Black */ -#define WIDGET_COLOUR_HIGHLIGHT 13 /* Cyan */ -#define WIDGET_COLOUR_TITLE WIDGET_COLOUR_BACKGROUND - -/* The ways of finishing a widget */ -typedef enum widget_finish_state { - WIDGET_FINISHED_OK = 1, - WIDGET_FINISHED_CANCEL, -} widget_finish_state; - -/* A function to draw a widget */ -typedef int (*widget_draw_fn)( void *data ); - -/* The information we need to store for each widget */ -typedef struct widget_t { - widget_draw_fn draw; /* Draw this widget */ - int (*finish)( widget_finish_state finished ); /* Post-widget processing */ - widget_keyhandler_fn keyhandler; /* Keyhandler */ -} widget_t; - -int widget_end_widget( widget_finish_state state ); -int widget_end_all( widget_finish_state state ); - -int widget_timer_init( void ); -int widget_timer_end( void ); - -void widget_putpixel( int x, int y, int colour ); -void widget_rectangle( int x, int y, int w, int h, int col ); -void widget_draw_line_horiz( int x, int y, int length, int colour ); -void widget_draw_line_vert( int x, int y, int length, int colour ); -void widget_draw_rectangle_outline( int x, int y, int w, int h, int colour ); -void widget_draw_rectangle_solid( int x, int y, int w, int h, int colour ); -void widget_draw_rectangle_outline_rounded( int x, int y, int w, int h, int colour ); -int widget_printstring1( int x, int y, int col, const char *s, int ms ); -#define widget_printstring( x, y, col, s ) \ - widget_printstring1( x, y, col, s, 0 ) -#define widget_printstring_ms( x, y, col, s ) \ - widget_printstring1( x, y, col, s, 1 ) -int widget_printstring_fixed( int x, int y, int col, const char *s ); -void widget_printchar_fixed( int x, int y, int col, int c ); -void widget_print_title( int y, int col, const char *s ); -void widget_printstring_right( int x, int y, int col, const char *s ); -void widget_display_rasters( int y, int h ); -#define widget_display_lines(y,h) widget_display_rasters((y)*8,(h)*8) - -size_t widget_stringwidth( const char *s ); -size_t widget_substringwidth( const char *s, size_t count ); -size_t widget_charwidth( int c ); - -void widget_up_arrow( int x, int y, int colour ); -void widget_down_arrow( int x, int y, int colour ); -void widget_draw_submenu_arrow(int x, int y, int colour); -void widget_print_checkbox( int x, int y, int colour, int value ); - -extern widget_finish_state widget_finished; - -int widget_dialog( int x, int y, int width, int height ); -int widget_dialog_with_border( int x, int y, int width, int height ); - -int split_message( const char *message, char ***lines, size_t *count, - const size_t line_length ); - -/* File selector */ - -typedef struct widget_dirent { - int mode; - char *name; -} widget_dirent; - -#ifndef __PS3__ -typedef struct widget_filesel_data { - int exit_all_widgets; - const char *title; -} widget_filesel_data; -#endif - -extern struct widget_dirent **widget_filenames; -extern size_t widget_numfiles; - -int widget_filesel_load_draw( void* data ); -int widget_filesel_save_draw( void* data ); -int widget_filesel_finish( widget_finish_state finished ); -void widget_filesel_keyhandler( input_key key ); - -/* Tape menu */ - -int widget_tape_draw( void* data ); -void widget_tape_keyhandler( input_key key ); - -/* File menu */ - -int widget_file_draw( void* data ); -void widget_file_keyhandler( input_key key ); - -/* Options menu */ -int widget_menu_filter( void *data ); - -/* Machine menu */ - -int widget_machine_draw( void* data ); -void widget_machine_keyhandler( input_key key ); - -/* Keyboard picture */ - -#ifndef __PS3__ -typedef struct widget_picture_data { - const char *filename; - libspectrum_byte *screen; - int border; -} widget_picture_data; -#endif - -int widget_picture_draw( void* data ); -void widget_picture_keyhandler( input_key key ); - -/* Help menu */ - -int widget_help_draw( void* data ); -void widget_help_keyhandler( input_key key ); - -/* General menu code */ - -int widget_menu_draw( void* data ); -void widget_menu_keyhandler( input_key key ); - -/* More callbacks */ -scaler_type widget_select_scaler( int (*selector)( scaler_type ) ); - -/* The generalised selector widget */ - -#ifndef __PS3__ -typedef struct widget_select_t { - - const char *title; /* Dialog title */ - const char * const *options; /* The available options */ - size_t count; /* The number of options */ - size_t current; /* Which option starts active? */ - - int result; /* What was selected? ( -1 if dialog cancelled ) */ - int finish_all; /* close all widget or not */ - -} widget_select_t; -#endif - -int widget_select_draw( void *data ); -void widget_select_keyhandler( input_key key ); -int widget_select_finish( widget_finish_state finished ); - -/* The tape browser widget */ - -int widget_browse_draw( void* data ); -void widget_browse_keyhandler( input_key key ); -int widget_browse_finish( widget_finish_state finished ); - -/* The text entry widget */ - -#ifndef __PS3__ -typedef enum widget_text_input_allow { - WIDGET_INPUT_ASCII, - WIDGET_INPUT_DIGIT, - WIDGET_INPUT_ALPHA, - WIDGET_INPUT_ALNUM -} widget_text_input_allow; - -typedef struct widget_text_t { - const char *title; - widget_text_input_allow allow; - unsigned int max_length; - char text[40]; -} widget_text_t; -#endif - -int widget_text_draw( void* data ); -void widget_text_keyhandler( input_key key ); -int widget_text_finish( widget_finish_state finished ); - -extern char *widget_text_text; /* The returned text */ - -/* The options widgets */ -int widget_options_finish( widget_finish_state finished ); - -/* The error widget */ - -int widget_error_draw( void *data ); -void widget_error_keyhandler( input_key key ); - -/* The debugger widget */ - -int widget_debugger_draw( void *data ); -void widget_debugger_keyhandler( input_key key ); - -/* The poke file widget */ - -int widget_pokemem_draw( void *data ); -void widget_pokemem_keyhandler( input_key key ); -int widget_pokemem_finish( widget_finish_state finished ); - -/* The poke finder widget */ - -int widget_pokefinder_draw( void *data ); -void widget_pokefinder_keyhandler( input_key key ); - -/* The memory browser widget */ - -int widget_memory_draw( void *data ); -void widget_memory_keyhandler( input_key key ); - -/* The about fuse widget */ - -int widget_about_draw( void *data ); -void widget_about_keyhandler( input_key key ); - -/* The ROM selector widget */ - -#ifndef __PS3__ -typedef struct widget_roms_info { - - int initialised; - - const char *title; - size_t start, count; - int is_peripheral; - -} widget_roms_info; -#endif - -int widget_roms_draw( void *data ); -void widget_roms_keyhandler( input_key key ); -int widget_roms_finish( widget_finish_state finished ); - -/* The query widgets */ - -typedef union { - int confirm; - ui_confirm_save_t save; -} widget_query_t; - -extern widget_query_t widget_query; - -int widget_query_draw( void *data ); -void widget_query_keyhandler( input_key key ); -int widget_query_save_draw( void *data ); -void widget_query_save_keyhandler( input_key key ); -int widget_query_finish( widget_finish_state finished ); - -int widget_binary_draw( void *data ); -void widget_binary_keyhandler( input_key key ); -int widget_binary_finish( widget_finish_state finished ); - -/* The widgets actually available */ - -extern widget_t widget_data[]; - -#endif /* #ifndef FUSE_WIDGET_INTERNALS_H */ diff --git a/fuse/ui/wii/Makefile.am b/fuse/ui/wii/Makefile.am deleted file mode 100644 index 75c1ea1..0000000 --- a/fuse/ui/wii/Makefile.am +++ /dev/null @@ -1,50 +0,0 @@ -## Process this file with automake to produce Makefile.in -## Copyright (c) 2001-2009 Philip Kendall, Bjoern Giesler -## Copyright (c) 2015 Sergio Baldoví - -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -## -## Author contact information: -## -## E-mail: bjoern@giesler.de - -if UI_WII - -fuse_SOURCES += $(ui_wii_files) - -BUILT_SOURCES += $(ui_wii_built) - -endif - - -CLEANFILES += $(ui_wii_built) - -ui_wii_files = \ - ui/wii/keysyms.c \ - ui/wii/wiidisplay.c \ - ui/wii/wiidisplay.h \ - ui/wii/wiijoystick.c \ - ui/wii/wiikeyboard.c \ - ui/wii/wiikeyboard.h \ - ui/wii/wiikeysyms.h \ - ui/wii/wiimouse.c \ - ui/wii/wiimouse.h \ - ui/wii/wiiui.c - -ui_wii_built = ui/wii/keysyms.c - -ui/wii/keysyms.c: $(srcdir)/keysyms.pl $(srcdir)/keysyms.dat - @$(MKDIR_P) ui/wii - $(AM_V_GEN)$(PERL) -I$(srcdir)/perl $(srcdir)/keysyms.pl wii $(srcdir)/keysyms.dat > $@.tmp && mv $@.tmp $@ diff --git a/fuse/ui/wii/wiidisplay.c b/fuse/ui/wii/wiidisplay.c deleted file mode 100644 index 8dbeb59..0000000 --- a/fuse/ui/wii/wiidisplay.c +++ /dev/null @@ -1,537 +0,0 @@ -/* wiidisplay.c: Routines for dealing with the Wii's framebuffer display - Copyright (c) 2008-2009 Bjoern Giesler, Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: bjoern@giesler.de - -*/ - -#include - -#include -#include -#include -#include - -/* Wii includes */ -#include -#include - -#include "fuse.h" -#include "display.h" -#include "screenshot.h" -#include "ui/ui.h" -#include "ui/uidisplay.h" -#include "settings.h" -#include "ui/wii/wiimouse.h" - -/* The size of a 1x1 image in units of - DISPLAY_ASPECT WIDTH x DISPLAY_SCREEN_HEIGHT */ -int image_scale; - -/* The height and width of a 1x1 image in pixels */ -int image_width, image_height; - -/* A copy of every pixel on the screen */ -libspectrum_word display_image[2 * DISPLAY_SCREEN_HEIGHT][DISPLAY_SCREEN_WIDTH]; - -/* An RGB image of the Spectrum screen; slightly bigger than the real - screen to handle the smoothing filters which read around each pixel */ -static unsigned char rgb_image[ 4 * 2 * ( DISPLAY_SCREEN_HEIGHT + 4 ) * - ( DISPLAY_SCREEN_WIDTH + 3 ) ]; -static const int rgb_pitch = ( DISPLAY_SCREEN_WIDTH + 3 ) * 4; - -/* The scaled image */ -static unsigned char scaled_image[ 4 * 3 * DISPLAY_SCREEN_HEIGHT * - (size_t)(1.5 * DISPLAY_SCREEN_WIDTH) ]; -static const ptrdiff_t scaled_pitch = 4 * 1.5 * DISPLAY_SCREEN_WIDTH; - -static u32 *xfb = NULL; -static GXRModeObj *rmode = NULL; - -/* The current size of the window (in units of DISPLAY_SCREEN_*) */ -static int wiidisplay_current_size=2; - -static int init_colours( void ); -static int register_scalers( void ); - -typedef struct { - u8 r, g, b; -} rgb_t; - -rgb_t rgb_colours[16] = { - /* no bright */ - {0, 0, 0}, /* BLACK */ - {0, 0, 192}, /* BLUE */ - {192, 0, 0}, /* RED */ - {192, 0, 192}, /* MAGENTA */ - {0, 192, 0}, /* GREEN */ - {0, 192, 192}, /* CYAN */ - {192, 192, 0}, /* YELLOW */ - {192, 192, 192}, /* WHITE */ - /* bright */ - {0, 0, 0}, /* BLACK */ - {0, 0, 255}, /* BLUE */ - {255, 0, 0}, /* RED */ - {255, 0, 255}, /* MAGENTA */ - {0, 255, 0}, /* GREEN */ - {0, 255, 255}, /* CYAN */ - {255, 255, 0}, /* YELLOW */ - {255, 255, 255}, /* WHITE */ -}; - -static u32 wiidisplay_colours[16]; -static u32 bw_colours[16]; - -#define MOUSESIZEX 9 -#define MOUSESIZEY 9 -#define MOUSEHOTX 4 -#define MOUSEHOTY 4 -static int mousecursor[MOUSESIZEY][MOUSESIZEX] = { - { 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff }, - { 0xff, 0xff, 0xff, 0x0f, 0x00, 0x0f, 0xff, 0xff, 0xff }, - { 0xff, 0xff, 0xff, 0x0f, 0x00, 0x0f, 0xff, 0xff, 0xff }, - { 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f }, - { 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f }, - { 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f }, - { 0xff, 0xff, 0xff, 0x0f, 0x00, 0x0f, 0xff, 0xff, 0xff }, - { 0xff, 0xff, 0xff, 0x0f, 0x00, 0x0f, 0xff, 0xff, 0xff }, - { 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff } -}; -static int mousecache[MOUSESIZEY][MOUSESIZEX]; -static int mousex = 0, mousey = 0; - -u32 convert_rgb (rgb_t rgb1, rgb_t rgb2) -{ - int y1, cb1, cr1, y2, cb2, cr2, cb, cr; - - y1 = (299 * rgb1.r + 587 * rgb1.g + 114 * rgb1.b) / 1000; - cb1 = (-16874 * rgb1.r - 33126 * rgb1.g + 50000 * rgb1.b + 12800000) / 100000; - cr1 = (50000 * rgb1.r - 41869 * rgb1.g - 8131 * rgb1.b + 12800000) / 100000; - - y2 = (299 * rgb2.r + 587 * rgb2.g + 114 * rgb2.b) / 1000; - cb2 = (-16874 * rgb2.r - 33126 * rgb2.g + 50000 * rgb2.b + 12800000) / 100000; - cr2 = (50000 * rgb2.r - 41869 * rgb2.g - 8131 * rgb2.b + 12800000) / 100000; - - cb = (cb1 + cb2) >> 1; - cr = (cr1 + cr2) >> 1; - - return (y1 << 24) | (cb << 16) | (y2 << 8) | cr; -} - -static void put_pixel(int x, int y, int colour, int mouseputpixel) -{ - if( machine_current->timex ) { - x <<= 1; y <<= 1; - display_image[y ][x ] = colour; - display_image[y ][x+1] = colour; - display_image[y+1][x ] = colour; - display_image[y+1][x+1] = colour; - } else { - display_image[y][x] = colour; - if(!mouseputpixel && - x >= mousex && x < mousex+MOUSESIZEX && - y >= mousey && y < mousey+MOUSESIZEY) - mousecache[y-mousey][x-mousex] = colour; - } -} - -static int get_pixel(int x, int y) -{ - return display_image[y][x]; -} - -static int -init_colours( void ) -{ - size_t i; - - for( i = 0; i < 16; i++ ) { - - rgb_t colour, grey; - - colour = rgb_colours[i]; - - /* Addition of 0.5 is to avoid rounding errors */ - grey.r = grey.g = grey.b = - ( 0.299 * colour.r + 0.587 * colour.g + 0.114 * colour.b ) + 0.5; - -#ifdef WORDS_BIGENDIAN - - wiidisplay_colours[i] = colour.r << 24 | colour.g << 16 | colour.b << 8; - bw_colours[i] = grey.r << 24 | grey.g << 16 | grey.b << 8; - -#else /* #ifdef WORDS_BIGENDIAN */ - - wiidisplay_colours[i] = colour.r | colour.g << 8 | colour.b << 16; - bw_colours[i] = grey.r | grey.g << 8 | grey.b << 16; - -#endif /* #ifdef WORDS_BIGENDIAN */ - - } - - return 0; -} - -int uidisplay_init(int width, int height) -{ - int error; - - image_width = width; image_height = height; - image_scale = width / DISPLAY_ASPECT_WIDTH; - - error = register_scalers(); if( error ) return error; - - display_ui_initialised = 1; - display_refresh_all(); - - return 0; -} - -static int -register_scalers( void ) -{ - scaler_register_clear(); - - switch( wiidisplay_current_size ) { - - case 1: - - switch( image_scale ) { - case 1: - scaler_register( SCALER_NORMAL ); - scaler_register( SCALER_PALTV ); - if( !scaler_is_supported( current_scaler ) ) - scaler_select_scaler( SCALER_NORMAL ); - return 0; - case 2: - scaler_register( SCALER_HALF ); - scaler_register( SCALER_HALFSKIP ); - if( !scaler_is_supported( current_scaler ) ) - scaler_select_scaler( SCALER_HALF ); - return 0; - } - - case 2: - - switch( image_scale ) { - case 1: - scaler_register( SCALER_DOUBLESIZE ); - scaler_register( SCALER_TV2X ); - scaler_register( SCALER_ADVMAME2X ); - scaler_register( SCALER_2XSAI ); - scaler_register( SCALER_SUPER2XSAI ); - scaler_register( SCALER_SUPEREAGLE ); - scaler_register( SCALER_DOTMATRIX ); - scaler_register( SCALER_PALTV2X ); - scaler_register( SCALER_HQ2X ); - if( !scaler_is_supported( current_scaler ) ) - scaler_select_scaler( SCALER_DOUBLESIZE ); - return 0; - case 2: - scaler_register( SCALER_NORMAL ); - scaler_register( SCALER_TIMEXTV ); - scaler_register( SCALER_PALTV ); - if( !scaler_is_supported( current_scaler ) ) - scaler_select_scaler( SCALER_NORMAL ); - return 0; - } - - case 3: - - switch( image_scale ) { - case 1: - scaler_register( SCALER_TRIPLESIZE ); - scaler_register( SCALER_TV3X ); - scaler_register( SCALER_ADVMAME3X ); - scaler_register( SCALER_PALTV3X ); - scaler_register( SCALER_HQ3X ); - if( !scaler_is_supported( current_scaler ) ) - scaler_select_scaler( SCALER_TRIPLESIZE ); - return 0; - case 2: - scaler_register( SCALER_TIMEX1_5X ); - if( !scaler_is_supported( current_scaler ) ) - scaler_select_scaler( SCALER_TIMEX1_5X ); - return 0; - } - - } - - ui_error( UI_ERROR_ERROR, "Unknown display size/image size %d/%d", - wiidisplay_current_size, image_scale ); - return 1; -} - -int wiidisplay_init(void) -{ - int error; - - error = init_colours(); if( error ) return error; - - VIDEO_Init(); - - u32 videoMode = VIDEO_GetCurrentTvMode(); - switch(videoMode) { - case VI_NTSC: - rmode = &TVNtsc480IntDf; - break; - case VI_PAL: - rmode = &TVPal528IntDf; - break; - case VI_MPAL: - rmode = &TVMpal480IntDf; - break; - default: - rmode = &TVNtsc480IntDf; - break; - } - - xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); - console_init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight, - rmode->fbWidth*VI_DISPLAY_PIX_SZ); - - VIDEO_Configure(rmode); - VIDEO_SetNextFramebuffer(xfb); - VIDEO_SetBlack(FALSE); - VIDEO_Flush(); - - VIDEO_WaitVSync(); - if(rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); - - return 0; -} - -int -uidisplay_hotswap_gfx_mode( void ) -{ - return 0; -} - -void -uidisplay_frame_end( void ) -{ - VIDEO_WaitVSync(); - if(rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); - - return; -} - -void wiidisplay_showmouse( float x, float y ) -{ - int c, r; - - if( !fuse_emulation_paused ) return; - - int mousenewx = x*(DISPLAY_SCREEN_WIDTH/2-MOUSESIZEX); - int mousenewy = y*(DISPLAY_SCREEN_HEIGHT-MOUSESIZEY); - - /* if we had no old mouse and have no new mouse, forget it */ - if( (mousex <= 0 || mousey <= 0) && - (mousenewx <= 0 || mousenewy <= 0) ) return; - - /* if we had a mouse pos before, put mousecache at old position into - picture */ - if( mousex > 0 && mousey > 0 ) { - for( r=0; rfbWidth / 2; - /* ystart is an offset to center spectrum screen on wii screen */ - int ystart = ( rmode->xfbHeight - 2 * DISPLAY_SCREEN_HEIGHT ) / 4; - u32 *dest, *next_line; - - if( scaled_x%2 ) { - scaled_x -= 1; - w += 1; - } - -/* FIXME: optimize this procedure and implement double buffering */ - next_line = xfb + scaled_x / 2 + ( scaled_y + ystart ) * fb_pitch; - - for( disp_y = scaled_y; disp_y < scaled_y + h; disp_y++ ) { - - dest = next_line; - - for( disp_x = scaled_x; disp_x < scaled_x + w; disp_x++ ) { - ofs = ( 4 * disp_x ) + ( scaled_pitch * disp_y ); - - rgb_t rgb1, rgb2; - - rgb1.b = scaled_image[ ofs + 2 ]; /* blue */ - rgb1.g = scaled_image[ ofs + 1 ]; /* green */ - rgb1.r = scaled_image[ ofs + 0 ]; /* red */ - - rgb2.b = scaled_image[ ofs + 2 + 4 ]; /* blue */ - rgb2.g = scaled_image[ ofs + 1 + 4 ]; /* green */ - rgb2.r = scaled_image[ ofs + 0 + 4 ]; /* red */ - - *dest = convert_rgb( rgb1, rgb2 ); - - dest += disp_x%2; - } - next_line += fb_pitch; - } -} - -int -uidisplay_end( void ) -{ - display_ui_initialised = 0; - return 0; -} - -int -wiidisplay_end( void ) -{ - return 0; -} - -/* Set one pixel in the display */ -void -uidisplay_putpixel( int x, int y, int colour ) -{ - put_pixel(x, y, colour, 0); -} - -/* Print the 8 pixels in `data' using ink colour `ink' and paper - colour `paper' to the screen at ( (8*x) , y ) */ -void -uidisplay_plot8( int x, int y, libspectrum_byte data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - x <<= 3; - - if( machine_current->timex ) { - int i; - - x <<= 1; y <<= 1; - for( i=0; i<2; i++,y++ ) { - display_image[y][x+ 0] = ( data & 0x80 ) ? ink : paper; - display_image[y][x+ 1] = ( data & 0x80 ) ? ink : paper; - display_image[y][x+ 2] = ( data & 0x40 ) ? ink : paper; - display_image[y][x+ 3] = ( data & 0x40 ) ? ink : paper; - display_image[y][x+ 4] = ( data & 0x20 ) ? ink : paper; - display_image[y][x+ 5] = ( data & 0x20 ) ? ink : paper; - display_image[y][x+ 6] = ( data & 0x10 ) ? ink : paper; - display_image[y][x+ 7] = ( data & 0x10 ) ? ink : paper; - display_image[y][x+ 8] = ( data & 0x08 ) ? ink : paper; - display_image[y][x+ 9] = ( data & 0x08 ) ? ink : paper; - display_image[y][x+10] = ( data & 0x04 ) ? ink : paper; - display_image[y][x+11] = ( data & 0x04 ) ? ink : paper; - display_image[y][x+12] = ( data & 0x02 ) ? ink : paper; - display_image[y][x+13] = ( data & 0x02 ) ? ink : paper; - display_image[y][x+14] = ( data & 0x01 ) ? ink : paper; - display_image[y][x+15] = ( data & 0x01 ) ? ink : paper; - } - } else { - display_image[y][x+ 0] = ( data & 0x80 ) ? ink : paper; - display_image[y][x+ 1] = ( data & 0x40 ) ? ink : paper; - display_image[y][x+ 2] = ( data & 0x20 ) ? ink : paper; - display_image[y][x+ 3] = ( data & 0x10 ) ? ink : paper; - display_image[y][x+ 4] = ( data & 0x08 ) ? ink : paper; - display_image[y][x+ 5] = ( data & 0x04 ) ? ink : paper; - display_image[y][x+ 6] = ( data & 0x02 ) ? ink : paper; - display_image[y][x+ 7] = ( data & 0x01 ) ? ink : paper; - } -} - -/* Print the 16 pixels in `data' using ink colour `ink' and paper - colour `paper' to the screen at ( (16*x) , y ) */ -void -uidisplay_plot16( int x, int y, libspectrum_word data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - /* FIXME: what should this do? */ - return; -} - -void -uidisplay_frame_save( void ) -{ - /* FIXME: implement */ -} - -void -uidisplay_frame_restore( void ) -{ - /* FIXME: implement */ -} diff --git a/fuse/ui/wii/wiidisplay.h b/fuse/ui/wii/wiidisplay.h deleted file mode 100644 index d279b4b..0000000 --- a/fuse/ui/wii/wiidisplay.h +++ /dev/null @@ -1,32 +0,0 @@ -/* wiidisplay.h: Routines for dealing with the wii's framebuffer display - Copyright (c) 2008 Bjoern Giesler - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: bjoern@giesler.de - -*/ - -#ifndef FUSE_WIIDISPLAY_H -#define FUSE_WIIDISPLAY_H - -int wiidisplay_init( void ); -int wiidisplay_end( void ); - -void wiidisplay_showmouse( float mousex, float mousey ); - -#endif /* #ifndef FUSE_WIIDISPLAY_H */ diff --git a/fuse/ui/wii/wiijoystick.c b/fuse/ui/wii/wiijoystick.c deleted file mode 100644 index ee57603..0000000 --- a/fuse/ui/wii/wiijoystick.c +++ /dev/null @@ -1,197 +0,0 @@ -/* wiijoystick.c: routines for dealing with the Wiimote as a joystick - Copyright (c) 2008-2009 Bjoern Giesler, Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: bjoern@giesler.de - -*/ - -#include -#include "fuse.h" -#include "input.h" -#include "ui/ui.h" -#include "ui/uijoystick.h" - -#define GEKKO -#include - -typedef enum { - WII_JOYSTICK_SIDEWAYS_RH, /* sideways config (fire on the right) */ - WII_JOYSTICK_SIDEWAYS_LH, /* sideways config (fire on the left) */ - WII_JOYSTICK_NUNCHUK, /* nunchuk for directions, A+B for fire */ - WII_JOYSTICK_CLASSIC, /* classic controller */ -} WiiJoystickConfig; - -int -ui_joystick_init( void ) -{ - return 4; -} - -void -ui_joystick_end( void ) -{ -} - -void -ui_joystick_poll( void ) -{ - input_event_t fuse_event; - int ctrlr; /* Which controller */ - u32 wm_down; /* Wii Remote buttons that are down */ - u32 wm_up; /* Wii Remote buttons that are up */ - ubyte nunchuck_down; /* Nunchuck buttons that are down */ - ubyte nunchuck_up; /* Nunchuck buttons that are up */ - WPADData *wpad; - joystick_t js; - - if( fuse_emulation_paused ) return; - -#define POST_JOYPRESS(number, pressed) do { \ - fuse_event.type = INPUT_EVENT_JOYSTICK_PRESS; \ - fuse_event.types.joystick.which = number; \ - fuse_event.types.joystick.button = pressed; \ - input_event(&fuse_event); \ - } while(0) - -#define POST_JOYRELEASE(number, pressed) do { \ - fuse_event.type = INPUT_EVENT_JOYSTICK_RELEASE; \ - fuse_event.types.joystick.which = number; \ - fuse_event.types.joystick.button = pressed; \ - input_event(&fuse_event); \ - } while(0) - - for( ctrlr = 0; ctrlr < 2; ctrlr++ ) { - - wpad = WPAD_Data( ctrlr ); - if( !wpad ) continue; - - wm_down = wpad->btns_d; - wm_up = wpad->btns_u; - - nunchuck_down = 0; - nunchuck_up = 0; - if( wpad->exp.type == EXP_NUNCHUK ) { - nunchuck_down = wpad->exp.nunchuk.btns; - nunchuck_up = wpad->exp.nunchuk.btns_released; - } - - if( wm_down & WPAD_BUTTON_LEFT ) - POST_JOYPRESS( ctrlr, INPUT_JOYSTICK_DOWN ); - if( wm_down & WPAD_BUTTON_RIGHT ) - POST_JOYPRESS( ctrlr, INPUT_JOYSTICK_UP ); - if( wm_down & WPAD_BUTTON_UP ) - POST_JOYPRESS( ctrlr, INPUT_JOYSTICK_LEFT ); - if( wm_down & WPAD_BUTTON_DOWN ) - POST_JOYPRESS( ctrlr, INPUT_JOYSTICK_RIGHT ); - - if( wm_down & WPAD_BUTTON_1 ) - POST_JOYPRESS( ctrlr, INPUT_JOYSTICK_FIRE_1 ); - if( wm_down & WPAD_BUTTON_2 ) - POST_JOYPRESS( ctrlr, INPUT_JOYSTICK_FIRE_2 ); - - if( wm_down & WPAD_BUTTON_A ) - POST_JOYPRESS( ctrlr, INPUT_JOYSTICK_FIRE_3 ); - if( wm_down & WPAD_BUTTON_B ) - POST_JOYPRESS( ctrlr, INPUT_JOYSTICK_FIRE_4 ); - if( wm_down & WPAD_BUTTON_PLUS ) - POST_JOYPRESS( ctrlr, INPUT_JOYSTICK_FIRE_5 ); - if( wm_down & WPAD_BUTTON_MINUS ) - POST_JOYPRESS( ctrlr, INPUT_JOYSTICK_FIRE_6 ); - if( nunchuck_down & WPAD_NUNCHUK_BUTTON_Z ) - POST_JOYPRESS( ctrlr, INPUT_JOYSTICK_FIRE_7 ); - if( nunchuck_down & WPAD_NUNCHUK_BUTTON_C ) - POST_JOYPRESS( ctrlr, INPUT_JOYSTICK_FIRE_8 ); - - if( wm_up & WPAD_BUTTON_LEFT ) - POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_DOWN ); - if( wm_up & WPAD_BUTTON_RIGHT ) - POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_UP ); - if( wm_up & WPAD_BUTTON_UP ) - POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_LEFT ); - if( wm_up & WPAD_BUTTON_DOWN ) - POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_RIGHT ); - - if( wm_up & WPAD_BUTTON_1 ) - POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_FIRE_1 ); - if( wm_up & WPAD_BUTTON_2 ) - POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_FIRE_2 ); - - if( wm_up & WPAD_BUTTON_A ) - POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_FIRE_3 ); - if( wm_up & WPAD_BUTTON_B ) - POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_FIRE_4 ); - if( wm_up & WPAD_BUTTON_PLUS ) - POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_FIRE_5 ); - if( wm_up & WPAD_BUTTON_MINUS ) - POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_FIRE_6 ); - if( nunchuck_up & WPAD_NUNCHUK_BUTTON_Z ) - POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_FIRE_7 ); - if( nunchuck_up & WPAD_NUNCHUK_BUTTON_C ) - POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_FIRE_8 ); - - if( wpad->exp.type == EXP_NUNCHUK ) { - - js = wpad->exp.nunchuk.js; - - if( js.mag < 0.5 ) { - /* stick tilted only halfway from the center - release all directions */ - POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_DOWN ); - POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_UP ); - POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_LEFT ); - POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_RIGHT ); - } - else { - int left_held = 0; - int right_held = 0; - int up_held = 0; - int down_held = 0; - - /* left */ - if( js.ang >= 270-60 && js.ang <= 270+60 ) { - POST_JOYPRESS( ctrlr, INPUT_JOYSTICK_LEFT ); - left_held = 1; - } - /* right */ - if( js.ang >= 90-60 && js.ang <= 90+60 ) { - POST_JOYPRESS( ctrlr, INPUT_JOYSTICK_RIGHT ); - right_held = 1; - } - /* up */ - if( js.ang >= 360-60 || js.ang <= 60 ) { - POST_JOYPRESS( ctrlr, INPUT_JOYSTICK_UP ); - up_held = 1; - } - /* down */ - if( js.ang >= 180-60 && js.ang <= 180+60 ) { - POST_JOYPRESS( ctrlr, INPUT_JOYSTICK_DOWN ); - down_held = 1; - } - - /* the below prevents an issue when user makes 180 deg circle with - the nunchuck from for example left to right while mag > 0.5, in - which case spectrum would get both left and right signal from - joystick. The below is to prevent that. */ - if( !down_held ) POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_DOWN ); - if( !up_held ) POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_UP ); - if( !left_held ) POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_LEFT ); - if( !right_held ) POST_JOYRELEASE( ctrlr, INPUT_JOYSTICK_RIGHT ); - } - } - } -} diff --git a/fuse/ui/wii/wiikeyboard.c b/fuse/ui/wii/wiikeyboard.c deleted file mode 100644 index fb69d71..0000000 --- a/fuse/ui/wii/wiikeyboard.c +++ /dev/null @@ -1,215 +0,0 @@ -/* wiikeyboard.c: routines for dealing with the Wii USB keyboard - Copyright (c) 2008 Bjoern Giesler - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: bjoern@giesler.de - -*/ - -#define _POSIX_THREADS - -#include - -#include -#include -#include -#include -#include -#include - -#include "display.h" -#include "fuse.h" -#include "keyboard.h" -#include "machine.h" -#include "settings.h" -#include "snapshot.h" -#include "spectrum.h" -#include "tape.h" -#include "ui/ui.h" - -#include -#include -#include - -typedef struct { - u32 msgtype; - u32 unknown1; - u8 modifiers; - u8 unknown2; - u8 keys[6]; -} wii_kbd_event; - -static s32 kbd = -1; - -static lwp_t kbdthread; -static mutex_t kbdmutex; -#define QUEUELEN 100 -static input_event_t queue[QUEUELEN]; -static int queuepos = 0; -static input_event_t releasequeue[QUEUELEN]; -static int releasequeuepos = 0; - -static int -post_modifier( input_event_t* event, - u8 old, u8 new, u8 modifier, input_key spectrum_key ) -{ - if( (old & modifier) && !(new & modifier) ) { - event->type = INPUT_EVENT_KEYRELEASE; - event->types.key.native_key = modifier; - event->types.key.spectrum_key = spectrum_key; - return 0; - } else if( !(old & modifier) && (new & modifier) ) { - event->type = INPUT_EVENT_KEYPRESS; - event->types.key.native_key = modifier; - event->types.key.spectrum_key = spectrum_key; - return 0; - } - - return 1; -} - -static void* -kbdthread_fn( void *arg ) -{ - wii_kbd_event event, oldevent; - int i, j, found; - - memset( &event, 0, sizeof(event) ); - memset( &oldevent, 0, sizeof(oldevent) ); - - while( kbd != -1 ) { - IOS_Ioctl( kbd, 0, NULL, 0, &event, sizeof(event) ); - - /* skip connect (0) and disconnect (1) events */ - if( event.msgtype != 2 ) continue; - - input_event_t fuse_event; - - LWP_MutexLock( kbdmutex ); - -#define POSTMODIFIER(wiikey, speckey) \ - if(queuepos < QUEUELEN) \ - if(post_modifier(queue + queuepos, \ - oldevent.modifiers, event.modifiers, \ - wiikey, speckey) == 0) \ - queuepos++ - - POSTMODIFIER( 0x01, INPUT_KEY_Control_L ); - POSTMODIFIER( 0x02, INPUT_KEY_Shift_L ); - POSTMODIFIER( 0x04, INPUT_KEY_Alt_L ); - POSTMODIFIER( 0x08, INPUT_KEY_Super_L ); - POSTMODIFIER( 0x10, INPUT_KEY_Control_R ); - POSTMODIFIER( 0x20, INPUT_KEY_Shift_R ); - POSTMODIFIER( 0x40, INPUT_KEY_Alt_R ); - POSTMODIFIER( 0x80, INPUT_KEY_Super_R ); - -#undef POSTMODIFIER - - /* post keyreleases: old keys that have no new keys */ - fuse_event.type = INPUT_EVENT_KEYRELEASE; - for(i=0; i<6; i++) { - if(oldevent.keys[i] == 0) break; - found = 0; - for( j=0; j<6; j++ ) { - if(event.keys[j] == oldevent.keys[i]) { - found = 1; - break; - } - } - if( !found ) { - fuse_event.types.key.spectrum_key = keysyms_remap(oldevent.keys[i]); - fuse_event.types.key.native_key = fuse_event.types.key.spectrum_key; - - if( queuepos >= QUEUELEN ) { - ui_error( UI_ERROR_WARNING, "%s: keyboard queue full", __func__ ); - continue; - } - queue[queuepos++] = fuse_event; - continue; - } - } - - fuse_event.type = INPUT_EVENT_KEYPRESS; - for( i=0; i<6; i++ ) { - if(event.keys[i] == 0) break; - found = 0; - for( j=0; j<6; j++ ) { - if(oldevent.keys[j] == event.keys[i]) { - found = 1; - break; - } - } - if( !found ) { - fuse_event.types.key.spectrum_key = keysyms_remap( event.keys[i] ); - fuse_event.types.key.native_key = fuse_event.types.key.spectrum_key; - - if( queuepos >= QUEUELEN ) { - ui_error( UI_ERROR_WARNING, "%s: keyboard queue full", __func__ ); - continue; - } - queue[queuepos++] = fuse_event; - } - } - - LWP_MutexUnlock( kbdmutex ); - oldevent = event; - } - - return NULL; -} - -int -wiikeyboard_init( void ) -{ - kbd = IOS_Open( "/dev/usb/kbd", IPC_OPEN_RW ); - if( kbd < 0 ) return kbd; - - if( LWP_MutexInit(&kbdmutex, 0) != 0 || - LWP_CreateThread(&kbdthread, kbdthread_fn, NULL, NULL, 0, 80) != 0) { - IOS_Close(kbd); - return 1; - } - - return 0; -} - -int wiikeyboard_end(void) -{ - if( kbd >= 0 ) IOS_Close(kbd); - kbd = -1; - return 0; -} - -void -keyboard_update( void ) -{ - int i; - - for( i=0; i - -#include -#include - -#include -#include -#include -#include -#include - -#define GEKKO - -#include - -#include "fuse.h" -#include "keyboard.h" -#include "ui/ui.h" -#include "ui/wii/wiidisplay.h" - -static WPADData paddata; -static WPADData oldpaddata; - -/* The below is to remember last nunchuck position when navigating the menus. - It is used so the user needs to release nunchuck stick and then press it - again to go to the next menu item (holding the direction will to next menu - item just once, no matter how long the direction is being held). */ -#define LEFT 1 -#define RIGHT 2 -#define UP 3 -#define DOWN 4 -static u8 last_nunchuck[ 2 ]; /* for 2 controllers */ - -int -wiimouse_init( void ) -{ - WPAD_Init(); - WPAD_SetDataFormat( WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR ); - WPAD_SetIdleTimeout( 60 ); - - memset( &paddata, 0, sizeof(paddata) ); - memset( &oldpaddata, 0, sizeof(oldpaddata) ); - ui_mouse_present = 1; - return 0; -} - -int -wiimouse_end( void ) -{ - return 0; -} - -void -wiimouse_get_position( int *x, int *y ) -{ - if( paddata.ir.state == 0 ) *x = *y = -1; - - *x = paddata.ir.x; - *y = paddata.ir.y; -} - -void -mouse_update( void ) -{ - /* do this ONLY here. wiijoystick depends on it as well, but - mouse_update is called regardless of whether the emulation is - running or not, ui_joystick_poll only if running. So we do this - here and risk lagging 1 frame behind on the joystick - FIXME: A function that does this only once depending on the - current frame counter would be better */ - - int ctrlr; /* Which controller */ - u32 wm_down; /* Wii Remote buttons that are down */ - WPADData *wpad; - joystick_t js; - - WPAD_ScanPads(); - -#define POST_KEYPRESS(pressed) do { \ - input_event_t fuse_event; \ - fuse_event.type = INPUT_EVENT_KEYPRESS; \ - fuse_event.types.key.native_key = pressed; \ - fuse_event.types.key.spectrum_key = pressed; \ - input_event(&fuse_event); \ - } while(0) - -#define POST_KEYRELEASE(pressed) do { \ - input_event_t fuse_event; \ - fuse_event.type = INPUT_EVENT_KEYRELEASE; \ - fuse_event.types.key.native_key = pressed; \ - fuse_event.types.key.spectrum_key = pressed; \ - input_event(&fuse_event); \ - } while(0) - - for( ctrlr = 0; ctrlr < 2; ctrlr++ ) { - - wpad = WPAD_Data( ctrlr ); - if( !wpad ) continue; - - wm_down = wpad->btns_d; - - /* we don't bother with key releases here; this is only for entering - and/or using the menu, which seems to at best disregard - keyreleases and at worst react badly to them. */ - - if(fuse_emulation_paused) { - if( wm_down & WPAD_BUTTON_DOWN ) - POST_KEYPRESS( INPUT_JOYSTICK_RIGHT ); - else if( wm_down & WPAD_BUTTON_UP ) - POST_KEYPRESS( INPUT_JOYSTICK_LEFT ); - else if( wm_down & WPAD_BUTTON_LEFT ) - POST_KEYPRESS( INPUT_JOYSTICK_DOWN ); - else if( wm_down & WPAD_BUTTON_RIGHT ) - POST_KEYPRESS( INPUT_JOYSTICK_UP ); - else if( ( wm_down & WPAD_BUTTON_A ) || ( wm_down & WPAD_BUTTON_2 ) ) - POST_KEYPRESS( INPUT_JOYSTICK_FIRE_1 ); - else if( ( wm_down & WPAD_BUTTON_B ) || ( wm_down & WPAD_BUTTON_1 ) - || ( wm_down & WPAD_BUTTON_HOME ) ) - POST_KEYPRESS( INPUT_JOYSTICK_FIRE_2 ); - - if( wpad->exp.type == EXP_NUNCHUK ) { - - js = wpad->exp.nunchuk.js; - - if( js.mag >= 0.5 ) { - /* left */ - if( js.ang >= 270-45 && js.ang <= 270+45 ) { - if( last_nunchuck[ ctrlr ] != LEFT ) { - POST_KEYPRESS( INPUT_JOYSTICK_LEFT ); - last_nunchuck[ ctrlr ] = LEFT; - } - } - /* right */ - else if( js.ang >= 90-45 && js.ang <= 90+45 ) { - if( last_nunchuck[ ctrlr ] != RIGHT ) { - POST_KEYPRESS( INPUT_JOYSTICK_RIGHT ); - last_nunchuck[ ctrlr ] = RIGHT; - } - } - /* up */ - else if( js.ang >= 360-45 || js.ang <= 45 ) { - if( last_nunchuck[ ctrlr ] != UP ) { - POST_KEYPRESS( INPUT_JOYSTICK_UP ); - last_nunchuck[ ctrlr ] = UP; - } - } - /* down */ - else if( js.ang >= 180-45 && js.ang <= 180+45 ) { - if( last_nunchuck[ ctrlr ] != DOWN ) { - POST_KEYPRESS( INPUT_JOYSTICK_DOWN ); - last_nunchuck[ ctrlr ] = DOWN; - } - } - } - else - last_nunchuck[ ctrlr ] = 0; - } - } else { - if( wm_down & WPAD_BUTTON_HOME ) - POST_KEYPRESS( INPUT_KEY_F1 ); - } - } - - WPAD_ReadEvent( 0, &paddata ); - - if( paddata.ir.state == 0 ) - wiidisplay_showmouse( -1, -1 ); - else - wiidisplay_showmouse( paddata.ir.x/560.0f, paddata.ir.y/420.0f ); -} - -int -ui_mouse_grab( int startup GCC_UNUSED ) -{ - return 1; -} - -int -ui_mouse_release( int suspend ) -{ - return !suspend; -} diff --git a/fuse/ui/wii/wiimouse.h b/fuse/ui/wii/wiimouse.h deleted file mode 100644 index 54a198b..0000000 --- a/fuse/ui/wii/wiimouse.h +++ /dev/null @@ -1,33 +0,0 @@ -/* wiimouse.h: routines for dealing with the Wiimote as a mouse - Copyright (c) 2008 Bjoern Giesler - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: bjoern@giesler.de - -*/ - -#ifndef FUSE_WIIMOUSE_H -#define FUSE_WIIMOUSE_H - -int wiimouse_init( void ); -int wiimouse_end( void ); -void wiimouse_get_position( int *x, int *y ); - -void mouse_update( void ); - -#endif /* FUSE_WIIMOUSE_H */ diff --git a/fuse/ui/wii/wiiui.c b/fuse/ui/wii/wiiui.c deleted file mode 100644 index 4aeac8e..0000000 --- a/fuse/ui/wii/wiiui.c +++ /dev/null @@ -1,92 +0,0 @@ -/* wiiui.h: routines for dealing with the Wii FB UI - Copyright (c) 2008 Bjoern Giesler - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: bjoern@giesler.de - -*/ - -#include - -#include -#include -#include -#include - -#include "wiidisplay.h" -#include "wiikeyboard.h" -#include "wiimouse.h" -#include "ui/ui.h" -#include "ui/uidisplay.h" - -static void wii_end( void ); - -int -ui_init( int *argc, char ***argv ) -{ - int error; - -#ifdef USE_WIDGET - if( ui_widget_init() ) return 1; -#endif /* #ifdef USE_WIDGET */ - - error = atexit( wii_end ); - if( error ) { - ui_error( UI_ERROR_ERROR, "%s: couldn't set atexit function", __func__ ); - return 1; - } - - error = wiidisplay_init(); - if( error ) return error; - error = wiikeyboard_init(); - if( error ) return error; - error = wiimouse_init(); - if( error ) return error; - - return 0; -} - -int -ui_event( void ) -{ - keyboard_update(); - mouse_update(); - return 0; -} - -int ui_end(void) -{ - /* Cleanup handled by atexit function */ - int error; - - error = wiikeyboard_end(); if( error ) return error; - error = wiidisplay_end(); if( error ) return error; - -#ifdef USE_WIDGET - ui_widget_end(); -#endif /* #ifdef USE_WIDGET */ - - return 0; -} - -static void -wii_end( void ) -{ - wiikeyboard_end(); - uidisplay_end(); -} diff --git a/fuse/ui/win32/Makefile.am b/fuse/ui/win32/Makefile.am deleted file mode 100644 index b701790..0000000 --- a/fuse/ui/win32/Makefile.am +++ /dev/null @@ -1,144 +0,0 @@ -## Process this file with automake to produce Makefile.in -## Copyright (c) 2001-2008 Philip Kendall -## Copyright (c) 2015 Sergio Baldoví - -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -## -## Author contact information: -## -## E-mail: philip-fuse@shadowmagic.org.uk - -if UI_WIN32 - -fuse_SOURCES += $(ui_win32_files) - -BUILT_SOURCES += $(ui_win32_built) - -ui_win32_res = $(ui_win32_rc_files) - -endif - - -CLEANFILES += $(ui_win32_built) - -ui_win32_files = \ - ui/win32/about.c \ - ui/win32/about.h \ - ui/win32/binary.c \ - ui/win32/binary.h \ - ui/win32/browse.c \ - ui/win32/browse.h \ - ui/win32/confirm.c \ - ui/win32/debugger.c \ - ui/win32/debugger.h \ - ui/win32/fileselector.c \ - ui/win32/hyperlinks.c \ - ui/win32/hyperlinks.h \ - ui/win32/keysyms.c \ - ui/win32/memorybrowser.c \ - ui/win32/memorybrowser.h \ - ui/win32/menu_data.c \ - ui/win32/options.c \ - ui/win32/picture.c \ - ui/win32/picture.h \ - ui/win32/pokefinder.c \ - ui/win32/pokefinder.h \ - ui/win32/pokemem.c \ - ui/win32/pokemem.h \ - ui/win32/rollback.c \ - ui/win32/rollback.h \ - ui/win32/roms.c \ - ui/win32/roms.h \ - ui/win32/select_template.h \ - ui/win32/statusbar.c \ - ui/win32/win32display.c \ - ui/win32/win32internals.h \ - ui/win32/win32joystick.c \ - ui/win32/win32joystick.h \ - ui/win32/win32keyboard.c \ - ui/win32/win32mouse.c \ - ui/win32/win32ui.c - -ui_win32_rc_files = \ - ui/win32/about.rc \ - ui/win32/binary.rc \ - ui/win32/browse.rc \ - ui/win32/debugger.rc \ - ui/win32/memorybrowser.rc \ - ui/win32/menu_data.rc \ - ui/win32/options.rc \ - ui/win32/picture.rc \ - ui/win32/pokefinder.rc \ - ui/win32/pokemem.rc \ - ui/win32/rollback.rc \ - ui/win32/roms.rc \ - ui/win32/select_template.rc \ - ui/win32/statusbar.rc \ - ui/win32/win32joystick.rc - -ui_win32_built = \ - ui/win32/keysyms.c \ - ui/win32/menu_data.c \ - ui/win32/menu_data.h \ - ui/win32/menu_data.rc \ - ui/win32/options_internals.h \ - ui/win32/options.c \ - ui/win32/options.rc - -EXTRA_DIST += \ - ui/win32/icons/disk_active.bmp \ - ui/win32/icons/disk_inactive.bmp \ - ui/win32/icons/mdr_active.bmp \ - ui/win32/icons/mdr_inactive.bmp \ - ui/win32/icons/mouse_active.bmp \ - ui/win32/icons/mouse_inactive.bmp \ - ui/win32/icons/pause_active.bmp \ - ui/win32/icons/pause_inactive.bmp \ - ui/win32/icons/tape_active.bmp \ - ui/win32/icons/tape_inactive.bmp \ - ui/win32/icons/tape_marker.bmp \ - ui/win32/icons/tape_marker_mask.bmp \ - ui/win32/options.pl \ - ui/win32/options-header.pl \ - ui/win32/options-resource.pl \ - $(ui_win32_rc_files) - -ui/win32/keysyms.c: $(srcdir)/keysyms.pl $(srcdir)/keysyms.dat - @$(MKDIR_P) ui/win32 - $(AM_V_GEN)$(PERL) -I$(srcdir)/perl $(srcdir)/keysyms.pl win32 $(srcdir)/keysyms.dat > $@.tmp && mv $@.tmp $@ - -ui/win32/menu_data.c: $(srcdir)/perl/cpp-perl.pl $(srcdir)/menu_data.pl $(srcdir)/menu_data.dat config.h - @$(MKDIR_P) ui/win32 - $(AM_V_GEN)$(PERL) $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/menu_data.dat | $(PERL) -I$(srcdir)/perl $(srcdir)/menu_data.pl win32 c > $@.tmp && mv $@.tmp $@ - -ui/win32/menu_data.h: $(srcdir)/perl/cpp-perl.pl $(srcdir)/menu_data.pl $(srcdir)/menu_data.dat config.h - @$(MKDIR_P) ui/win32 - $(AM_V_GEN)$(PERL) $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/menu_data.dat | $(PERL) -I$(srcdir)/perl $(srcdir)/menu_data.pl win32 h > $@.tmp && mv $@.tmp $@ - -ui/win32/menu_data.rc: $(srcdir)/perl/cpp-perl.pl $(srcdir)/menu_data.pl $(srcdir)/menu_data.dat config.h - @$(MKDIR_P) ui/win32 - $(AM_V_GEN)$(PERL) $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/menu_data.dat | $(PERL) -I$(srcdir)/perl $(srcdir)/menu_data.pl win32 rc > $@.tmp && mv $@.tmp $@ - -ui/win32/options.c: $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/ui/win32/options.pl $(srcdir)/ui/options.dat $(srcdir)/perl/Fuse.pm $(srcdir)/perl/Fuse/Dialog.pm - @$(MKDIR_P) ui/win32 - $(AM_V_GEN)$(PERL) $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/ui/options.dat | $(PERL) -I$(srcdir)/perl $(srcdir)/ui/win32/options.pl - > $@.tmp && mv $@.tmp $@ - -ui/win32/options_internals.h: $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/ui/win32/options-header.pl $(srcdir)/ui/options.dat $(srcdir)/perl/Fuse.pm $(srcdir)/perl/Fuse/Dialog.pm - @$(MKDIR_P) ui/win32 - $(AM_V_GEN)$(PERL) $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/ui/options.dat | $(PERL) -I$(srcdir)/perl $(srcdir)/ui/win32/options-header.pl - > $@.tmp && mv $@.tmp $@ - -ui/win32/options.rc: $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/ui/win32/options-resource.pl $(srcdir)/ui/options.dat $(srcdir)/perl/Fuse.pm $(srcdir)/perl/Fuse/Dialog.pm - @$(MKDIR_P) ui/win32 - $(AM_V_GEN)$(PERL) $(srcdir)/perl/cpp-perl.pl config.h $(srcdir)/ui/options.dat | $(PERL) -I$(srcdir)/perl $(srcdir)/ui/win32/options-resource.pl - > $@.tmp && mv $@.tmp $@ diff --git a/fuse/ui/win32/about.c b/fuse/ui/win32/about.c deleted file mode 100644 index cfbf817..0000000 --- a/fuse/ui/win32/about.c +++ /dev/null @@ -1,113 +0,0 @@ -/* about.c: about dialog box - Copyright (c) 2011 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include "fuse.h" -#include "hyperlinks.h" -#include "win32internals.h" - -#include "about.h" - - -static INT_PTR CALLBACK dialog_proc( HWND hwndDlg, UINT uMsg, - WPARAM wParam, LPARAM lParam ); - -/* About window handle */ -HWND fuse_hABOWnd; - -static HFONT hBoldFont; - -void -menu_help_about( int action ) -{ - /* Firstly, stop emulation */ - fuse_emulation_pause(); - - if( !IsWindow( fuse_hABOWnd ) ) { - fuse_hABOWnd = CreateDialog( fuse_hInstance, - MAKEINTRESOURCE( IDD_ABOUT ), - fuse_hWnd, dialog_proc ); - if( fuse_hABOWnd == NULL ) { fuse_emulation_unpause(); return; } - } - - ShowWindow( fuse_hABOWnd, SW_SHOW ); - - /* Carry on with emulation */ - fuse_emulation_unpause(); -} - -static void -dialog_init( HWND hwndDlg ) -{ - HDC hdc; - long lfHeight; - - hdc = GetDC( NULL ); - lfHeight = -MulDiv( 16, GetDeviceCaps( hdc, LOGPIXELSY ), 72 ); - ReleaseDC( NULL, hdc ); - - hBoldFont = CreateFont( lfHeight, 0, 0, 0, FW_BOLD, 0, 0, 0, 0, 0, - 0, 0, 0, "Arial" ); - - if( hBoldFont ) { - win32ui_set_font( hwndDlg, IDC_ABOUT_STATIC_VERSION, hBoldFont ); - } - - ConvertCtlStaticToHyperlink( hwndDlg, IDC_ABOUT_STATIC_WEBSITE ); -} - -static INT_PTR CALLBACK -dialog_proc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) -{ - switch( uMsg ) { - case WM_INITDIALOG: - dialog_init( hwndDlg ); - return TRUE; - - case WM_COMMAND: - switch( LOWORD( wParam ) ) { - case IDCLOSE: - case IDCANCEL: - DestroyWindow( hwndDlg ); - fuse_hABOWnd = NULL; - if( hBoldFont ) DeleteObject( hBoldFont ); - return TRUE; - case IDC_ABOUT_STATIC_WEBSITE: - ShellExecute( hwndDlg, "open", PACKAGE_URL, - NULL, NULL, SW_SHOWNORMAL ); - return TRUE; - } - break; - - case WM_CLOSE: - DestroyWindow( hwndDlg ); - fuse_hABOWnd = NULL; - return TRUE; - } - - return FALSE; -} diff --git a/fuse/ui/win32/about.h b/fuse/ui/win32/about.h deleted file mode 100644 index 821f0de..0000000 --- a/fuse/ui/win32/about.h +++ /dev/null @@ -1,28 +0,0 @@ -/* about.h: about dialog box - Copyright (c) 2011 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#define IDD_ABOUT 1800 -#define IDC_ABOUT_STATIC_VERSION 1801 -#define IDC_ABOUT_STATIC_NAME 1802 -#define IDC_ABOUT_STATIC_COPYRIGHT 1802 -#define IDC_ABOUT_STATIC_WEBSITE 1804 diff --git a/fuse/ui/win32/about.rc b/fuse/ui/win32/about.rc deleted file mode 100644 index 6d5a926..0000000 --- a/fuse/ui/win32/about.rc +++ /dev/null @@ -1,37 +0,0 @@ -/* about.rc: about dialog box - Copyright (c) 2011 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include "about.h" - -IDD_ABOUT DIALOGEX 0, 0, 186, 95 -STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "About fuse" -FONT 8,"Ms Shell Dlg 2",400,0,1 -{ - CTEXT "Fuse " VERSION, IDC_ABOUT_STATIC_VERSION, 12, 5, 155, 16, SS_CENTER - CTEXT "The Free Unix Spectrum Emulator", IDC_ABOUT_STATIC_NAME, 12, 24, 155, 8, SS_CENTER - CTEXT FUSE_COPYRIGHT, IDC_ABOUT_STATIC_COPYRIGHT, 12, 40, 155, 8, SS_CENTER - CTEXT PACKAGE_URL, IDC_ABOUT_STATIC_WEBSITE, 12, 56, 155, 8, SS_CENTER|SS_NOTIFY - DEFPUSHBUTTON "Close", IDCLOSE, 68, 77, 50, 14 -} diff --git a/fuse/ui/win32/binary.c b/fuse/ui/win32/binary.c deleted file mode 100644 index 1b4296a..0000000 --- a/fuse/ui/win32/binary.c +++ /dev/null @@ -1,348 +0,0 @@ -/* binary.c: Win32 routines to load/save chunks of binary data - Copyright (c) 2003-2008 Philip Kendall, Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include - -#include "fuse.h" -#include "ui/ui.h" -#include "utils.h" -#include "win32internals.h" - -#include "binary.h" - -struct binary_info { - - TCHAR *filename; - utils_file file; - - TCHAR *dialog_title; - - void (*on_change_filename)( HWND hwndDlg, LONG_PTR user_data ); - void (*on_execute)( HWND hwndDlg, LONG_PTR user_data ); -}; - -static void change_load_filename( HWND hwndDlg, LONG_PTR user_data ); -static void load_data( HWND hwndDlg, LONG_PTR user_data ); - -static void change_save_filename( HWND hwndDlg, LONG_PTR user_data ); -static void save_data( HWND hwndDlg, LONG_PTR user_data ); - -static INT_PTR CALLBACK -binarydata_proc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ); - -void -menu_file_loadbinarydata( int action ) -{ - /* FIXME: a way to associate a long type with a window is via SetWindowLong - with GWL_USERDATA parameter - review past code and implement */ - - struct binary_info info; - - int error; - - fuse_emulation_pause(); - - info.dialog_title = (TCHAR *) TEXT( "Fuse - Load Binary Data" ); - - info.filename = ui_get_open_filename( info.dialog_title ); - if( !info.filename ) { fuse_emulation_unpause(); return; } - - error = utils_read_file( info.filename, &info.file ); - if( error ) { free( info.filename ); fuse_emulation_unpause(); return; } - - info.on_change_filename = &change_load_filename; - info.on_execute = &load_data; - - /* Information display */ - DialogBoxParam( fuse_hInstance, MAKEINTRESOURCE( IDD_BINARY ), fuse_hWnd, - binarydata_proc, ( LPARAM ) &info ); - - free( info.filename ); - utils_close_file( &info.file ); - - fuse_emulation_unpause(); -} - -static INT_PTR CALLBACK -binarydata_proc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) -{ - struct binary_info *info = NULL; - - switch( uMsg ) { - case WM_INITDIALOG: { - TCHAR buffer[80]; - info = ( struct binary_info * ) lParam; - - /* save the pointer to info with this dialog window */ - SetWindowLongPtr( hwndDlg, GWLP_USERDATA, ( LONG_PTR ) info ); - - SendMessage( hwndDlg, WM_SETTEXT, 0, ( LPARAM ) info->dialog_title ); - - SendDlgItemMessage( hwndDlg, IDC_BINARY_STATIC_PATH, WM_SETTEXT, - 0, ( LPARAM ) info->filename ); - - if( info->file.length != -1 ) { - _sntprintf( buffer, 80, "%lu", (unsigned long) info->file.length ); - SendDlgItemMessage( hwndDlg, IDC_BINARY_EDIT_LENGTH, WM_SETTEXT, - 0, ( LPARAM ) buffer ); - } - return FALSE; - } - case WM_COMMAND: - switch( LOWORD( wParam ) ) { - case IDC_BINARY_BUTTON_BROWSE: - info = ( struct binary_info * ) GetWindowLongPtr( hwndDlg, GWLP_USERDATA ); - info->on_change_filename( hwndDlg, ( LONG_PTR ) info ) ; - return 0; - - case IDOK: - info = ( struct binary_info * ) GetWindowLongPtr( hwndDlg, GWLP_USERDATA ); - info->on_execute( hwndDlg, ( LONG_PTR ) info ) ; - return 0; - - case IDCANCEL: - EndDialog( hwndDlg, 0 ); - return 0; - } - break; - - case WM_CLOSE: - EndDialog( hwndDlg, 0 ); - return 0; - } - return FALSE; -} - -static void -change_load_filename( HWND hwndDlg, LONG_PTR user_data ) -{ - struct binary_info *info = ( struct binary_info * ) user_data; - - TCHAR *new_filename; - utils_file new_file; - - TCHAR buffer[80]; - int error; - - new_filename = ui_get_open_filename( "Fuse - Load Binary Data" ); - if( !new_filename ) return; - - error = utils_read_file( new_filename, &new_file ); - if( error ) { free( new_filename ); return; } - - /* Remove the data for the old file */ - utils_close_file( &info->file ); - - free( info->filename ); - - /* Put the new data in */ - info->filename = new_filename; info->file = new_file; - - /* And update the displayed information */ - SendDlgItemMessage( hwndDlg, IDC_BINARY_STATIC_PATH, WM_SETTEXT, - 0, ( LPARAM ) new_filename ); - - _sntprintf( buffer, 80, "%lu", (unsigned long) info->file.length ); - SendDlgItemMessage( hwndDlg, IDC_BINARY_EDIT_LENGTH, WM_SETTEXT, - 0, ( LPARAM ) buffer ); -} - -static void -load_data( HWND hwndDlg, LONG_PTR user_data ) -{ - struct binary_info *info = ( struct binary_info * )user_data; - HWND hwnd_control; - - long start, length; size_t i; - - TCHAR *temp_buffer, *endptr; - size_t temp_buffer_len; - int base; - - errno = 0; - temp_buffer_len = SendDlgItemMessage( hwndDlg, IDC_BINARY_EDIT_LENGTH, - WM_GETTEXTLENGTH, 0, 0 ); - temp_buffer = malloc( sizeof( TCHAR ) * ( temp_buffer_len + 1 ) ); - SendDlgItemMessage( hwndDlg, IDC_BINARY_EDIT_LENGTH, WM_GETTEXT, - temp_buffer_len + 1, ( LPARAM ) temp_buffer ); - - errno = 0; - base = ( !_tcsncmp( _T("0x"), temp_buffer, strlen( _T("0x") ) ) )? 16 : 10; - length = _tcstol( temp_buffer, &endptr, base ); - if( errno || length < 1 || length > 0x10000 || endptr == temp_buffer ) { - free( temp_buffer ); - ui_error( UI_ERROR_ERROR, "Length must be between 1 and 65536" ); - hwnd_control = GetDlgItem( hwndDlg, IDC_BINARY_EDIT_LENGTH ); - SendMessage( hwndDlg, WM_NEXTDLGCTL, (WPARAM) hwnd_control, TRUE ); - return; - } - free( temp_buffer ); - - if( length > info->file.length ) { - ui_error( UI_ERROR_ERROR, - "'%s' contains only %lu bytes", - info->filename, (unsigned long)info->file.length ); - return; - } - - errno = 0; - temp_buffer_len = SendDlgItemMessage( hwndDlg, IDC_BINARY_EDIT_START, - WM_GETTEXTLENGTH, 0, 0 ); - temp_buffer = malloc( sizeof( TCHAR ) * ( temp_buffer_len + 1 ) ); - SendDlgItemMessage( hwndDlg, IDC_BINARY_EDIT_START, WM_GETTEXT, - temp_buffer_len + 1, ( LPARAM ) temp_buffer ); - - errno = 0; - base = ( !_tcsncmp( _T("0x"), temp_buffer, strlen( _T("0x") ) ) )? 16 : 10; - start = _tcstol( temp_buffer, &endptr, base ); - if( errno || start < 0 || start > 0xffff || endptr == temp_buffer ) { - free( temp_buffer ); - ui_error( UI_ERROR_ERROR, "Start must be between 0 and 65535" ); - hwnd_control = GetDlgItem( hwndDlg, IDC_BINARY_EDIT_START ); - SendMessage( hwndDlg, WM_NEXTDLGCTL, (WPARAM) hwnd_control, TRUE ); - return; - } - free( temp_buffer ); - - if( start + length > 0x10000 ) { - ui_error( UI_ERROR_ERROR, "Block ends after address 65535" ); - hwnd_control = GetDlgItem( hwndDlg, IDC_BINARY_EDIT_LENGTH ); - SendMessage( hwndDlg, WM_NEXTDLGCTL, (WPARAM) hwnd_control, TRUE ); - return; - } - - for( i = 0; i < length; i++ ) - writebyte_internal( start + i, info->file.buffer[ i ] ); - - EndDialog( hwndDlg, 0 ); -} - -void -menu_file_savebinarydata( int action ) -{ - struct binary_info info; - - fuse_emulation_pause(); - - info.dialog_title = (TCHAR *) TEXT( "Fuse - Save Binary Data" ); - - info.filename = ui_get_save_filename( info.dialog_title ); - if( !info.filename ) { fuse_emulation_unpause(); return; } - - info.file.length = -1; /* let the dialog know to leave length box blank */ - info.on_change_filename = &change_save_filename; - info.on_execute = &save_data; - - /* Information display */ - DialogBoxParam( fuse_hInstance, MAKEINTRESOURCE( IDD_BINARY ), fuse_hWnd, - binarydata_proc, ( LPARAM ) &info ); - - free( info.filename ); - - fuse_emulation_unpause(); -} - -static void -change_save_filename( HWND hwndDlg, LONG_PTR user_data ) -{ - struct binary_info *info = ( struct binary_info * ) user_data; - TCHAR *new_filename; - - new_filename = ui_get_save_filename( "Fuse - Save Binary Data" ); - if( !new_filename ) return; - - free( info->filename ); - - info->filename = new_filename; - - SendDlgItemMessage( hwndDlg, IDC_BINARY_STATIC_PATH, WM_SETTEXT, - 0, ( LPARAM ) new_filename ); -} - -static void -save_data( HWND hwndDlg, LONG_PTR user_data ) -{ - struct binary_info *info = ( struct binary_info * ) user_data; - long start, length; - HWND hwnd_control; - - TCHAR *temp_buffer, *endptr; - size_t temp_buffer_len; - int base; - - int error; - - errno = 0; - temp_buffer_len = SendDlgItemMessage( hwndDlg, IDC_BINARY_EDIT_LENGTH, - WM_GETTEXTLENGTH, 0, 0 ); - temp_buffer = malloc( sizeof( TCHAR ) * ( temp_buffer_len + 1 ) ); - SendDlgItemMessage( hwndDlg, IDC_BINARY_EDIT_LENGTH, WM_GETTEXT, - temp_buffer_len + 1, ( LPARAM ) temp_buffer ); - - errno = 0; - base = ( !_tcsncmp( _T("0x"), temp_buffer, strlen( _T("0x") ) ) )? 16 : 10; - length = _tcstol( temp_buffer, &endptr, base ); - if( errno || length < 1 || length > 0x10000 || endptr == temp_buffer ) { - free( temp_buffer ); - ui_error( UI_ERROR_ERROR, "Length must be between 1 and 65536" ); - hwnd_control = GetDlgItem( hwndDlg, IDC_BINARY_EDIT_LENGTH ); - SendMessage( hwndDlg, WM_NEXTDLGCTL, (WPARAM) hwnd_control, TRUE ); - return; - } - free( temp_buffer ); - - errno = 0; - temp_buffer_len = SendDlgItemMessage( hwndDlg, IDC_BINARY_EDIT_START, - WM_GETTEXTLENGTH, 0, 0 ); - temp_buffer = malloc( sizeof( TCHAR ) * ( temp_buffer_len + 1 ) ); - SendDlgItemMessage( hwndDlg, IDC_BINARY_EDIT_START, WM_GETTEXT, - temp_buffer_len + 1, ( LPARAM ) temp_buffer ); - - errno = 0; - base = ( !_tcsncmp( _T("0x"), temp_buffer, strlen( _T("0x") ) ) )? 16 : 10; - start = _tcstol( temp_buffer, &endptr, base ); - if( errno || start < 0 || start > 0xffff || endptr == temp_buffer ) { - free( temp_buffer ); - ui_error( UI_ERROR_ERROR, "Start must be between 0 and 65535" ); - hwnd_control = GetDlgItem( hwndDlg, IDC_BINARY_EDIT_START ); - SendMessage( hwndDlg, WM_NEXTDLGCTL, (WPARAM) hwnd_control, TRUE ); - return; - } - free( temp_buffer ); - - if( start + length > 0x10000 ) { - ui_error( UI_ERROR_ERROR, "Block ends after address 65535" ); - hwnd_control = GetDlgItem( hwndDlg, IDC_BINARY_EDIT_LENGTH ); - SendMessage( hwndDlg, WM_NEXTDLGCTL, (WPARAM) hwnd_control, TRUE ); - return; - } - - error = utils_save_binary( start, length, info->filename ); - if( error ) return; - - EndDialog( hwndDlg, 0 ); -} diff --git a/fuse/ui/win32/binary.h b/fuse/ui/win32/binary.h deleted file mode 100644 index de9c8ef..0000000 --- a/fuse/ui/win32/binary.h +++ /dev/null @@ -1,31 +0,0 @@ -/* binary.h: Win32 routines to load/save chunks of binary data - Copyright (c) 2008 Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#define IDD_BINARY 1300 -#define IDC_BINARY_STATIC_FILENAME 1301 -#define IDC_BINARY_STATIC_PATH 1302 -#define IDC_BINARY_BUTTON_BROWSE 1303 -#define IDC_BINARY_STATIC_START 1304 -#define IDC_BINARY_EDIT_START 1305 -#define IDC_BINARY_STATIC_LENGTH 1306 -#define IDC_BINARY_EDIT_LENGTH 1307 diff --git a/fuse/ui/win32/binary.rc b/fuse/ui/win32/binary.rc deleted file mode 100644 index ce66fa8..0000000 --- a/fuse/ui/win32/binary.rc +++ /dev/null @@ -1,41 +0,0 @@ -/* binary.rc: Win32 routines to load/save chunks of binary data - Copyright (c) 2008 Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include "binary.h" - -IDD_BINARY DIALOGEX 0,0,396,85 -STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_FIXEDSYS | WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "Fuse - Load Binary Data" -FONT 8,"Ms Shell Dlg 2",400,0,1 -BEGIN - CTEXT "Filename",IDC_BINARY_STATIC_FILENAME,5,5,34,15,SS_CENTERIMAGE - LTEXT "",IDC_BINARY_STATIC_PATH,45,5,290,15,SS_CENTERIMAGE - PUSHBUTTON "Browse...",IDC_BINARY_BUTTON_BROWSE,340,5,50,14 - CTEXT "Start",IDC_BINARY_STATIC_START,5,25,34,15,SS_CENTERIMAGE - EDITTEXT IDC_BINARY_EDIT_START,45,25,344,15,ES_AUTOHSCROLL - CTEXT "Length",IDC_BINARY_STATIC_LENGTH,5,45,34,15,SS_CENTERIMAGE - EDITTEXT IDC_BINARY_EDIT_LENGTH,45,45,344,15,ES_AUTOHSCROLL - DEFPUSHBUTTON "OK",IDOK,275,65,50,14 - PUSHBUTTON "Cancel",IDCANCEL,335,65,50,14 -END diff --git a/fuse/ui/win32/browse.c b/fuse/ui/win32/browse.c deleted file mode 100644 index 80ded5e..0000000 --- a/fuse/ui/win32/browse.c +++ /dev/null @@ -1,255 +0,0 @@ -/* browse.c: tape browser dialog box - Copyright (c) 2002-2008 Philip Kendall, Marek Januszewski - Copyright (c) 2015 Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include - -#include "fuse.h" -#include "tape.h" -#include "ui/ui.h" -#include "win32internals.h" - -#include "browse.h" - -static INT_PTR CALLBACK dialog_proc( HWND hwndDlg, UINT uMsg, - WPARAM wParam, LPARAM lParam ); -static void add_block_details( libspectrum_tape_block *block, void *user_data ); -static void select_row( LPNMITEMACTIVATE lpnmitem ); - -static HWND dialog; /* The dialog box itself */ - -static int dialog_created; /* Have we created the dialog box yet? */ - -void -menu_media_tape_browse( int action ) -{ - /* Firstly, stop emulation */ - fuse_emulation_pause(); - - if( !dialog_created ) { - dialog = CreateDialog( fuse_hInstance, MAKEINTRESOURCE( IDD_BROWSE ), - fuse_hWnd, dialog_proc ); - if( dialog == NULL ) { fuse_emulation_unpause(); return; } - } - - if( ui_tape_browser_update( UI_TAPE_BROWSER_NEW_TAPE, NULL ) ) { - fuse_emulation_unpause(); - return; - } - - ShowWindow( dialog, SW_SHOW ); - - /* Carry on with emulation */ - fuse_emulation_unpause(); -} - -static void -dialog_init( HWND hwndDlg ) -{ - size_t i; - LPCTSTR titles[3] = { _T( "" ), _T( "Block type" ), _T( "Data" ) }; - int titles_widths[3] = { 16, 115, 150 }; - - /* set extended listview style to select full row, when an item is selected */ - DWORD lv_ext_style; - lv_ext_style = SendDlgItemMessage( hwndDlg, IDC_BROWSE_LV, - LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0 ); - lv_ext_style |= LVS_EX_FULLROWSELECT; - SendDlgItemMessage( hwndDlg, IDC_BROWSE_LV, - LVM_SETEXTENDEDLISTVIEWSTYLE, 0, lv_ext_style ); - - /* Create columns in the listview */ - LVCOLUMN lvc; - lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT ; - lvc.fmt = LVCFMT_LEFT; - - for( i = 0; i < 3; i++ ) { - if( i != 0 ) - lvc.mask |= LVCF_SUBITEM; - lvc.cx = titles_widths[i]; - lvc.pszText = (LPTSTR)titles[i]; - SendDlgItemMessage( hwndDlg, IDC_BROWSE_LV, LVM_INSERTCOLUMN, i, - ( LPARAM ) &lvc ); - } - - /* create image list for the listview */ - HBITMAP icon_tape_marker, icon_tape_marker_mask; - BITMAP bmp; - HIMAGELIST himl; - - /* FIXME: need to destroy those objects later */ - icon_tape_marker = LoadImage( fuse_hInstance, "win32bmp_tape_marker", - IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); - icon_tape_marker_mask = LoadImage( fuse_hInstance, "win32bmp_tape_marker_mask", - IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); - GetObject( icon_tape_marker, sizeof( bmp ), &bmp ); - - /* FIXME: destroy the list later */ - himl = ImageList_Create( bmp.bmWidth, bmp.bmHeight, - ILC_COLOR | ILC_MASK, 1, 0 ); - - ImageList_Add( himl, icon_tape_marker, icon_tape_marker_mask ); - - SendDlgItemMessage( hwndDlg, IDC_BROWSE_LV, LVM_SETIMAGELIST, - LVSIL_SMALL, ( LPARAM ) himl ); - - dialog_created = 1; -} - -static INT_PTR CALLBACK -dialog_proc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) -{ -/* FIXME: implement resizing the dialog */ - switch( uMsg ) { - - case WM_INITDIALOG: - dialog_init( hwndDlg ); - return FALSE; - - case WM_NOTIFY: - if( ( ( LPNMHDR ) lParam )->code == NM_DBLCLK ) { - if( ( ( LPNMHDR ) lParam )->idFrom == IDC_BROWSE_LV ) { - select_row( ( LPNMITEMACTIVATE ) lParam ); - return 0; - } - } - break; - - case WM_COMMAND: - if( LOWORD( wParam ) == IDCLOSE ) { - ShowWindow( dialog, SW_HIDE ); - return 0; - } - break; - - case WM_CLOSE: - /* Catch attempts to delete the window and just hide it instead */ - ShowWindow( dialog, SW_HIDE ); - return 0; - } - return FALSE; -} - -int -ui_tape_browser_update( ui_tape_browser_update_type change GCC_UNUSED, - libspectrum_tape_block *block GCC_UNUSED ) -{ - int error, current_block; - - if( !dialog_created ) return 0; - - fuse_emulation_pause(); - - SendDlgItemMessage( dialog, IDC_BROWSE_LV, LVM_DELETEALLITEMS, 0, 0 ); - - error = tape_foreach( add_block_details, NULL ); - if( error ) { - fuse_emulation_unpause(); - return 1; - } - - current_block = tape_get_current_block(); - if( current_block != -1 ) { - LVITEM li; - li.mask = LVIF_IMAGE; - li.iItem = current_block; - li.iSubItem = 0; - li.iImage = 0; - SendDlgItemMessage( dialog, IDC_BROWSE_LV, LVM_SETITEM, 0, ( LPARAM ) &li ); - } - - if( tape_modified ) { - SendDlgItemMessage( dialog, IDC_BROWSE_MODIFIED, WM_SETTEXT, - 0, ( LPARAM ) TEXT( "Tape modified" ) ); - } else { - SendDlgItemMessage( dialog, IDC_BROWSE_MODIFIED, WM_SETTEXT, - 0, ( LPARAM ) TEXT( "Tape not modified" ) ); - } - - fuse_emulation_unpause(); - - return 0; -} - -static void -add_block_details( libspectrum_tape_block *block, void *user_data ) -{ - TCHAR buffer[256]; - TCHAR *details[3] = { &buffer[0], &buffer[80], &buffer[160] }; - LV_ITEM lvi; - size_t i; - - _tcscpy( details[0], "" ); - libspectrum_tape_block_description( details[1], 80, block ); - /* FIXME: why does it give such a big number of bytes? */ - tape_block_details( details[2], 80, block ); - - lvi.mask = LVIF_TEXT | LVIF_IMAGE; - lvi.iImage = -1; - lvi.iItem = SendDlgItemMessage( dialog, IDC_BROWSE_LV, - LVM_GETITEMCOUNT, 0, 0 ); - for( i = 0; i < 3; i++ ) { - lvi.iSubItem = i; - lvi.pszText = details[i]; - if( i == 0 ) - SendDlgItemMessage( dialog, IDC_BROWSE_LV, LVM_INSERTITEM, 0, - ( LPARAM ) &lvi ); - else - SendDlgItemMessage( dialog, IDC_BROWSE_LV, LVM_SETITEM, 0, - ( LPARAM ) &lvi ); - } -} - -/* Called when a row is selected */ -static void -select_row( LPNMITEMACTIVATE lpnmitem ) -{ - int current_block, row; - - row = lpnmitem->iItem; - - /* Don't do anything if the current block was clicked on */ - current_block = tape_get_current_block(); - if( row == current_block ) return; - - /* Otherwise, select the new block */ - tape_select_block_no_update( row ); - - /* set the marker at the current item, clear others */ - size_t i, count; - count = SendDlgItemMessage( dialog, IDC_BROWSE_LV, - LVM_GETITEMCOUNT, 0, 0 ); - LVITEM li; - li.mask = LVIF_IMAGE; - li.iSubItem = 0; - - for( i=0; i - -#include - -#include "fuse.h" -#include "win32internals.h" -#include "settings.h" -#include "ui/ui.h" - -int -win32ui_confirm( const char *string ) -{ - int confirm; - int result; - - /* Return value isn't an error code, but signifies whether to undertake - the action */ - if( !settings_current.confirm_actions ) return 1; - - fuse_emulation_pause(); - - confirm = 0; - - result = MessageBox( fuse_hWnd, string, "Fuse - Confirm", - MB_OKCANCEL | MB_ICONQUESTION ); - if( result == IDOK ) confirm = 1; - - fuse_emulation_unpause(); - - return confirm; -} - -ui_confirm_save_t -ui_confirm_save_specific( const char *message ) -{ - ui_confirm_save_t confirm; - int result; - - if( !settings_current.confirm_actions ) return UI_CONFIRM_SAVE_DONTSAVE; - - fuse_emulation_pause(); - - confirm = UI_CONFIRM_SAVE_CANCEL; - - result = MessageBox( fuse_hWnd, message, "Fuse - Confirm", - MB_YESNOCANCEL | MB_ICONQUESTION ); - switch( result ) - { - case IDYES: - confirm = UI_CONFIRM_SAVE_SAVE; - break; - case IDNO: - confirm = UI_CONFIRM_SAVE_DONTSAVE; - break; - } - - fuse_emulation_unpause(); - - return confirm; -} - -int -ui_query( const char *message ) -{ - return win32ui_confirm( message ); -} - diff --git a/fuse/ui/win32/debugger.c b/fuse/ui/win32/debugger.c deleted file mode 100644 index 3d04e23..0000000 --- a/fuse/ui/win32/debugger.c +++ /dev/null @@ -1,1337 +0,0 @@ -/* debugger.c: the Win32 debugger - Copyright (c) 2004-2012 Philip Kendall, Marek Januszewski - Copyright (c) 2013-2015 Sergio Baldoví - Copyright (c) 2015 Stuart Brady - Copyright (c) 2016 BogDan Vatra - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -/* FIXME: is that needed? -#include -#include -*/ - -#include -#include -#include -#include - -#include "debugger/debugger.h" -#include "event.h" -#include "fuse.h" -#include "settings.h" -#include "peripherals/ide/zxcf.h" -#include "peripherals/scld.h" -#include "peripherals/ula.h" -#include "ui/ui.h" -#include "win32internals.h" -#include "z80/z80.h" -#include "z80/z80_macros.h" - -#include "debugger.h" - -/* FIXME: delete whatever is not needed - -#include "machine.h" -#include "memory_pages.h" - - */ - -/* The various debugger panes */ -typedef enum debugger_pane { - - DEBUGGER_PANE_BEGIN = 1, /* Start marker */ - - DEBUGGER_PANE_REGISTERS = DEBUGGER_PANE_BEGIN, - DEBUGGER_PANE_MEMORYMAP, - DEBUGGER_PANE_BREAKPOINTS, - DEBUGGER_PANE_DISASSEMBLY, - DEBUGGER_PANE_STACK, - DEBUGGER_PANE_EVENTS, - - DEBUGGER_PANE_END /* End marker */ -} debugger_pane; - -static int create_dialog( void ); -static int hide_hidden_panes( void ); -static UINT get_pane_menu_item( debugger_pane pane ); -static BOOL show_hide_pane( debugger_pane pane, int show ); -/* static int create_menu_bar( void ); this function is handled by rc */ -static void toggle_display( debugger_pane pane, UINT menu_item_id ); -static int create_register_display( HFONT font ); -/* int create_memory_map( void ); this function is handled by rc */ -static int create_breakpoints( void ); -static int create_disassembly( HFONT font ); -static int create_stack_display( HFONT font ); -static void stack_click( LPNMITEMACTIVATE lpnmitem ); -static int create_events( void ); -static void events_click( LPNMITEMACTIVATE lpnmitem ); -/* int create_command_entry( void ); this function is handled by rc */ -/* int create_buttons( void ); this function is handled by rc */ - -static int activate_debugger( void ); -static void update_memory_map( void ); -static void update_breakpoints( void ); -static void update_disassembly( void ); -static void update_events( void ); -static void add_event( gpointer data, gpointer user_data GCC_UNUSED ); -static int deactivate_debugger( void ); - -static int move_disassembly( WPARAM scroll_command ); - -static void evaluate_command( void ); -static void win32ui_debugger_done_step( void ); -static void win32ui_debugger_done_continue( void ); -static void win32ui_debugger_break( void ); -static void delete_dialog( void ); -static void win32ui_debugger_done_close( void ); -static INT_PTR CALLBACK win32ui_debugger_proc( HWND hWnd, UINT msg, - WPARAM wParam, LPARAM lParam ); - -static LRESULT CALLBACK -disassembly_listview_proc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); - -/* Debugger window handle */ -HWND fuse_hDBGWnd; - -/* The top line of the current disassembly */ -static libspectrum_word disassembly_top; - -/* The next line below the current disassembly */ -static libspectrum_word disassembly_bottom; - -/* helper constants for disassembly listview's scrollbar */ -static const int disassembly_min = 0x0000; -static const int disassembly_max = 0xffff; -/* Visual styles could change visible rows */ -static unsigned int disassembly_page = 20; - -/* Have we created the above yet? */ -static int dialog_created = 0; - -/* Is the debugger window active (as opposed to the debugger itself)? */ -static int debugger_active; - -#define STUB do { printf("STUB: %s()\n", __func__); fflush(stdout); } while(0) - -static const TCHAR* -format_8_bit( void ) -{ - return debugger_output_base == 10 ? TEXT( "%3d" ) : TEXT( "0x%02X" ); -} - -static const TCHAR* -format_16_bit( void ) -{ - return debugger_output_base == 10 ? TEXT( "%5d" ) : TEXT( "0x%04X" ); -} - -int -ui_debugger_activate( void ) -{ - int error; - - fuse_emulation_pause(); - - /* create_dialog will create the dialog or activate if it exists */ - if( !dialog_created ) if( create_dialog() ) return 1; - - ShowWindow( fuse_hDBGWnd, SW_SHOW ); - error = hide_hidden_panes(); if( error ) return error; - - EnableWindow( GetDlgItem( fuse_hDBGWnd, IDC_DBG_BTN_CONT ), TRUE); - EnableWindow( GetDlgItem( fuse_hDBGWnd, IDC_DBG_BTN_BREAK ), FALSE ); - if( !debugger_active ) activate_debugger(); - - return 0; -} - -void -ui_breakpoints_updated( void ) -{ - /* TODO: Refresh debugger list here */ -} - -static int -hide_hidden_panes( void ) -{ - debugger_pane i; - UINT checkitem; - MENUITEMINFO mii; - - for( i = DEBUGGER_PANE_BEGIN; i < DEBUGGER_PANE_END; i++ ) { - - checkitem = get_pane_menu_item( i ); if( !checkitem ) return 1; - - mii.fMask = MIIM_STATE; - mii.cbSize = sizeof( MENUITEMINFO ); - if( ! GetMenuItemInfo( GetMenu( fuse_hDBGWnd ), checkitem, FALSE, &mii ) ) - return 1; - - if( mii.fState & MFS_CHECKED ) continue; - - if( ! show_hide_pane( i, SW_HIDE ) ) return 1; - } - - return 0; -} - -static UINT -get_pane_menu_item( debugger_pane pane ) -{ - UINT menu_item_id; - - menu_item_id = 0; - - switch( pane ) { - case DEBUGGER_PANE_REGISTERS: menu_item_id = IDM_DBG_REG; break; - case DEBUGGER_PANE_MEMORYMAP: menu_item_id = IDM_DBG_MEMMAP; break; - case DEBUGGER_PANE_BREAKPOINTS: menu_item_id = IDM_DBG_BPS; break; - case DEBUGGER_PANE_DISASSEMBLY: menu_item_id = IDM_DBG_DIS; break; - case DEBUGGER_PANE_STACK: menu_item_id = IDM_DBG_STACK; break; - case DEBUGGER_PANE_EVENTS: menu_item_id = IDM_DBG_EVENTS; break; - - case DEBUGGER_PANE_END: break; - } - - if( !menu_item_id ) { - ui_error( UI_ERROR_ERROR, "unknown debugger pane %u", pane ); - return 0; - } - - return menu_item_id; -} - -static BOOL -show_hide_pane( debugger_pane pane, int show ) -{ -/* Instead of get_pane() and then hiding or showing the widget as it is done - in gtk ui, we need to show/hide multiple widgets, hence this combined - function. - - show parameter needs to be SW_SHOW to reveal the pane, - or SW_HIDE to hide it. -*/ - /* FIXME: window needs to resize/collapse as panel are being hidden */ - int i; - - switch( pane ) { - case DEBUGGER_PANE_REGISTERS: - for( i = IDC_DBG_REG_PC; i <= IDC_DBG_REG_IM; i++ ) { - ShowWindow( GetDlgItem( fuse_hDBGWnd, i ), show ); - } - return TRUE; - - case DEBUGGER_PANE_MEMORYMAP: - for( i = IDC_DBG_MAP11; i <= IDC_DBG_TEXT_CONTENDED; i++ ) { - ShowWindow( GetDlgItem( fuse_hDBGWnd, i ), show ); - } - ShowWindow( GetDlgItem( fuse_hDBGWnd, IDC_DBG_GRP_MEMMAP ), show ); - return TRUE; - - case DEBUGGER_PANE_BREAKPOINTS: - ShowWindow( GetDlgItem( fuse_hDBGWnd, IDC_DBG_LV_BPS ), show ); - return TRUE; - - case DEBUGGER_PANE_DISASSEMBLY: - ShowWindow( GetDlgItem( fuse_hDBGWnd, IDC_DBG_LV_PC ), show ); - ShowWindow( GetDlgItem( fuse_hDBGWnd, IDC_DBG_SB_PC ), show ); - return TRUE; - - case DEBUGGER_PANE_STACK: - ShowWindow( GetDlgItem( fuse_hDBGWnd, IDC_DBG_LV_STACK ), show ); - return TRUE; - - case DEBUGGER_PANE_EVENTS: - ShowWindow( GetDlgItem( fuse_hDBGWnd, IDC_DBG_LV_EVENTS ), show ); - return TRUE; - - case DEBUGGER_PANE_END: break; - } - - ui_error( UI_ERROR_ERROR, "unknown debugger pane %u", pane ); - return FALSE; -} - -int -ui_debugger_deactivate( int interruptable ) -{ - if( debugger_active ) deactivate_debugger(); - - if( dialog_created ) { - EnableWindow( GetDlgItem( fuse_hDBGWnd, IDC_DBG_BTN_CONT ), - !interruptable ? TRUE : FALSE ); - EnableWindow( GetDlgItem( fuse_hDBGWnd, IDC_DBG_BTN_BREAK ), - interruptable ? TRUE : FALSE ); - } - - return 0; -} - -static int -create_dialog( void ) -{ - int error; - debugger_pane i; - MENUITEMINFO mii; - - HFONT font; - - error = win32ui_get_monospaced_font( &font ); if( error ) return error; - - fuse_hDBGWnd = CreateDialog( fuse_hInstance, MAKEINTRESOURCE( IDD_DBG ), - fuse_hWnd, win32ui_debugger_proc ); - - /* The main display areas */ - error = create_register_display( font ); - if( error ) return error; - - error = create_breakpoints(); if( error ) return error; - - error = create_disassembly( font ); if( error ) return error; - - error = create_stack_display( font ); if( error ) return error; - - error = create_events(); if( error ) return error; - - /* Initially, have all the panes visible */ - for( i = DEBUGGER_PANE_BEGIN; i < DEBUGGER_PANE_END; i++ ) { - - UINT check_item; - - check_item = get_pane_menu_item( i ); if( !check_item ) break; - - mii.fMask = MIIM_STATE; - mii.fState = MFS_CHECKED; - mii.cbSize = sizeof( MENUITEMINFO ); - SetMenuItemInfo( GetMenu( fuse_hDBGWnd ), check_item, FALSE, &mii ); - } - - dialog_created = 1; - - return 0; -} - -static void -toggle_display( debugger_pane pane, UINT menu_item_id ) -{ - MENUITEMINFO mii; - - mii.fMask = MIIM_STATE; - mii.cbSize = sizeof( MENUITEMINFO ); - GetMenuItemInfo( GetMenu( fuse_hDBGWnd ), menu_item_id, FALSE, &mii ); - - /* Windows doesn't automatically checks/unchecks - the menus when they're clicked */ - if( mii.fState & MFS_CHECKED ) { - show_hide_pane( pane, SW_HIDE ); - mii.fState = MFS_UNCHECKED; - SetMenuItemInfo( GetMenu( fuse_hDBGWnd ), menu_item_id, FALSE, &mii ); - } else { - show_hide_pane( pane, SW_SHOW ); - mii.fState = MFS_CHECKED; - SetMenuItemInfo( GetMenu( fuse_hDBGWnd ), menu_item_id, FALSE, &mii ); - } -} - -static int -create_register_display( HFONT font ) -{ - /* this display is created in rc, just set the monospaced font */ - size_t i; - - for( i = 0; i < NUM_DBG_REGS; i++ ) { - win32ui_set_font( fuse_hDBGWnd, IDC_DBG_REG_PC + i, font ); - } - - return 0; -} - -static int -create_breakpoints( void ) -{ - size_t i; - - LPCTSTR breakpoint_titles[] = { _T( "ID" ), _T( "Type" ), _T( "Value" ), - _T( "Ignore" ), _T( "Life" ), - _T( "Condition" ) }; - /* set extended listview style to select full row, when an item is selected */ - DWORD lv_ext_style; - lv_ext_style = SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_BPS, - LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0 ); - lv_ext_style |= LVS_EX_FULLROWSELECT; - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_BPS, - LVM_SETEXTENDEDLISTVIEWSTYLE, 0, lv_ext_style ); - - /* create columns */ - LVCOLUMN lvc; - lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT ; - lvc.fmt = LVCFMT_LEFT; - - for( i = 0; i < 6; i++ ) { - if( i != 0 ) - lvc.mask |= LVCF_SUBITEM; - lvc.cx = _tcslen( breakpoint_titles[i] ) * 8 + 10; - lvc.pszText = (LPTSTR)breakpoint_titles[i]; - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_BPS, LVM_INSERTCOLUMN, i, - ( LPARAM ) &lvc ); - } - - return 0; -} - -static int -create_disassembly( HFONT font ) -{ - size_t i; - - LPCTSTR disassembly_titles[] = { TEXT( "Address" ), TEXT( "Instruction" ) }; - - /* The disassembly listview itself */ - - /* subclass listview to catch keydown and mousewheel messages */ - HWND hwnd_list = GetDlgItem( fuse_hDBGWnd, IDC_DBG_LV_PC ); - WNDPROC orig_proc = (WNDPROC) GetWindowLongPtr( hwnd_list, GWLP_WNDPROC ); - SetProp( hwnd_list, "original_proc", (HANDLE) orig_proc ); - SetWindowLongPtr( hwnd_list, GWLP_WNDPROC, - (LONG_PTR) (WNDPROC) disassembly_listview_proc ); - - /* set extended listview style to select full row, when an item is selected */ - DWORD lv_ext_style; - lv_ext_style = SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_PC, - LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0 ); - lv_ext_style |= LVS_EX_FULLROWSELECT; - lv_ext_style |= LVS_EX_DOUBLEBUFFER; - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_PC, - LVM_SETEXTENDEDLISTVIEWSTYLE, 0, lv_ext_style ); - - win32ui_set_font( fuse_hDBGWnd, IDC_DBG_LV_PC, font ); - - /* create columns */ - LVCOLUMN lvc; - lvc.mask = LVCF_FMT | LVCF_TEXT; - lvc.fmt = LVCFMT_LEFT; - - for( i = 0; i < 2; i++ ) { - if( i != 0 ) lvc.mask |= LVCF_SUBITEM; - lvc.pszText = (LPTSTR)disassembly_titles[i]; - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_PC, LVM_INSERTCOLUMN, i, - ( LPARAM ) &lvc ); - } - - /* Set columns width */ - ListView_SetColumnWidth( hwnd_list, 0, LVSCW_AUTOSIZE_USEHEADER ); - ListView_SetColumnWidth( hwnd_list, 1, LVSCW_AUTOSIZE_USEHEADER ); - - /* Recalculate visible rows, Visual Styles could change rows height */ - disassembly_page = SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_PC, - LVM_GETCOUNTPERPAGE, 0, 0 ); - - /* The disassembly scrollbar */ - SCROLLINFO si; - si.cbSize = sizeof(si); - si.fMask = SIF_POS | SIF_RANGE | SIF_PAGE; - si.nPos = 0; - si.nMin = disassembly_min; - si.nMax = disassembly_max; - si.nPage = disassembly_page; - SetScrollInfo( GetDlgItem( fuse_hDBGWnd, IDC_DBG_SB_PC ), - SB_CTL, &si, TRUE ); - - return 0; -} - -static int -create_stack_display( HFONT font ) -{ - size_t i; - - LPCTSTR stack_titles[] = { _T( "Address" ), _T( "Value" ) }; - - /* set extended listview style to select full row, when an item is selected */ - DWORD lv_ext_style; - lv_ext_style = SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_STACK, - LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0 ); - lv_ext_style |= LVS_EX_FULLROWSELECT; - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_STACK, - LVM_SETEXTENDEDLISTVIEWSTYLE, 0, lv_ext_style ); - - win32ui_set_font( fuse_hDBGWnd, IDC_DBG_LV_STACK, font ); - - /* create columns */ - LVCOLUMN lvc; - lvc.mask = LVCF_FMT | LVCF_TEXT; - lvc.fmt = LVCFMT_LEFT; - - for( i = 0; i < 2; i++ ) { - if( i != 0 ) lvc.mask |= LVCF_SUBITEM; - lvc.pszText = (LPTSTR)stack_titles[i]; - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_STACK, LVM_INSERTCOLUMN, i, - ( LPARAM ) &lvc ); - } - - /* Set columns width */ - HWND hwnd_list = GetDlgItem( fuse_hDBGWnd, IDC_DBG_LV_STACK ); - ListView_SetColumnWidth( hwnd_list, 0, LVSCW_AUTOSIZE_USEHEADER ); - ListView_SetColumnWidth( hwnd_list, 1, LVSCW_AUTOSIZE_USEHEADER ); - - return 0; -} - -static void -stack_click( LPNMITEMACTIVATE lpnmitem ) -{ - libspectrum_word destination; - int retval, error, row; - char *stopstring; - TCHAR buffer[255]; - LVITEM li; - - row = lpnmitem->iItem; - if( row < 0 ) return; - - li.iSubItem = 1; - li.pszText = buffer; - li.cchTextMax = 255; - retval = SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_STACK, - LVM_GETITEMTEXT, row, ( LPARAM ) &li ); - if( !retval ) { - ui_error( UI_ERROR_ERROR, "couldn't get text for row %d", row ); - return; - } - - destination = strtoul( buffer, &stopstring, 16 ); - - error = debugger_breakpoint_add_address( - DEBUGGER_BREAKPOINT_TYPE_EXECUTE, memory_source_any, 0, destination, 0, - DEBUGGER_BREAKPOINT_LIFE_ONESHOT, NULL - ); - if( error ) return; - - debugger_run(); -} - -static int -create_events( void ) -{ - size_t i; - LPCTSTR titles[] = { _T( "Time" ), _T( "Type" ) }; - - /* set extended listview style to select full row, when an item is selected */ - DWORD lv_ext_style; - lv_ext_style = SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_EVENTS, - LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0 ); - lv_ext_style |= LVS_EX_FULLROWSELECT; - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_EVENTS, - LVM_SETEXTENDEDLISTVIEWSTYLE, 0, lv_ext_style ); - - /* create columns */ - LVCOLUMN lvc; - lvc.mask = LVCF_FMT | LVCF_TEXT; - lvc.fmt = LVCFMT_LEFT; - - for( i = 0; i < 2; i++ ) { - if( i != 0 ) lvc.mask |= LVCF_SUBITEM; - lvc.pszText = (LPTSTR)titles[i]; - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_EVENTS, LVM_INSERTCOLUMN, i, - ( LPARAM ) &lvc ); - } - - /* Set columns width */ - HWND hwnd_list = GetDlgItem( fuse_hDBGWnd, IDC_DBG_LV_EVENTS ); - ListView_SetColumnWidth( hwnd_list, 0, LVSCW_AUTOSIZE_USEHEADER ); - ListView_SetColumnWidth( hwnd_list, 1, LVSCW_AUTOSIZE_USEHEADER ); - - return 0; -} - -static void -events_click( LPNMITEMACTIVATE lpnmitem ) -{ - int got_text, error, row; - TCHAR buffer[255]; - LVITEM li; - libspectrum_dword tstates; - - row = lpnmitem->iItem; - if( row < 0 ) return; - - li.iSubItem = 0; - li.pszText = buffer; - li.cchTextMax = 255; - got_text = SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_EVENTS, - LVM_GETITEMTEXT, row, ( LPARAM ) &li ); - if( !got_text ) { - ui_error( UI_ERROR_ERROR, "couldn't get text for row %d", row ); - return; - } - - tstates = _ttoi( buffer ); - error = debugger_breakpoint_add_time( - DEBUGGER_BREAKPOINT_TYPE_TIME, tstates, 0, - DEBUGGER_BREAKPOINT_LIFE_ONESHOT, NULL - ); - if( error ) return; - - debugger_run(); -} - -static int -activate_debugger( void ) -{ - debugger_active = 1; - - ui_debugger_disassemble( PC ); - ui_debugger_update(); - - win32ui_process_messages( 0 ); - return 0; -} - -/* Update the debugger's display */ -int -ui_debugger_update( void ) -{ - size_t i; - TCHAR buffer[1024], format_string[1024]; - TCHAR *disassembly_text[2] = { &buffer[0], &buffer[40] }; - libspectrum_word address; - int capabilities; size_t length; - - const char *register_name[] = { TEXT( "PC" ), TEXT( "SP" ), - TEXT( "AF" ), TEXT( "AF'" ), - TEXT( "BC" ), TEXT( "BC'" ), - TEXT( "DE" ), TEXT( "DE'" ), - TEXT( "HL" ), TEXT( "HL'" ), - TEXT( "IX" ), TEXT( "IY" ), - }; - - libspectrum_word *value_ptr[] = { &PC, &SP, &AF, &AF_, - &BC, &BC_, &DE, &DE_, - &HL, &HL_, &IX, &IY, - }; - - if( !dialog_created ) return 0; - - /* FIXME: verify all functions below are unicode compliant */ - for( i = 0; i < 12; i++ ) { - _sntprintf( buffer, 5, "%3s ", register_name[i] ); - _sntprintf( &buffer[4], 76, format_16_bit(), *value_ptr[i] ); - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_REG_PC + i, - WM_SETTEXT, (WPARAM) 0, (LPARAM) buffer ); - } - - _tcscpy( buffer, TEXT( " I " ) ); - _sntprintf( &buffer[6], 76, format_8_bit(), I ); - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_REG_I, - WM_SETTEXT, (WPARAM) 0, (LPARAM) buffer ); - - _tcscpy( buffer, TEXT( " R " ) ); - _sntprintf( &buffer[6], 80, format_8_bit(), ( R & 0x7f ) | ( R7 & 0x80 ) ); - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_REG_R, - WM_SETTEXT, (WPARAM) 0, (LPARAM) buffer ); - - _sntprintf( buffer, 80, TEXT( "Halted %d" ), z80.halted ); - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_REG_HALTED, - WM_SETTEXT, (WPARAM) 0, (LPARAM) buffer ); - _sntprintf( buffer, 80, TEXT( "T-states %5d" ), tstates ); - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_REG_T_STATES, - WM_SETTEXT, (WPARAM) 0, (LPARAM) buffer ); - _sntprintf( buffer, 80, TEXT( " IM %d\r\nIFF1 %d\r\nIFF2 %d" ), - IM, IFF1, IFF2 ); - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_REG_IM, - WM_SETTEXT, (WPARAM) 0, (LPARAM) buffer ); - - _tcscpy( buffer, TEXT( "SZ5H3PNC\r\n" ) ); - for( i = 0; i < 8; i++ ) buffer[i+10] = ( F & ( 0x80 >> i ) ) ? '1' : '0'; - buffer[18] = '\0'; - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_REG_FLAGS, - WM_SETTEXT, (WPARAM) 0, (LPARAM) buffer ); - - capabilities = libspectrum_machine_capabilities( machine_current->machine ); - - _stprintf( format_string, " ULA %s", format_8_bit() ); - _sntprintf( buffer, 1024, format_string, ula_last_byte() ); - - if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_AY ) { - _stprintf( format_string, "\r\n AY %s", format_8_bit() ); - length = _tcslen( buffer ); - _sntprintf( &buffer[length], 1024-length, format_string, - machine_current->ay.current_register ); - } - - if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_128_MEMORY ) { - _stprintf( format_string, "\r\n128Mem %s", format_8_bit() ); - length = _tcslen( buffer ); - _sntprintf( &buffer[length], 1024-length, format_string, - machine_current->ram.last_byte ); - } - - if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_PLUS3_MEMORY ) { - _stprintf( format_string, "\r\n+3 Mem %s", format_8_bit() ); - length = _tcslen( buffer ); - _sntprintf( &buffer[length], 1024-length, format_string, - machine_current->ram.last_byte2 ); - } - - if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_VIDEO || - capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_MEMORY || - capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_SE_MEMORY ) { - _stprintf( format_string, "\r\nTmxDec %s", format_8_bit() ); - length = _tcslen( buffer ); - _sntprintf( &buffer[length], 1024-length, format_string, - scld_last_dec.byte ); - } - - if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_MEMORY || - capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_SE_MEMORY ) { - _stprintf( format_string, "\r\nTmxHsr %s", format_8_bit() ); - length = _tcslen( buffer ); - _sntprintf( &buffer[length], 1024-length, format_string, scld_last_hsr ); - } - - if( settings_current.zxcf_active ) { - _stprintf( format_string, "\r\n ZXCF %s", format_8_bit() ); - length = _tcslen( buffer ); - _sntprintf( &buffer[length], 1024-length, format_string, - zxcf_last_memctl() ); - } - - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_REG_ULA, - WM_SETTEXT, (WPARAM) 0, (LPARAM) buffer ); - - update_memory_map(); - update_breakpoints(); - update_disassembly(); - - /* And the stack display */ - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_STACK, - LVM_DELETEALLITEMS, 0, 0 ); - - LV_ITEM lvi; - lvi.mask = LVIF_TEXT; - - for( i = 0, address = SP + 38; i < 20; i++, address -= 2 ) { - - libspectrum_word contents = readbyte_internal( address ) + - 0x100 * readbyte_internal( address + 1 ); - - _sntprintf( disassembly_text[0], 40, format_16_bit(), address ); - _sntprintf( disassembly_text[1], 40, format_16_bit(), contents ); - - /* add the item */ - lvi.iItem = i; - lvi.iSubItem = 0; - lvi.pszText = disassembly_text[0]; - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_STACK, LVM_INSERTITEM, 0, - ( LPARAM ) &lvi ); - lvi.iSubItem = 1; - lvi.pszText = disassembly_text[1]; - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_STACK, LVM_SETITEM, 0, - ( LPARAM ) &lvi ); - } - - /* And the events display */ - update_events(); - - return 0; -} - -static void -update_memory_map( void ) -{ - TCHAR buffer[ 40 ]; - int source, page_num, writable, contended; - libspectrum_word offset; - size_t i, j, block, row; - - source = page_num = writable = contended = -1; - offset = 0; - row = 0; - - for( block = 0; block < MEMORY_PAGES_IN_64K && row < 8; block++ ) { - memory_page *page = &memory_map_read[block]; - - if( page->source != source || - page->page_num != page_num || - page->offset != offset || - page->writable != writable || - page->contended != contended ) { - - _sntprintf( buffer, 40, format_16_bit(), - (unsigned)block * MEMORY_PAGE_SIZE ); - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_MAP11 + ( row * 4 ), - WM_SETTEXT, ( WPARAM ) 0, ( LPARAM ) buffer ); - - /* FIXME: memory_source_description is not unicode */ - _snprintf( buffer, 40, TEXT( "%s %d" ), - memory_source_description( page->source ), page->page_num ); - - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_MAP11 + ( row * 4 ) + 1, - WM_SETTEXT, ( WPARAM ) 0, ( LPARAM ) buffer ); - - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_MAP11 + ( row * 4 ) + 2, - WM_SETTEXT, (WPARAM) 0, - ( LPARAM ) ( page->writable - ? TEXT( "Y" ) : TEXT( "N" ) ) ); - - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_MAP11 + ( row * 4 ) + 3, - WM_SETTEXT, (WPARAM) 0, - ( LPARAM ) ( page->contended - ? TEXT( "Y" ) : TEXT( "N" ) ) ); - row++; - - source = page->source; - page_num = page->page_num; - writable = page->writable; - contended = page->contended; - offset = page->offset; - } - - /* We expect the next page to have an increased offset */ - offset += MEMORY_PAGE_SIZE; - } - - /* Hide unused rows */ - for( i = row; i < 8; i++ ) { - for( j = 0; j < 4; j++ ) { - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_MAP11 + ( i * 4 ) + j, - WM_SETTEXT, (WPARAM) 0, (LPARAM) NULL ); - } - } - -} - -static void -update_breakpoints( void ) -{ - /* FIXME: review this function for unicode compatibility */ - TCHAR buffer[ 1024 ], - *breakpoint_text[6] = { &buffer[ 0], &buffer[ 40], &buffer[80], - &buffer[120], &buffer[160], &buffer[200] }; - GSList *ptr; - TCHAR format_string[ 1024 ]; - - LV_ITEM lvi; - lvi.mask = LVIF_TEXT; - int i; - - /* Create the breakpoint list */ - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_BPS, - LVM_DELETEALLITEMS, 0, 0 ); - - for( ptr = debugger_breakpoints; ptr; ptr = ptr->next ) { - - debugger_breakpoint *bp = ptr->data; - - _sntprintf( breakpoint_text[0], 40, "%lu", (unsigned long)bp->id ); - _sntprintf( breakpoint_text[1], 40, "%s", - debugger_breakpoint_type_text[ bp->type ] ); - - switch( bp->type ) { - - case DEBUGGER_BREAKPOINT_TYPE_EXECUTE: - case DEBUGGER_BREAKPOINT_TYPE_READ: - case DEBUGGER_BREAKPOINT_TYPE_WRITE: - if( bp->value.address.source == memory_source_any ) { - _sntprintf( breakpoint_text[2], 40, format_16_bit(), - bp->value.address.offset ); - } else { - snprintf( format_string, 1024, "%%s:%s:%s", - format_16_bit(), format_16_bit() ); - snprintf( breakpoint_text[2], 40, format_string, - memory_source_description( bp->value.address.source ), - bp->value.address.page, bp->value.address.offset ); - } - break; - - case DEBUGGER_BREAKPOINT_TYPE_PORT_READ: - case DEBUGGER_BREAKPOINT_TYPE_PORT_WRITE: - _stprintf( format_string, "%s:%s", format_16_bit(), format_16_bit() ); - _sntprintf( breakpoint_text[2], 40, format_string, - bp->value.port.mask, bp->value.port.port ); - break; - - case DEBUGGER_BREAKPOINT_TYPE_TIME: - _sntprintf( breakpoint_text[2], 40, "%5d", bp->value.time.tstates ); - break; - - case DEBUGGER_BREAKPOINT_TYPE_EVENT: - _sntprintf( breakpoint_text[2], 40, "%s:%s", bp->value.event.type, - bp->value.event.detail ); - - } - - _sntprintf( breakpoint_text[3], 40, "%lu", (unsigned long)bp->ignore ); - _sntprintf( breakpoint_text[4], 40, "%s", - debugger_breakpoint_life_text[ bp->life ] ); - if( bp->condition ) { - debugger_expression_deparse( breakpoint_text[5], 80, bp->condition ); - } else { - _tcscpy( breakpoint_text[5], "" ); - } - - /* get the count of items to insert as last element */ - lvi.iItem = SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_BPS, - LVM_GETITEMCOUNT, 0, 0 ); - - /* append the breakpoint items */ - for( i = 0; i < 6; i++ ) { - lvi.iSubItem = i; - lvi.pszText = breakpoint_text[i]; - if( i == 0 ) - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_BPS, LVM_INSERTITEM, 0, - ( LPARAM ) &lvi ); - else - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_BPS, LVM_SETITEM, 0, - ( LPARAM ) &lvi ); - } - } -} - -static void -update_disassembly( void ) -{ - size_t i, length; libspectrum_word address; - TCHAR buffer[80]; - TCHAR *disassembly_text[2] = { &buffer[0], &buffer[40] }; - - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_PC, - LVM_DELETEALLITEMS, 0, 0 ); - - LV_ITEM lvi; - lvi.mask = LVIF_TEXT; - - for( i = 0, address = disassembly_top; i < disassembly_page; i++ ) { - int l; - _sntprintf( disassembly_text[0], 40, format_16_bit(), address ); - debugger_disassemble( disassembly_text[1], 40, &length, address ); - - /* pad to 16 characters (long instruction) to avoid varying width */ - l = _tcslen( disassembly_text[1] ); - while( l < 16 ) disassembly_text[1][l++] = ' '; - disassembly_text[1][l] = 0; - - address += length; - - /* append the item */ - lvi.iItem = i; - lvi.iSubItem = 0; - lvi.pszText = disassembly_text[0]; - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_PC, LVM_INSERTITEM, 0, - ( LPARAM ) &lvi ); - lvi.iSubItem = 1; - lvi.pszText = disassembly_text[1]; - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_PC, LVM_SETITEM, 0, - ( LPARAM ) &lvi ); - } - - disassembly_bottom = address; -} - -static void -update_events( void ) -{ - /* clear the listview */ - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_EVENTS, - LVM_DELETEALLITEMS, 0, 0 ); - - event_foreach( add_event, NULL ); -} - -static void -add_event( gpointer data, gpointer user_data GCC_UNUSED ) -{ - event_t *ptr = data; - - TCHAR buffer[80]; - TCHAR *event_text[2] = { &buffer[0], &buffer[40] }; - - LV_ITEM lvi; - lvi.mask = LVIF_TEXT; - - /* Skip events which have been removed */ - if( ptr->type == event_type_null ) return; - - _sntprintf( event_text[0], 40, "%d", ptr->tstates ); - /* FIXME: event_name() is not unicode compliant */ - _tcsncpy( event_text[1], event_name( ptr->type ), 40 ); - event_text[1][39] = '\0'; - - /* append the item */ - lvi.iItem = SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_EVENTS, - LVM_GETITEMCOUNT, 0, 0 ); - lvi.iSubItem = 0; - lvi.pszText = event_text[0]; - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_EVENTS, LVM_INSERTITEM, 0, - ( LPARAM ) &lvi ); - lvi.iSubItem = 1; - lvi.pszText = event_text[1]; - SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_LV_EVENTS, LVM_SETITEM, 0, - ( LPARAM ) &lvi ); -} - -static int -deactivate_debugger( void ) -{ - PostMessage( fuse_hWnd, WM_USER_EXIT_PROCESS_MESSAGES, 0, 0 ); - debugger_active = 0; - fuse_emulation_unpause(); - return 0; -} - -/* Set the disassembly to start at 'address' */ -int -ui_debugger_disassemble( libspectrum_word address ) -{ - /* Note: the scroll bar can not cope with "upper bound - page_size" value and - higher. PC register, key and wheel scrolling are fine with that */ - SCROLLINFO si; - si.cbSize = sizeof(si); - si.fMask = SIF_POS; - si.nPos = disassembly_top = address; - SetScrollInfo( GetDlgItem( fuse_hDBGWnd, IDC_DBG_SB_PC ), - SB_CTL, &si, TRUE ); - - /* And update the disassembly if the debugger is active */ - if( debugger_active ) update_disassembly(); - - return 0; -} - -/* Called when the disassembly scrollbar is moved */ -static int -move_disassembly( WPARAM scroll_command ) -{ - libspectrum_word address; - int cursor_row; - - /* in Windows we have to read the command and scroll the scrollbar manually */ - switch( LOWORD( scroll_command ) ) { - case SB_BOTTOM: - if( disassembly_bottom == disassembly_min ) return 0; - address = debugger_search_instruction( disassembly_min, - -disassembly_page ); - break; - case SB_TOP: - if( disassembly_top == disassembly_min ) return 0; - address = disassembly_min; - break; - case SB_LINEDOWN: - if( disassembly_bottom == disassembly_min ) return 0; - address = debugger_search_instruction( disassembly_top, 1 ); - break; - case SB_LINEUP: - if( disassembly_top == disassembly_min ) return 0; - address = debugger_search_instruction( disassembly_top, -1); - break; - case SB_PAGEUP: - address = debugger_search_instruction( disassembly_top, - -disassembly_page ); - break; - case SB_PAGEDOWN: - address = debugger_search_instruction( disassembly_top, - disassembly_page ); - break; - case SB_THUMBPOSITION: - case SB_THUMBTRACK: - /* just set disassembly_top to that value */ - address = HIWORD( scroll_command ); - - /* The scrollbar should constrain to min/max values */ - if( address > disassembly_max - disassembly_page ) - address = debugger_search_instruction( disassembly_min, - -disassembly_page ); - break; - default: - return 1; - } - - /* Get selected row */ - cursor_row = ListView_GetNextItem( GetDlgItem( fuse_hDBGWnd, IDC_DBG_LV_PC ), - -1, LVNI_SELECTED ); - - /* Scroll to new position */ - ui_debugger_disassemble( address ); - - /* Mark selected row */ - if( cursor_row >= 0 ) { - ListView_SetItemState( GetDlgItem( fuse_hDBGWnd, IDC_DBG_LV_PC ), - cursor_row, LVIS_FOCUSED|LVIS_SELECTED, - LVIS_FOCUSED|LVIS_SELECTED ); - } - - return 0; -} - -/* Evaluate the command currently in the entry box */ -static void -evaluate_command( void ) -{ - TCHAR *buffer; - int buffer_size; - - /* poll the size of the value in Evaluate text box first */ - buffer_size = SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_ED_EVAL, WM_GETTEXTLENGTH, - (WPARAM) 0, (LPARAM) 0 ); - buffer = malloc( ( buffer_size + 1 ) * sizeof( TCHAR ) ); - if( buffer == NULL ) { - ui_error( UI_ERROR_ERROR, "Out of memory in %s.", __func__ ); - return; - } - - /* get the value in Evaluate text box first */ - if( SendDlgItemMessage( fuse_hDBGWnd, IDC_DBG_ED_EVAL, WM_GETTEXT, - (WPARAM) ( buffer_size + 1 ), - (LPARAM) buffer ) != buffer_size ) { - ui_error( UI_ERROR_ERROR, - "Couldn't get the content of the Evaluate text box" ); - return; - } - - /* FIXME: need to convert from TCHAR to char to comply with unicode */ - debugger_command_evaluate( buffer ); - - free( buffer ); -} - -static void -win32ui_debugger_done_step( void ) -{ - debugger_step(); -} - -static void -win32ui_debugger_done_continue( void ) -{ - debugger_run(); -} - -static void -win32ui_debugger_break( void ) -{ - debugger_mode = DEBUGGER_MODE_HALTED; - - EnableWindow( GetDlgItem( fuse_hDBGWnd, IDC_DBG_BTN_CONT ), TRUE); - EnableWindow( GetDlgItem( fuse_hDBGWnd, IDC_DBG_BTN_BREAK ), FALSE ); -} - -static void -delete_dialog( void ) -{ - win32ui_debugger_done_close(); -} - -static void -win32ui_debugger_done_close( void ) -{ - ShowWindow( fuse_hDBGWnd, SW_HIDE ); - win32ui_debugger_done_continue(); -} - -static INT_PTR CALLBACK -win32ui_debugger_proc( HWND hWnd GCC_UNUSED, UINT msg, - WPARAM wParam, LPARAM lParam ) -{ - switch( msg ) { - case WM_COMMAND: - switch( LOWORD( wParam ) ) { - case IDCLOSE: - case IDCANCEL: - win32ui_debugger_done_close(); - return 0; - case IDC_DBG_BTN_CONT: - win32ui_debugger_done_continue(); - return 0; - case IDC_DBG_BTN_BREAK: - win32ui_debugger_break(); - return 0; - case IDC_DBG_BTN_STEP: - win32ui_debugger_done_step(); - return 0; - case IDC_DBG_BTN_EVAL: - evaluate_command(); - return 0; - - /* menus */ - case IDM_DBG_REG: - toggle_display( DEBUGGER_PANE_REGISTERS, IDM_DBG_REG ); - return 0; - case IDM_DBG_MEMMAP: - toggle_display( DEBUGGER_PANE_MEMORYMAP, IDM_DBG_MEMMAP ); - return 0; - case IDM_DBG_BPS: - toggle_display( DEBUGGER_PANE_BREAKPOINTS, IDM_DBG_BPS ); - return 0; - case IDM_DBG_DIS: - toggle_display( DEBUGGER_PANE_DISASSEMBLY, IDM_DBG_DIS ); - return 0; - case IDM_DBG_STACK: - toggle_display( DEBUGGER_PANE_STACK, IDM_DBG_STACK ); - return 0; - case IDM_DBG_EVENTS: - toggle_display( DEBUGGER_PANE_EVENTS, IDM_DBG_EVENTS ); - return 0; - } - break; - - case WM_CLOSE: - delete_dialog(); - return 0; - - case WM_NOTIFY: - switch ( ( ( LPNMHDR ) lParam )->code ) { - - case NM_DBLCLK: - switch( ( ( LPNMHDR ) lParam)->idFrom ) { - - case IDC_DBG_LV_EVENTS: - events_click( ( LPNMITEMACTIVATE ) lParam ); - return 0; - case IDC_DBG_LV_STACK: - stack_click( ( LPNMITEMACTIVATE ) lParam ); - return 0; - } - } - break; - - case WM_VSCROLL: - if( ( HWND ) lParam != NULL ) - if( ! move_disassembly( wParam ) ) - return 0; - break; - } - return FALSE; -} - -static LRESULT CALLBACK -disassembly_key_press( HWND hWnd, WPARAM wParam ) -{ - libspectrum_word initial_top, address; - int cursor_row; - - initial_top = disassembly_top; - - /* Get selected row */ - cursor_row = ListView_GetNextItem( hWnd, -1, LVNI_SELECTED ); - - switch( wParam ) { - case VK_DOWN: - if( cursor_row == disassembly_page - 1 ) { - address = debugger_search_instruction( disassembly_top, 1 ); - ui_debugger_disassemble( address ); - } - break; - - case VK_UP: - if( cursor_row == 0 ) { - address = debugger_search_instruction( disassembly_top, -1 ); - ui_debugger_disassemble( address ); - } - break; - - case VK_NEXT: - ui_debugger_disassemble( disassembly_bottom ); - break; - - case VK_PRIOR: - address = debugger_search_instruction( disassembly_top, - -disassembly_page ); - ui_debugger_disassemble( address ); - break; - - case VK_HOME: - cursor_row = 0; - ui_debugger_disassemble( disassembly_min ); - break; - - case VK_END: - cursor_row = disassembly_page - 1; - address = debugger_search_instruction( disassembly_min, - -disassembly_page ); - ui_debugger_disassemble( address ); - break; - } - - if( initial_top != disassembly_top ) { - /* Mark selected row */ - if( cursor_row >= 0 ) { - ListView_SetItemState( hWnd, cursor_row, LVIS_FOCUSED|LVIS_SELECTED, - LVIS_FOCUSED|LVIS_SELECTED ); - } - return TRUE; - } - - return FALSE; -} - -static LRESULT CALLBACK -disassembly_wheel_scroll( HWND hWnd, WPARAM wParam ) -{ - libspectrum_word address; - int cursor_row; - short delta; - - /* Get selected row */ - cursor_row = ListView_GetNextItem( hWnd, -1, LVNI_SELECTED ); - - /* Convert wheel displacement to instruction displacement */ - delta = (short) HIWORD( wParam ) / WHEEL_DELTA; - - /* Scroll to new position */ - address = debugger_search_instruction( disassembly_top, -delta ); - ui_debugger_disassemble( address ); - - /* Mark selected row */ - if( cursor_row >= 0 ) { - ListView_SetItemState( hWnd, cursor_row, LVIS_FOCUSED|LVIS_SELECTED, - LVIS_FOCUSED|LVIS_SELECTED ); - } - - return TRUE; -} - -static LRESULT CALLBACK -disassembly_listview_proc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) -{ - WNDPROC orig_proc; - - switch( msg ) { - case WM_DESTROY: - orig_proc = (WNDPROC) GetProp( hWnd, "original_proc" ); - SetWindowLongPtr( hWnd, GWLP_WNDPROC, (LONG_PTR) orig_proc ); - RemoveProp( hWnd, "original_proc" ); - break; - - case WM_KEYDOWN: - if( disassembly_key_press( hWnd, wParam ) ) return 0; - break; - - case WM_MOUSEWHEEL: - disassembly_wheel_scroll( hWnd, wParam ); - return 0; - } - - orig_proc = (WNDPROC) GetProp( hWnd, "original_proc" ); - return CallWindowProc( orig_proc, hWnd, msg, wParam, lParam ); -} diff --git a/fuse/ui/win32/debugger.h b/fuse/ui/win32/debugger.h deleted file mode 100644 index 2a75fcc..0000000 --- a/fuse/ui/win32/debugger.h +++ /dev/null @@ -1,107 +0,0 @@ -/* debugger.h: the Win32 debugger - Copyright (c) 2004 Marek Januszewski - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -/* FIXME: http://msdn.microsoft.com/en-us/library/t2zechd4%28v=VS.80%29.aspx */ - -#define IDD_DBG 2000 -#define IDC_DBG_LV_PC ( IDD_DBG + 1 ) -#define IDC_DBG_SB_PC ( IDD_DBG + 2 ) -#define IDC_DBG_LV_STACK ( IDD_DBG + 3 ) -#define IDC_DBG_LV_EVENTS ( IDD_DBG + 4 ) -#define IDC_DBG_LV_BPS ( IDD_DBG + 5 ) -#define IDC_DBG_ED_EVAL ( IDD_DBG + 6 ) -#define IDC_DBG_BTN_EVAL ( IDD_DBG + 7 ) -#define IDC_DBG_GRP_MEMMAP ( IDD_DBG + 8 ) -#define IDC_DBG_BTN_STEP ( IDD_DBG + 9 ) -#define IDC_DBG_BTN_CONT ( IDD_DBG + 10 ) -#define IDC_DBG_BTN_BREAK ( IDD_DBG + 11 ) - -#define IDC_DBG_MAP11 ( IDD_DBG + 12 ) -#define IDC_DBG_MAP12 ( IDC_DBG_MAP11 + 1 ) -#define IDC_DBG_MAP13 ( IDC_DBG_MAP12 + 1 ) -#define IDC_DBG_MAP14 ( IDC_DBG_MAP13 + 1 ) -#define IDC_DBG_MAP21 ( IDC_DBG_MAP14 + 1 ) -#define IDC_DBG_MAP22 ( IDC_DBG_MAP21 + 1 ) -#define IDC_DBG_MAP23 ( IDC_DBG_MAP22 + 1 ) -#define IDC_DBG_MAP24 ( IDC_DBG_MAP23 + 1 ) -#define IDC_DBG_MAP31 ( IDC_DBG_MAP24 + 1 ) -#define IDC_DBG_MAP32 ( IDC_DBG_MAP31 + 1 ) -#define IDC_DBG_MAP33 ( IDC_DBG_MAP32 + 1 ) -#define IDC_DBG_MAP34 ( IDC_DBG_MAP33 + 1 ) -#define IDC_DBG_MAP41 ( IDC_DBG_MAP34 + 1 ) -#define IDC_DBG_MAP42 ( IDC_DBG_MAP41 + 1 ) -#define IDC_DBG_MAP43 ( IDC_DBG_MAP42 + 1 ) -#define IDC_DBG_MAP44 ( IDC_DBG_MAP43 + 1 ) -#define IDC_DBG_MAP51 ( IDC_DBG_MAP44 + 1 ) -#define IDC_DBG_MAP52 ( IDC_DBG_MAP51 + 1 ) -#define IDC_DBG_MAP53 ( IDC_DBG_MAP52 + 1 ) -#define IDC_DBG_MAP54 ( IDC_DBG_MAP53 + 1 ) -#define IDC_DBG_MAP61 ( IDC_DBG_MAP54 + 1 ) -#define IDC_DBG_MAP62 ( IDC_DBG_MAP61 + 1 ) -#define IDC_DBG_MAP63 ( IDC_DBG_MAP62 + 1 ) -#define IDC_DBG_MAP64 ( IDC_DBG_MAP63 + 1 ) -#define IDC_DBG_MAP71 ( IDC_DBG_MAP64 + 1 ) -#define IDC_DBG_MAP72 ( IDC_DBG_MAP71 + 1 ) -#define IDC_DBG_MAP73 ( IDC_DBG_MAP72 + 1 ) -#define IDC_DBG_MAP74 ( IDC_DBG_MAP73 + 1 ) -#define IDC_DBG_MAP81 ( IDC_DBG_MAP74 + 1 ) -#define IDC_DBG_MAP82 ( IDC_DBG_MAP81 + 1 ) -#define IDC_DBG_MAP83 ( IDC_DBG_MAP82 + 1 ) -#define IDC_DBG_MAP84 ( IDC_DBG_MAP83 + 1 ) - -#define IDC_DBG_TEXT_ADDRESS ( IDC_DBG_MAP84 + 1 ) -#define IDC_DBG_TEXT_SOURCE ( IDC_DBG_MAP84 + 2 ) -#define IDC_DBG_TEXT_WRITABLE ( IDC_DBG_MAP84 + 3 ) -#define IDC_DBG_TEXT_CONTENDED ( IDC_DBG_MAP84 + 4 ) - -#define IDC_DBG_REG_PC ( IDC_DBG_TEXT_CONTENDED + 1 ) -#define IDC_DBG_REG_SP ( IDC_DBG_REG_PC + 1 ) -#define IDC_DBG_REG_AF ( IDC_DBG_REG_SP + 1 ) -#define IDC_DBG_REG_AF_ ( IDC_DBG_REG_AF + 1 ) -#define IDC_DBG_REG_BC ( IDC_DBG_REG_AF_ + 1 ) -#define IDC_DBG_REG_BC_ ( IDC_DBG_REG_BC + 1 ) -#define IDC_DBG_REG_DE ( IDC_DBG_REG_BC_ + 1 ) -#define IDC_DBG_REG_DE_ ( IDC_DBG_REG_DE + 1 ) -#define IDC_DBG_REG_HL ( IDC_DBG_REG_DE_ + 1 ) -#define IDC_DBG_REG_HL_ ( IDC_DBG_REG_HL + 1 ) -#define IDC_DBG_REG_IX ( IDC_DBG_REG_HL_ + 1 ) -#define IDC_DBG_REG_IY ( IDC_DBG_REG_IX + 1 ) -#define IDC_DBG_REG_I ( IDC_DBG_REG_IY + 1 ) -#define IDC_DBG_REG_R ( IDC_DBG_REG_I + 1 ) -#define IDC_DBG_REG_HALTED ( IDC_DBG_REG_R + 1 ) -#define IDC_DBG_REG_T_STATES ( IDC_DBG_REG_HALTED + 1 ) -#define IDC_DBG_REG_FLAGS ( IDC_DBG_REG_T_STATES + 1 ) -#define IDC_DBG_REG_ULA ( IDC_DBG_REG_FLAGS + 1 ) -#define IDC_DBG_REG_IM ( IDC_DBG_REG_ULA + 1 ) - -#define NUM_DBG_REGS ( IDC_DBG_REG_IM - IDC_DBG_REG_PC + 1 ) - -#define IDM_DBG_MENU ( IDC_DBG_REG_PC + NUM_DBG_REGS ) -#define IDM_DBG_VIEW ( IDM_DBG_MENU + 1 ) -#define IDM_DBG_REG ( IDM_DBG_VIEW + 1 ) -#define IDM_DBG_MEMMAP ( IDM_DBG_REG + 1 ) -#define IDM_DBG_BPS ( IDM_DBG_MEMMAP + 1 ) -#define IDM_DBG_DIS ( IDM_DBG_BPS + 1 ) -#define IDM_DBG_STACK ( IDM_DBG_DIS + 1 ) -#define IDM_DBG_EVENTS ( IDM_DBG_STACK + 1 ) diff --git a/fuse/ui/win32/debugger.rc b/fuse/ui/win32/debugger.rc deleted file mode 100644 index afd58c3..0000000 --- a/fuse/ui/win32/debugger.rc +++ /dev/null @@ -1,132 +0,0 @@ -/* debugger.rc: the Win32 debugger - Copyright (c) 2004 Marek Januszewski - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include "debugger.h" - -IDD_DBG DIALOGEX DISCARDABLE 6, 5, 555, 279 -CAPTION "Fuse - Debugger" -FONT 8,"MS Sans Serif" -MENU IDM_MENU -STYLE WS_POPUP | WS_CAPTION | WS_VISIBLE | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -BEGIN - CONTROL "", IDC_DBG_LV_PC, "SysListView32", \ - WS_CHILD | WS_VISIBLE | LVS_REPORT | \ - LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSCROLL, \ - 238, 3, 133, 240, WS_EX_CLIENTEDGE - SCROLLBAR IDC_DBG_SB_PC, 370, 3, 12, 240, WS_CHILD | SBS_VERT - CONTROL "", IDC_DBG_LV_STACK, "SysListView32", - WS_CHILD | WS_VISIBLE | LVS_REPORT | \ - LVS_SINGLESEL | LVS_SHOWSELALWAYS, \ - 384, 3, 86, 240, WS_EX_CLIENTEDGE - CONTROL "", IDC_DBG_LV_EVENTS, "SysListView32", \ - WS_CHILD | WS_VISIBLE | LVS_REPORT | \ - LVS_SINGLESEL | LVS_SHOWSELALWAYS, \ - 472, 3, 81, 240, WS_EX_CLIENTEDGE - CONTROL "", IDC_DBG_LV_BPS, "SysListView32", - WS_CHILD | WS_VISIBLE | LVS_REPORT | \ - LVS_SINGLESEL | LVS_SHOWSELALWAYS, \ - 2, 147, 234, 96, WS_EX_CLIENTEDGE - EDITTEXT IDC_DBG_ED_EVAL, 2, 245, 513, 14, \ - WS_CHILD | WS_VISIBLE, WS_EX_CLIENTEDGE - - DEFPUSHBUTTON "&Evaluate", IDC_DBG_BTN_EVAL, 517, 245, 36, 14 - PUSHBUTTON "&Single Step", IDC_DBG_BTN_STEP, 323, 260, 56, 14 - PUSHBUTTON "&Continue", IDC_DBG_BTN_CONT, 381, 260, 56, 14 - PUSHBUTTON "&Break", IDC_DBG_BTN_BREAK, 439, 260, 56, 14 - PUSHBUTTON "&Close", IDCLOSE, 497, 260, 56, 14 - - GROUPBOX "Memory Map", IDC_DBG_GRP_MEMMAP, 114, 3, 122, 142 - - CTEXT "0x0038", IDC_DBG_MAP11, 120, 27, 24, 9 - CTEXT "RAM 0", IDC_DBG_MAP12, 148, 27, 55, 9 - CTEXT "Y", IDC_DBG_MAP13, 206, 27, 11, 9 - CTEXT "N", IDC_DBG_MAP14, 219, 27, 11, 9 - CTEXT "0x0038", IDC_DBG_MAP21, 120, 40, 24, 9 - CTEXT "RAM 0", IDC_DBG_MAP22, 148, 40, 55, 9 - CTEXT "Y", IDC_DBG_MAP23, 206, 40, 11, 9 - CTEXT "N", IDC_DBG_MAP24, 219, 40, 11, 9 - CTEXT "0x0038", IDC_DBG_MAP31, 120, 53, 24, 9 - CTEXT "RAM 2", IDC_DBG_MAP32, 148, 53, 55, 9 - CTEXT "Y", IDC_DBG_MAP33, 206, 53, 11, 9 - CTEXT "N", IDC_DBG_MAP34, 219, 53, 11, 9 - CTEXT "0x0038", IDC_DBG_MAP41, 120, 66, 24, 9 - CTEXT "RAM 2", IDC_DBG_MAP42, 148, 66, 55, 9 - CTEXT "Y", IDC_DBG_MAP43, 206, 66, 11, 9 - CTEXT "N", IDC_DBG_MAP44, 219, 66, 11, 9 - CTEXT "0x0038", IDC_DBG_MAP51, 120, 79, 24, 9 - CTEXT "RAM 5", IDC_DBG_MAP52, 148, 79, 55, 9 - CTEXT "Y", IDC_DBG_MAP53, 206, 79, 11, 9 - CTEXT "Y", IDC_DBG_MAP54, 219, 79, 11, 9 - CTEXT "0x0038", IDC_DBG_MAP61, 120, 92, 24, 9 - CTEXT "RAM 5", IDC_DBG_MAP62, 148, 92, 55, 9 - CTEXT "Y", IDC_DBG_MAP63, 206, 92, 11, 9 - CTEXT "Y", IDC_DBG_MAP64, 219, 92, 11, 9 - CTEXT "0x0038", IDC_DBG_MAP71, 120, 105, 24, 9 - CTEXT "RAM 0", IDC_DBG_MAP72, 148, 105, 55, 9 - CTEXT "N", IDC_DBG_MAP73, 206, 105, 11, 9 - CTEXT "N", IDC_DBG_MAP74, 219, 105, 11, 9 - CTEXT "0x0000", IDC_DBG_MAP81, 120, 118, 24, 9 - CTEXT "RAM 0", IDC_DBG_MAP82, 148, 118, 55, 9 - CTEXT "N", IDC_DBG_MAP83, 206, 118, 11, 9 - CTEXT "N", IDC_DBG_MAP84, 219, 118, 11, 9 - - CTEXT "Address", IDC_DBG_TEXT_ADDRESS, 118, 14, 28, 9 - CTEXT "Source", IDC_DBG_TEXT_SOURCE, 148, 14, 55, 9 - CTEXT "W?", IDC_DBG_TEXT_WRITABLE, 206, 14, 11, 9 - CTEXT "C?", IDC_DBG_TEXT_CONTENDED, 219, 14, 11, 9 - - RTEXT "PC", IDC_DBG_REG_PC, 2, 5, 52, 9 - RTEXT "SP", IDC_DBG_REG_SP, 58, 5, 52, 9 - RTEXT "AF", IDC_DBG_REG_AF, 2, 14, 52, 9 - RTEXT "AF'", IDC_DBG_REG_AF_, 58, 14, 52, 9 - RTEXT "BC", IDC_DBG_REG_BC, 2, 23, 52, 9 - RTEXT "BC'", IDC_DBG_REG_BC_, 58, 23, 52, 9 - RTEXT "DE", IDC_DBG_REG_DE, 2, 32, 52, 9 - RTEXT "DE'", IDC_DBG_REG_DE_, 58, 32, 52, 9 - RTEXT "HL", IDC_DBG_REG_HL, 2, 41, 52, 9 - RTEXT "HL'", IDC_DBG_REG_HL_, 58, 41, 52, 9 - RTEXT "IX", IDC_DBG_REG_IX, 2, 50, 52, 9 - RTEXT "IY", IDC_DBG_REG_IY, 58, 50, 52, 9 - RTEXT "I", IDC_DBG_REG_I, 2, 59, 52, 9 - RTEXT "R", IDC_DBG_REG_R, 58, 59, 52, 9 - LTEXT "T-states", IDC_DBG_REG_T_STATES, 2, 77, 68, 9 - LTEXT "Halted", IDC_DBG_REG_HALTED, 2, 86, 52, 9 - EDITTEXT IDC_DBG_REG_IM, 68, 68, 42, 27, NOT WS_BORDER | ES_RIGHT | ES_MULTILINE | ES_READONLY - EDITTEXT IDC_DBG_REG_FLAGS, 2, 95, 52, 18, NOT WS_BORDER | ES_RIGHT | ES_MULTILINE | ES_READONLY - EDITTEXT IDC_DBG_REG_ULA, 58, 95, 52, 48, NOT WS_BORDER | ES_RIGHT | ES_MULTILINE | ES_READONLY -END - -IDM_MENU MENU -BEGIN - POPUP "&View" - BEGIN - MENUITEM "&Registers", IDM_DBG_REG - MENUITEM "&Memory Map", IDM_DBG_MEMMAP - MENUITEM "&Breakpoints", IDM_DBG_BPS - MENUITEM "&Disassembly", IDM_DBG_DIS - MENUITEM "&Stack", IDM_DBG_STACK - MENUITEM "&Events", IDM_DBG_EVENTS - END -END diff --git a/fuse/ui/win32/fileselector.c b/fuse/ui/win32/fileselector.c deleted file mode 100644 index db8469f..0000000 --- a/fuse/ui/win32/fileselector.c +++ /dev/null @@ -1,143 +0,0 @@ -/* fileselector.c: Win32 fileselector routines - Copyright (c) 2008 Marek Januszewski - Copyright (c) 2016 Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include - -#include "utils.h" -#include "win32internals.h" - -/* FIXME: remember the last directory when opening/saving -static char *current_folder; -*/ - -/* TODO: poll libspectrum for supported file extensions and avoid duplication - between UIs */ -static LPCTSTR file_filter = TEXT( -"Supported Files\0" -"*.mgtsnp;*.slt;*.sna;*.snapshot;*.snp;*.sp;*.szx;*.z80;*.zx-state;" -"*.csw;*.ltp;*.pzx;*.raw;*.spc;*.sta;*.tzx;*.tap;*.wav;" -"*.d40;*.d80;*.dsk;*.fdi;*.img;*.mgt;*.opd;*.opu;*.sad;*.scl;*.td0;*.trd;*.udi;" -"*.dck;*.rom;*.hdf;*.mdr;*.fmf;*.rzx;" -"*.bin;*.log;*.mlt;*.png;*.pok;*.scr;*.svg" -#ifdef LIBSPECTRUM_SUPPORTS_ZLIB_COMPRESSION -";*.gz;*.zip" -#endif -#ifdef LIBSPECTRUM_SUPPORTS_BZ2_COMPRESSION -";*.bz2" -#endif -"\0" -"All Files (*.*)\0" -"*.*\0" -"Auxiliary Files (*.scr;*.mlt;*.pok;*.png;*.svg;...)\0" -"*.bin;*.log;*.mlt;*.png;*.pok;*.scr;*.svg\0" -#ifdef LIBSPECTRUM_SUPPORTS_ZLIB_COMPRESSION -"Compressed files (*.gz;*.zip;...)\0" -"*.gz;*.zip" -#ifdef LIBSPECTRUM_SUPPORTS_BZ2_COMPRESSION -";*.bz2" -#endif -"\0" -#endif -"Disk Files (*.dsk;*.udi;*.scl;*.trd;*.fdi;...)\0" -"*.d40;*.d80;*.dsk;*.fdi;*.img;*.mgt;*.opd;*.opu;*.sad;*.scl;*.td0;*.trd;*.udi\0" -"Dock Files (*.dck;*.rom)\0" -"*.dck;*.rom\0" -"Harddisk Files (*.hdf)\0" -"*.hdf\0" -"Microdrive Files (*.mdr)\0" -"*.mdr\0" -"Movie Files (*.fmf)\0" -"*.fmf\0" -"Recording Files (*.rzx)\0" -"*.rzx\0" -"Snapshot Files (*.szx;*.z80;*.sna;...)\0" -"*.mgtsnp;*.slt;*.sna;*.snapshot;*.snp;*.sp;*.szx;*.z80;*.zx-state\0" -"Tape Files (*.tap;*.tzx;*.pzx;*.wav;*.csw;...)\0" -"*.csw;*.ltp;*.pzx;*.raw;*.spc;*.sta;*.tzx;*.tap;*.wav\0" -"\0" ); - -static DWORD filter_index = 0; - -static char* -run_dialog( const char *title, int is_saving ) -{ - OPENFILENAME ofn; - char szFile[512]; - int result; - - memset( &ofn, 0, sizeof( ofn ) ); - szFile[0] = '\0'; - - ofn.lStructSize = sizeof( ofn ); - ofn.hwndOwner = fuse_hWnd; - ofn.lpstrFilter = file_filter; - ofn.lpstrCustomFilter = NULL; - /* TODO: select filter based on UI operation (snapshot, recording, screenshot) */ - /* TODO: custom filter based file action (open, save) */ - ofn.nFilterIndex = filter_index; - ofn.lpstrFile = szFile; - ofn.nMaxFile = sizeof( szFile ); - ofn.lpstrFileTitle = NULL; - ofn.lpstrInitialDir = NULL; - ofn.lpstrTitle = title; - ofn.Flags = /* OFN_DONTADDTORECENT | */ OFN_PATHMUSTEXIST | OFN_HIDEREADONLY; - if( is_saving ) { - ofn.Flags |= OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN; - } else { - ofn.Flags |= OFN_FILEMUSTEXIST; - } - ofn.nFileOffset = 0; - ofn.nFileExtension = 0; - ofn.lpstrDefExt = NULL; -/* ofn.pvReserved = NULL; */ -/* ofn.FlagsEx = 0; */ - - if( is_saving ) { - result = GetSaveFileName( &ofn ); - } else { - result = GetOpenFileName( &ofn ); - } - - filter_index = ofn.nFilterIndex; - - if( !result ) { - return NULL; - } else { - return utils_safe_strdup( ofn.lpstrFile ); - } -} - -char* -ui_get_open_filename( const char *title ) -{ - return run_dialog( title, 0 ); -} - -char* -ui_get_save_filename( const char *title ) -{ - return run_dialog( title, 1 ); -} diff --git a/fuse/ui/win32/hyperlinks.c b/fuse/ui/win32/hyperlinks.c deleted file mode 100644 index a0bd5d6..0000000 --- a/fuse/ui/win32/hyperlinks.c +++ /dev/null @@ -1,170 +0,0 @@ -/* hyperlinks.c: hyperlink control - Copyright 2002 Neal Stublen - - Taken (almost) verbatim from public domain code found on CodeGuru: - http://www.codeguru.com/cpp/controls/staticctrl/article.php/c5803 - Copyright 2002 Neal Stublen - All rights reserved. - - The CodeGuru license is a bit vague, but they state: - "While we are talking about copyrights, you retain copyright of your - article and code, but by submitting it to CodeGuru you give permission - to use it in a fair manner and also permit all developers to freely use - the code in their own applications -even if they are commercial." - License: CodeGuru-specific, 2009 - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include "hyperlinks.h" - -#define PROP_ORIGINAL_FONT TEXT("_Hyperlink_Original_Font_") -#define PROP_ORIGINAL_PROC TEXT("_Hyperlink_Original_Proc_") -#define PROP_STATIC_HYPERLINK TEXT("_Hyperlink_From_Static_") -#define PROP_UNDERLINE_FONT TEXT("_Hyperlink_Underline_Font_") - - -LRESULT CALLBACK -_HyperlinkParentProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - WNDPROC pfnOrigProc = (WNDPROC) GetProp(hwnd, PROP_ORIGINAL_PROC); - - switch (message) { - case WM_CTLCOLORSTATIC: - { - HDC hdc = (HDC) wParam; - HWND hwndCtl = (HWND) lParam; - - BOOL fHyperlink = (NULL != GetProp(hwndCtl, PROP_STATIC_HYPERLINK)); - if (fHyperlink) { - LRESULT lr = CallWindowProc(pfnOrigProc, hwnd, message, wParam, lParam); - SetTextColor(hdc, RGB(0, 0, 192)); - return lr; - } - break; - } - case WM_DESTROY: - { - SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) pfnOrigProc); - RemoveProp(hwnd, PROP_ORIGINAL_PROC); - break; - } - } - return CallWindowProc(pfnOrigProc, hwnd, message, wParam, lParam); -} - -LRESULT CALLBACK -_HyperlinkProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - WNDPROC pfnOrigProc = (WNDPROC) GetProp(hwnd, PROP_ORIGINAL_PROC); - - switch (message) { - case WM_DESTROY: - { - SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) pfnOrigProc); - RemoveProp(hwnd, PROP_ORIGINAL_PROC); - - HFONT hOrigFont = (HFONT) GetProp(hwnd, PROP_ORIGINAL_FONT); - SendMessage(hwnd, WM_SETFONT, (WPARAM) hOrigFont, 0); - RemoveProp(hwnd, PROP_ORIGINAL_FONT); - - HFONT hFont = (HFONT) GetProp(hwnd, PROP_UNDERLINE_FONT); - DeleteObject(hFont); - RemoveProp(hwnd, PROP_UNDERLINE_FONT); - - RemoveProp(hwnd, PROP_STATIC_HYPERLINK); - - break; - } - case WM_MOUSEMOVE: - { - if (GetCapture() != hwnd) { - HFONT hFont = (HFONT) GetProp(hwnd, PROP_UNDERLINE_FONT); - SendMessage(hwnd, WM_SETFONT, (WPARAM) hFont, FALSE); - InvalidateRect(hwnd, NULL, FALSE); - SetCapture(hwnd); - } else { - RECT rect; - GetWindowRect(hwnd, &rect); - - POINT pt = {LOWORD(lParam), HIWORD(lParam)}; - ClientToScreen(hwnd, &pt); - - if (!PtInRect(&rect, pt)) { - HFONT hFont = (HFONT) GetProp(hwnd, PROP_ORIGINAL_FONT); - SendMessage(hwnd, WM_SETFONT, (WPARAM) hFont, FALSE); - InvalidateRect(hwnd, NULL, FALSE); - ReleaseCapture(); - } - } - break; - } - case WM_SETCURSOR: - { - /* Since IDC_HAND is not available on all operating systems, we will - load the arrow cursor if IDC_HAND is not present. */ - HCURSOR hCursor = LoadCursor(NULL, IDC_HAND); - if (NULL == hCursor) { - hCursor = LoadCursor(NULL, IDC_ARROW); - } - SetCursor(hCursor); - return TRUE; - } - } - - return CallWindowProc(pfnOrigProc, hwnd, message, wParam, lParam); -} - -BOOL -ConvertStaticToHyperlink(HWND hwndCtl) -{ - /* Subclass the parent so we can color the controls as we desire. */ - - HWND hwndParent = GetParent(hwndCtl); - if (NULL != hwndParent) { - WNDPROC pfnOrigProc = (WNDPROC) GetWindowLongPtr(hwndParent, GWLP_WNDPROC); - if (pfnOrigProc != _HyperlinkParentProc) { - SetProp(hwndParent, PROP_ORIGINAL_PROC, (HANDLE) pfnOrigProc); - SetWindowLongPtr(hwndParent, GWLP_WNDPROC, (LONG_PTR) (WNDPROC) _HyperlinkParentProc); - } - } - /* Make sure the control will send notifications. */ - - DWORD dwStyle = GetWindowLong(hwndCtl, GWL_STYLE); - SetWindowLong(hwndCtl, GWL_STYLE, dwStyle | SS_NOTIFY); - - /* Subclass the existing control. */ - - WNDPROC pfnOrigProc = (WNDPROC) GetWindowLongPtr(hwndCtl, GWLP_WNDPROC); - SetProp(hwndCtl, PROP_ORIGINAL_PROC, (HANDLE) pfnOrigProc); - SetWindowLongPtr(hwndCtl, GWLP_WNDPROC, (LONG_PTR) (WNDPROC) _HyperlinkProc); - - /* Create an updated font by adding an underline. */ - - HFONT hOrigFont = (HFONT) SendMessage(hwndCtl, WM_GETFONT, 0, 0); - SetProp(hwndCtl, PROP_ORIGINAL_FONT, (HANDLE) hOrigFont); - - LOGFONT lf; - GetObject(hOrigFont, sizeof(lf), &lf); - lf.lfUnderline = TRUE; - - HFONT hFont = CreateFontIndirect(&lf); - SetProp(hwndCtl, PROP_UNDERLINE_FONT, (HANDLE) hFont); - - /* Set a flag on the control so we know what color it should be. */ - - SetProp(hwndCtl, PROP_STATIC_HYPERLINK, (HANDLE) 1); - - return TRUE; -} - -BOOL -ConvertCtlStaticToHyperlink(HWND hwndParent, UINT uiCtlId) -{ - return ConvertStaticToHyperlink(GetDlgItem(hwndParent, uiCtlId)); -} diff --git a/fuse/ui/win32/hyperlinks.h b/fuse/ui/win32/hyperlinks.h deleted file mode 100644 index 8c25099..0000000 --- a/fuse/ui/win32/hyperlinks.h +++ /dev/null @@ -1,28 +0,0 @@ -/* hyperlinks.h: hyperlink control - Copyright 2002 Neal Stublen - - Taken (almost) verbatim from public domain code found on CodeGuru: - http://www.codeguru.com/cpp/controls/staticctrl/article.php/c5803 - Copyright 2002 Neal Stublen - All rights reserved. - - The CodeGuru license is a bit vague, but they state: - "While we are talking about copyrights, you retain copyright of your - article and code, but by submitting it to CodeGuru you give permission - to use it in a fair manner and also permit all developers to freely use - the code in their own applications -even if they are commercial." - License: CodeGuru-specific, 2009 - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#ifndef FUSE_HYPERLINKS_H -#define FUSE_HYPERLINKS_H - -BOOL ConvertStaticToHyperlink( HWND hwndCtl ); -BOOL ConvertCtlStaticToHyperlink( HWND hwndParent, UINT uiCtlId ); - -#endif /* #ifndef FUSE_HYPERLINKS_H */ diff --git a/fuse/ui/win32/icons/disk_active.bmp b/fuse/ui/win32/icons/disk_active.bmp deleted file mode 100644 index ac3d411710546e1907eba37b268dc6e287e89efd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1014 zcmZXR!A%4~35 y=3}VGnzm7#3QqqJ5v+>Qy#{m-ES=2myjw4G4QF}Xo5JnxYYsxmZ0bI diff --git a/fuse/ui/win32/icons/mouse_inactive.bmp b/fuse/ui/win32/icons/mouse_inactive.bmp deleted file mode 100644 index 9ac15b7b70ca12cf9eb24d15aa7c9e5108c82f93..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 978 zcmZ?ry~NA_24+A~1Bm&6SQLmE86FQVJBnP=q1?Q~*;> zidqyiaByJe;*drW9tmn8k%OPa77p-ufioaMH%!#R0|YriVDlSL9-0IAbO2><{9 diff --git a/fuse/ui/win32/icons/pause_active.bmp b/fuse/ui/win32/icons/pause_active.bmp deleted file mode 100644 index 5aa2e78f30d497400c3558c17a6ace30bf1a6d78..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1986 zcmb`F!41MN3`Na}36MB(W&#G_&Sp%-2nZpB7>3_`VmXe}1ZYK4Cvl#?e>t8mYe~-m z^B!Y|vB6l$7PH9tbDkDUO?Q#2$a5*&hx1BQfcd*EiC3xy3#oUa6+a-p>mnRbo(*Q% zPEgB5%d;`Aw;!9xICQa2<4&9HL@S_{^1UbHH_(h$wn42T@7OFGhn?C4#*fU2-gP>6 zLbfxo_0@Bot|w52YWj77=M}4%|KCbZ*F|kCtMPAbCTc@(YhX38c%`YRfcyxI94$zlIO?9 diff --git a/fuse/ui/win32/icons/pause_inactive.bmp b/fuse/ui/win32/icons/pause_inactive.bmp deleted file mode 100644 index 20a435b694949df4ec08d9432e484e98c9d658c1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1986 zcmb`F%Mrpb3`E0;3Yg)@rbJsn$^UtEqG>&86_wzir!EKafSwQ783`09SsSFyaH=>EJkY02V4v?pV zUA7UFb5ZkjjO%&4PLw$5qEC~ZJllvSz)ShwllmKIhLv^TRfHX#rQ>9$Izi%TngYqc zeY)%<*~Y-!R}WQ+oxI%69$+3p)(DBHHlXbC#9RXkRVf+5Q zd<4qzbX&Vo2kM@+V{KR~x1~CFnfl{lD)&U*`{Y!*HB)ez3?az8=@vqDN;tyQS-LSs zJ(g_nD^vW2IX8U7&SMxR1U$7e&lTqNdxHNr=D9}ZD`s=@GlA^;ei#NSBW>F@O+yuN zqg|Z%Q*4%r4bNi~SoU4ly?L)s(-psBvrNqiRdX69_tGuQ$rEvwOB2c_o6~q|k3VGs aug#P7!$I<&*Y}cKF0R@4(qdXVNX{qFH@!Uo diff --git a/fuse/ui/win32/icons/tape_marker.bmp b/fuse/ui/win32/icons/tape_marker.bmp deleted file mode 100644 index ad0716513da5b8c9d582d1b1d5650daa677401b0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 438 zcmZ?r-NwiO24+A~1Bf|*SOAC_86H4wu3dhe%-+Csh#WJ4`JQFQbX0g#$zuE{JRnvLIX>O%NiEDF_q+0Q25ZhX4Qo diff --git a/fuse/ui/win32/icons/tape_marker_mask.bmp b/fuse/ui/win32/icons/tape_marker_mask.bmp deleted file mode 100644 index f619de9ebf0f1dbd9589e9ee86b3f2eb0757b41e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 126 zcmZ?rtz&=yJ0PV2#2i2@0K|+yhz^*50w4?m|NsAIs8_aQum@s!AfNxH7y~ - -#include -#include -#include - -#include "compat.h" -#include "fuse.h" -#include "memory_pages.h" -#include "win32internals.h" - -#include "memorybrowser.h" - -static INT_PTR CALLBACK -memorybrowser_proc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ); - -static LRESULT CALLBACK -memory_listview_proc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); - -static void -memorybrowser_init( HWND hwndDlg ); - -void -menu_machine_memorybrowser( int action ); - -/* helper constants for memory listview's scrollbar */ -static const int memorysb_min = 0x0000; -static const int memorysb_max = 0x10000; -static const int memorysb_step = 0x10; - -/* Visual styles could change visible rows */ -static int memorysb_page_inc = 0xa0; -static int memorysb_page_size = 0x140; -static int memorysb_page_rows = 20; - -/* Address of first visible row */ -static libspectrum_word memaddr = 0x0000; - -static void -update_display( HWND hwndDlg, libspectrum_word base ) -{ - int i, j; - - TCHAR buffer[ 8 + 64 + 20 ]; - TCHAR *text[] = { &buffer[0], &buffer[ 8 ], &buffer[ 8 + 64 ] }; - TCHAR buffer2[ 8 ]; - - memaddr = base; - - SendDlgItemMessage( hwndDlg, IDC_MEM_LV, LVM_DELETEALLITEMS, 0, 0 ); - - LV_ITEM lvi; - lvi.mask = LVIF_TEXT; - - for( i = 0; i < memorysb_page_rows; i++ ) { - _sntprintf( text[0], 8, TEXT( "%04X" ), base ); - - text[1][0] = '\0'; - for( j = 0; j < memorysb_step; j++, base++ ) { - - libspectrum_byte b = readbyte_internal( base ); - - _sntprintf( buffer2, 4, TEXT( "%02X " ), b ); - _tcsncat( text[1], buffer2, 64 - _tcslen( text[1] ) - 1 ); - - text[2][j] = ( b >= 32 && b < 127 ) ? b : '.'; - } - text[2][ 0x10 ] = '\0'; - - /* append the item */ - lvi.iItem = SendDlgItemMessage( hwndDlg, IDC_MEM_LV, - LVM_GETITEMCOUNT, 0, 0 ); - lvi.iSubItem = 0; - lvi.pszText = text[0]; - SendDlgItemMessage( hwndDlg, IDC_MEM_LV, LVM_INSERTITEM, 0, - ( LPARAM ) &lvi ); - lvi.iSubItem = 1; - lvi.pszText = text[1]; - SendDlgItemMessage( hwndDlg, IDC_MEM_LV, LVM_SETITEM, 0, - ( LPARAM ) &lvi ); - lvi.iSubItem = 2; - lvi.pszText = text[2]; - SendDlgItemMessage( hwndDlg, IDC_MEM_LV, LVM_SETITEM, 0, - ( LPARAM ) &lvi ); - } -} - -static int -scroller( HWND hwndDlg, WPARAM scroll_command ) -{ - libspectrum_word base; - SCROLLINFO si; - - memset( &si, 0, sizeof( si ) ); - si.cbSize = sizeof(si); - si.fMask = SIF_POS; - GetScrollInfo( GetDlgItem( hwndDlg, IDC_MEM_SB ), SB_CTL, &si ); - - int value = si.nPos; - int selected = 0; - - /* in Windows we have to read the command and scroll the scrollbar manually */ - switch( LOWORD( scroll_command ) ) { - case SB_BOTTOM: - value = memorysb_max; - selected = memorysb_page_rows - 1; - break; - case SB_TOP: - value = memorysb_min; - break; - case SB_LINEDOWN: - value += memorysb_step; - selected = 1; - break; - case SB_LINEUP: - value -= memorysb_step; - break; - case SB_PAGEUP: - value -= memorysb_page_inc; - break; - case SB_PAGEDOWN: - value += memorysb_page_inc; - selected = memorysb_page_rows - 1; - break; - case SB_THUMBPOSITION: - case SB_THUMBTRACK: - value = HIWORD( scroll_command ); - break; - default: - return 1; - } - - if( value > memorysb_max - memorysb_page_size ) - value = memorysb_max - memorysb_page_size; - if( value < memorysb_min ) value = memorysb_min; - - /* Drop the low bits before displaying anything */ - base = value; base &= 0xfff0; - - if( base != memaddr ) { - /* set the new scrollbar position */ - memset( &si, 0, sizeof(si) ); - si.cbSize = sizeof(si); - si.fMask = SIF_POS; - si.nPos = base; - SetScrollInfo( GetDlgItem( hwndDlg, IDC_MEM_SB ), SB_CTL, &si, TRUE ); - - update_display( hwndDlg, base ); - } - - /* Select row according to last scroll command */ - ListView_SetItemState( GetDlgItem( hwndDlg, IDC_MEM_LV ), selected, - LVIS_SELECTED, LVIS_SELECTED ); - - return 0; -} - -void -menu_machine_memorybrowser( int action GCC_UNUSED ) -{ - fuse_emulation_pause(); - - DialogBox( fuse_hInstance, MAKEINTRESOURCE( IDD_MEM ), - fuse_hWnd, (DLGPROC) memorybrowser_proc ); - - fuse_emulation_unpause(); - return; -} - -static INT_PTR CALLBACK -memorybrowser_proc( HWND hwndDlg, UINT uMsg, WPARAM wParam, - LPARAM lParam GCC_UNUSED ) -{ - switch( uMsg ) - { - case WM_INITDIALOG: - memorybrowser_init( hwndDlg ); - return TRUE; - - case WM_COMMAND: - if( LOWORD( wParam ) == IDCLOSE || - LOWORD( wParam ) == IDCANCEL ) { - EndDialog( hwndDlg, 0 ); - return TRUE; - } - break; - - case WM_CLOSE: { - EndDialog( hwndDlg, 0 ); - return TRUE; - } - - case WM_VSCROLL: - /* Accept vertical scroll from listview too */ - scroller( hwndDlg, wParam ); - return TRUE; - - case WM_MOUSEWHEEL: - { - /* get current position */ - SCROLLINFO si; - memset( &si, 0, sizeof(si) ); - si.cbSize = sizeof(si); - si.fMask = SIF_POS; - GetScrollInfo( GetDlgItem( hwndDlg, IDC_MEM_SB ), SB_CTL, &si ); - - /* convert delta displacement to memory displacement */ - short delta = (short) HIWORD( wParam ) / WHEEL_DELTA; - int value = si.nPos - delta * memorysb_step; - if( value > memorysb_max - memorysb_page_size ) - value = memorysb_max - memorysb_page_size; - if( value < memorysb_min ) value = memorysb_min; - - /* scroll to new position */ - scroller( hwndDlg, MAKEWPARAM( SB_THUMBPOSITION, value ) ); - return TRUE; - } - } - - return FALSE; -} - -static LRESULT CALLBACK -memory_listview_proc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) -{ - switch( msg ) { - - case WM_DESTROY: - { - WNDPROC orig_proc = (WNDPROC) GetProp( hWnd, "original_proc" ); - SetWindowLongPtr( hWnd, GWLP_WNDPROC, (LONG_PTR) orig_proc ); - RemoveProp( hWnd, "original_proc" ); - break; - } - - case WM_KEYDOWN: - { - WORD scroll_notify = 0xffff; - - switch( wParam ) - { - case VK_UP: - scroll_notify = SB_LINEUP; - break; - - case VK_PRIOR: - scroll_notify = SB_PAGEUP; - break; - - case VK_NEXT: - scroll_notify = SB_PAGEDOWN; - break; - - case VK_DOWN: - scroll_notify = SB_LINEDOWN; - break; - - case VK_HOME: - scroll_notify = SB_TOP; - break; - - case VK_END: - scroll_notify = SB_BOTTOM; - break; - } - - /* Inform parent window about key scrolling */ - if( scroll_notify != 0xffff ) { - SendMessage( GetParent( hWnd ), WM_VSCROLL, - MAKEWPARAM( scroll_notify, 0 ), (LPARAM) NULL ); - return 0; - } - - break; - } - - case WM_MOUSEWHEEL: - { - /* Inform parent window about mouse scrolling */ - SendMessage( GetParent( hWnd ), WM_MOUSEWHEEL, wParam, lParam ); - return 0; - } - - } - - WNDPROC orig_proc = (WNDPROC) GetProp( hWnd, "original_proc" ); - return CallWindowProc( orig_proc, hWnd, msg, wParam, lParam ); -} - -static void -memorybrowser_init( HWND hwndDlg ) -{ - size_t i; - int error; - HFONT font; - - const TCHAR *titles[] = { "Address", "Hex", "Data" }; - int column_widths[] = { 62, 348, 124 }; - - error = win32ui_get_monospaced_font( &font ); if( error ) return; - - /* subclass listview to catch keydown and mousewheel messages */ - HWND hwnd_list = GetDlgItem( hwndDlg, IDC_MEM_LV ); - WNDPROC orig_proc = (WNDPROC) GetWindowLongPtr( hwnd_list, GWLP_WNDPROC ); - SetProp( hwnd_list, "original_proc", (HANDLE) orig_proc ); - SetWindowLongPtr( hwnd_list, GWLP_WNDPROC, - (LONG_PTR) (WNDPROC) memory_listview_proc ); - - /* set extended listview style to select full row, when an item is selected */ - DWORD lv_ext_style; - lv_ext_style = SendDlgItemMessage( hwndDlg, IDC_MEM_LV, - LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0 ); - lv_ext_style |= LVS_EX_FULLROWSELECT; - lv_ext_style |= LVS_EX_DOUBLEBUFFER; - SendDlgItemMessage( hwndDlg, IDC_MEM_LV, - LVM_SETEXTENDEDLISTVIEWSTYLE, 0, lv_ext_style ); - - /* create columns */ - LVCOLUMN lvc; - lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT ; - lvc.fmt = LVCFMT_LEFT; - - for( i = 0; i < 3; i++ ) { - if( i != 0 ) - lvc.mask |= LVCF_SUBITEM; - lvc.cx = column_widths[i]; - lvc.pszText = (TCHAR *)titles[i]; - SendDlgItemMessage( hwndDlg, IDC_MEM_LV, LVM_INSERTCOLUMN, i, - ( LPARAM ) &lvc ); - } - - /* set font of the listview to monospaced one */ - SendDlgItemMessage( hwndDlg, IDC_MEM_LV , WM_SETFONT, - (WPARAM) font, FALSE ); - - /* Recalculate visible rows, Visual Styles could change rows height */ - memorysb_page_rows = SendDlgItemMessage( hwndDlg, IDC_MEM_LV, - LVM_GETCOUNTPERPAGE, 0, 0 ); - memorysb_page_size = memorysb_page_rows * memorysb_step; - memorysb_page_inc = memorysb_page_size / 2; - - /* set the scrollbar parameters */ - SCROLLINFO si; - si.cbSize = sizeof(si); - si.fMask = SIF_POS | SIF_RANGE | SIF_PAGE; - si.nPos = memaddr; - si.nMin = memorysb_min; - si.nMax = memorysb_max; - si.nPage = memorysb_page_size; - SetScrollInfo( GetDlgItem( hwndDlg, IDC_MEM_SB ), SB_CTL, &si, TRUE ); - - update_display( hwndDlg, memaddr ); - - /* Recalculate columns width, high DPI resolutions have larger sizes */ - ListView_SetColumnWidth( hwnd_list, 0, LVSCW_AUTOSIZE_USEHEADER ); - ListView_SetColumnWidth( hwnd_list, 1, LVSCW_AUTOSIZE ); - ListView_SetColumnWidth( hwnd_list, 2, LVSCW_AUTOSIZE_USEHEADER ); -} diff --git a/fuse/ui/win32/memorybrowser.h b/fuse/ui/win32/memorybrowser.h deleted file mode 100644 index a44eedb..0000000 --- a/fuse/ui/win32/memorybrowser.h +++ /dev/null @@ -1,26 +0,0 @@ -/* memorybrowser.h: the Win32 memory browser - Copyright (c) 2008 Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#define IDD_MEM 4000 -#define IDC_MEM_LV 4001 -#define IDC_MEM_SB 4002 diff --git a/fuse/ui/win32/memorybrowser.rc b/fuse/ui/win32/memorybrowser.rc deleted file mode 100644 index 55c7e9c..0000000 --- a/fuse/ui/win32/memorybrowser.rc +++ /dev/null @@ -1,38 +0,0 @@ -/* memorybrowser.rc: the Win32 memory browser - Copyright (c) 2008 Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include "memorybrowser.h" - -IDD_MEM DIALOGEX DISCARDABLE 0,0,371,264 -CAPTION "Fuse - Memory Browser" -FONT 8,"MS Sans Serif" -STYLE WS_POPUP | WS_CAPTION | WS_VISIBLE | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -BEGIN - CONTROL "", IDC_MEM_LV, "SysListView32", \ - WS_CHILD | WS_TABSTOP | WS_VISIBLE | LVS_REPORT | \ - LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSCROLL, \ - 0,0,360,240, WS_EX_CLIENTEDGE - SCROLLBAR IDC_MEM_SB, 360,0,11,240, WS_CHILD | SBS_VERT - PUSHBUTTON "&Close", IDCLOSE, 315,245,51,14 -END diff --git a/fuse/ui/win32/options-header.pl b/fuse/ui/win32/options-header.pl deleted file mode 100755 index 52e44d2..0000000 --- a/fuse/ui/win32/options-header.pl +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/perl -w - -# options-header.pl: generate options dialog boxes - -# Copyright (c) 2001-2007 Philip Kendall, Stuart Brady, Marek Januszewski - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Author contact information: - -# E-mail: philip-fuse@shadowmagic.org.uk - -use strict; - -use Fuse; -use Fuse::Dialog; - -die "No data file specified" unless @ARGV; - -my @dialogs = Fuse::Dialog::read( shift @ARGV ); -my $internal = 1; - -$internal = 0 if( @ARGV && shift( @ARGV ) eq 'public' ); - -if( $internal ) { - print Fuse::GPL( 'options_internals.h: options dialog boxes', - '2001-2002 Philip Kendall' ); -} else { - print Fuse::GPL( 'options.h: options dialog boxes public declarations', - '2001-2002 Philip Kendall' ); -} -print <<"CODE"; - -/* This file is autogenerated from options.dat by options-header.pl. - Do not edit unless you know what you\'re doing! */ - -CODE - -if( $internal ) { - print << "CODE"; -#ifndef FUSE_WIN32OPTIONS_INTERNALS_H -#define FUSE_WIN32OPTIONS_INTERNALS_H - -CODE -} else { - print << "CODE"; -#ifndef FUSE_OPTIONS_H -#define FUSE_OPTIONS_H - -CODE -} - -if( $internal ) { - my $optnum = 3000; - - foreach( @dialogs ) { - - my $optname = uc( "OPT_$_->{name}" ); - printf "#define IDD_%s %s\n", $optname, $optnum++; - - foreach my $widget ( @{ $_->{widgets} } ) { - - if( $widget->{type} eq "Checkbox" ) { - printf "#define IDC_%s_%s %s\n", - $optname, uc( $widget->{value} ), $optnum++; - } elsif( $widget->{type} eq "Entry" ) { - printf "#define IDC_%s_%s %s\n", - $optname, uc( $widget->{value} ), $optnum++; - printf "#define IDC_%s_LABEL_%s %s\n", - $optname, uc( $widget->{value} ), $optnum++; - } elsif( $widget->{type} eq "Combo" ) { - printf "#define IDC_%s_%s %s\n", - $optname, uc( $widget->{value} ), $optnum++; - printf "#define IDC_%s_LABEL_%s %s\n", - $optname, uc( $widget->{value} ), $optnum++; - } else { - die "Unknown type '$widget->{type}'"; - } - - } - } -} else { - foreach( @dialogs ) { - foreach my $widget ( @{ $_->{widgets} } ) { - if( $widget->{type} eq "Combo" ) { - print <<"CODE"; -int option_enumerate_$_->{name}_$widget->{value}( void ); - -CODE - } - } - } -} - -if( $internal ) { - print << "CODE"; -#endif /* #ifndef FUSE_WIN32OPTIONS_INTERNALS_H */ -CODE -} else { - print << "CODE"; -#endif /* #ifndef FUSE_OPTIONS_H */ -CODE -} - diff --git a/fuse/ui/win32/options-resource.pl b/fuse/ui/win32/options-resource.pl deleted file mode 100755 index 8f714b4..0000000 --- a/fuse/ui/win32/options-resource.pl +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/perl -w - -# options-resource.pl: generate options dialog boxes - -# Copyright (c) 2001-2007 Philip Kendall, Stuart Brady, Marek Januszewski -# Copyright (c) 2015 Sergio Baldoví - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Author contact information: - -# E-mail: philip-fuse@shadowmagic.org.uk - -use strict; - -use Fuse; -use Fuse::Dialog; - -die "No data file specified" unless @ARGV; - -my @dialogs = Fuse::Dialog::read( shift @ARGV ); - -print Fuse::GPL( 'options.rc: options dialog boxes', - '2001-2007 Philip Kendall, Stuart Brady' ) . << "CODE"; - -/* This file is autogenerated from options.dat by options-resource.pl. - Do not edit unless you know what you\'re doing! */ - -#include "options_internals.h" -CODE - -foreach( @dialogs ) { - - my $buffer = ""; # needed because we find out the height at the end at the end - my $optname = uc( "OPT_$_->{name}" ); - my $y = 5; - my $y_label = $y; - - foreach my $widget ( @{ $_->{widgets} } ) { - - my $text = $widget->{text}; $text =~ s/\((.)\)/&$1/; - if( $widget->{type} eq "Checkbox" ) { - $buffer .= sprintf " AUTOCHECKBOX \"%s\",IDC_%s_%s,5,$y,160,11\n", - $text, $optname, uc( $widget->{value}, ); - $y += 12; - } elsif( $widget->{type} eq "Entry" ) { - $y_label = $y + 2; - $buffer .= sprintf " LTEXT \"%s\",IDC_%s_LABEL_%s,5,$y_label,90,9\n", - $text, $optname, uc( $widget->{value} ); - $buffer .= sprintf " EDITTEXT IDC_%s_%s,100,$y,85,13,ES_NUMBER\n", - $optname, uc( $widget->{value} ); - $y += 14; - } elsif( $widget->{type} eq "Combo" ) { - $y_label = $y + 2; - $buffer .= sprintf " LTEXT \"%s\",IDC_%s_LABEL_%s,5,$y_label,90,9\n", - $text, $optname, uc( $widget->{value} ); - $buffer .= sprintf " COMBOBOX IDC_%s_%s,100,$y,85,90," - . "CBS_DROPDOWNLIST | CBS_HASSTRINGS\n", - $optname, uc( $widget->{value} ); - $y += 14; - } else { - die "Unknown type '$widget->{type}'"; - } - - } - - $y += 5; - - $buffer .= sprintf " DEFPUSHBUTTON \"OK\",IDOK,45,$y,50,14\n"; - $buffer .= sprintf " PUSHBUTTON \"Cancel\",IDCANCEL,100,$y,50,14\n"; - - $y += 14 + 5; #height of the buttons + 5 margin - - print << "CODE"; - -IDD_$optname DIALOGEX 6,5,190,$y - CAPTION "Fuse - $_->{title}" - FONT 8,"Ms Shell Dlg 2",400,0,1 - STYLE WS_POPUP | WS_CAPTION | WS_BORDER | WS_SYSMENU - EXSTYLE WS_EX_APPWINDOW -BEGIN -CODE - - print $buffer; - - print "END\n"; - printf "\n"; -} diff --git a/fuse/ui/win32/options.pl b/fuse/ui/win32/options.pl deleted file mode 100755 index 22ed934..0000000 --- a/fuse/ui/win32/options.pl +++ /dev/null @@ -1,343 +0,0 @@ -#!/usr/bin/perl -w - -# options.pl: generate options dialog boxes - -# Copyright (c) 2001-2015 Philip Kendall, Marek Januszewski, Stuart Brady - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Author contact information: - -# E-mail: philip-fuse@shadowmagic.org.uk - -use strict; - -use Fuse; -use Fuse::Dialog; - -die "No data file specified" unless @ARGV; -my %combo_sets; -my %combo_default; - -my @dialogs = Fuse::Dialog::read( shift @ARGV ); - -print Fuse::GPL( 'options.c: options dialog boxes', - '2001-2013 Philip Kendall, Marek Januszewski, Stuart Brady' ) . << "CODE"; - -/* This file is autogenerated from options.dat by options.pl. - Do not edit unless you know what you\'re doing! */ - -#include - -#ifdef UI_WIN32 /* Use this file if we're using WIN32 */ - -#include - -#include "display.h" -#include "fuse.h" -#include "options.h" -#include "options_internals.h" -#include "periph.h" -#include "settings.h" -#include "ui/win32/win32internals.h" -#include "utils.h" - -static int -option_enumerate_combo( const char * const *options, char *value, int count, - int def ) { - int i; - if( value != NULL ) { - for( i = 0; i < count; i++) { - if( !strcmp( value, options[ i ] ) ) - return i; - } - } - return def; -} - -CODE - -foreach( @dialogs ) { - - foreach my $widget ( @{ $_->{widgets} } ) { - - foreach my $type ( $widget->{type} ) { - - my $text = $widget->{text}; $text =~ tr/()//d; - - if( $type eq "Combo" ) { - my $n = 0; - - foreach( split( /\|/, $widget->{data1} ) ) { - if( /^\*/ ) { - $combo_default{$widget->{value}} = $n; - } - $n++; - } - $n = 0; - $widget->{data1} =~ s/^\*//; - $widget->{data1} =~ s/\|\*/|/; - if( not exists( $combo_sets{$widget->{data1}} ) ) { - $combo_sets{$widget->{data1}} = "$_->{name}_$widget->{value}_combo"; - - print << "CODE"; - -static const char * const $_->{name}_$widget->{value}_combo[] = { -CODE - foreach( split( /\|/, $widget->{data1} ) ) { - print << "CODE"; - "$_", -CODE - $n++; - } - print << "CODE"; -}; - -static const int $_->{name}_$widget->{value}_combo_count = $n; - -CODE - } else { - print << "CODE"; -\#define $_->{name}_$widget->{value}_combo $combo_sets{$widget->{data1}} -\#define $_->{name}_$widget->{value}_combo_count $combo_sets{$widget->{data1}}_count - -CODE - } - print << "CODE"; -int -option_enumerate_$_->{name}_$widget->{value}( void ) { - return option_enumerate_combo( $_->{name}_$widget->{value}_combo, - settings_current.$widget->{value}, - $_->{name}_$widget->{value}_combo_count, - $combo_default{$widget->{value}} ); -} - -CODE - } - } - } - - my $idcname = uc( "IDC_OPT_$_->{name}" ); - my $optname = uc( "OPT_$_->{name}" ); - -print << "CODE"; -static void -menu_options_$_->{name}_init( HWND hwndDlg ) -{ - char buffer[80]; - int i; - - i = 0; - buffer[0] = '\\0'; - if( buffer[i] ) {}; /* Shut gcc up */ - -CODE - foreach my $widget ( @{ $_->{widgets} } ) { - my $type = $widget->{type}; - - if( $type eq "Checkbox" ) { - my $idcname = uc( "$widget->{value}" ); - print << "CODE"; - SendDlgItemMessage( hwndDlg, IDC_${optname}_${idcname}, BM_SETCHECK, - settings_current.$widget->{value} ? BST_CHECKED : BST_UNCHECKED, 0 ); - -CODE - } elsif( $widget->{type} eq "Entry" ) { - my $idcname = uc( "$widget->{value}" ); - print << "CODE"; - SendDlgItemMessage( hwndDlg, IDC_${optname}_${idcname}, EM_LIMITTEXT, - $widget->{data1}, 0 ); - /* FIXME This is asuming SendDlgItemMessage is not UNICODE */ - snprintf( buffer, 80, "%d", settings_current.$widget->{value} ); - SendDlgItemMessage( hwndDlg, IDC_${optname}_${idcname}, WM_SETTEXT, - 0, (LPARAM) buffer ); - -CODE - } elsif( $type eq "Combo" ) { - my $idcname = uc( "$widget->{value}" ); - print << "CODE"; - for( i = 0; i < $_->{name}_$widget->{value}_combo_count; i++ ) { - /* FIXME This is asuming SendDlgItemMessage is not UNICODE */ - SendDlgItemMessage( hwndDlg, IDC_${optname}_${idcname}, CB_ADDSTRING, - 0, (LPARAM) $_->{name}_$widget->{value}_combo[i] ); - } - SendDlgItemMessage( hwndDlg, IDC_${optname}_${idcname}, CB_SETCURSEL, - (LPARAM) $combo_default{$widget->{value}}, 0 ); - if( settings_current.$widget->{value} != NULL ) { - for( i = 0; i < $_->{name}_$widget->{value}_combo_count; i++ ) { - if( !strcmp( settings_current.$widget->{value}, - $_->{name}_$widget->{value}_combo[i] ) ) { - SendDlgItemMessage( hwndDlg, IDC_${optname}_${idcname}, - CB_SETCURSEL, i, 0 ); - } - } - } -CODE - } else { - die "Unknown type `$type'"; - } - } - -print << "CODE"; -} - -static void -menu_options_$_->{name}_done( HWND hwndDlg ) -{ - char buffer[80]; - - buffer[0] = '\\0'; - if( buffer[0] ) {}; /* Shut gcc up */ - -CODE - - if( $_->{postcheck} ) { - - print << "CODE"; - /* Get a copy of current settings */ - settings_info original_settings; - memset( &original_settings, 0, sizeof( settings_info ) ); - settings_copy( &original_settings, &settings_current ); - -CODE - - } - - foreach my $widget ( @{ $_->{widgets} } ) { - my $type = $widget->{type}; - - if( $type eq "Checkbox" ) { - my $idcname = uc( "$widget->{value}" ); - - print << "CODE"; - settings_current.$widget->{value} = - IsDlgButtonChecked( hwndDlg, IDC_${optname}_${idcname} ); - -CODE - } elsif( $widget->{type} eq "Entry" ) { - my $idcname = uc( "$widget->{value}" ); - print << "CODE"; - /* FIXME This is asuming SendDlgItemMessage is not UNICODE */ - SendDlgItemMessage( hwndDlg, IDC_${optname}_${idcname}, WM_GETTEXT, - 80, (LPARAM) buffer ); - settings_current.$widget->{value} = atoi( buffer ); - -CODE - } elsif( $widget->{type} eq "Combo" ) { - my $idcname = uc( "$widget->{value}" ); - print << "CODE"; - libspectrum_free( settings_current.$widget->{value} ); - settings_current.$widget->{value} = - utils_safe_strdup( $_->{name}_$widget->{value}_combo[ - SendDlgItemMessage( hwndDlg, IDC_${optname}_${idcname}, CB_GETCURSEL, 0, 0 ) ] ); - -CODE - } else { - die "Unknown type `$widget->{type}'"; - } - } - - if( $_->{postcheck} ) { - - print << "CODE"; - int needs_hard_reset = $_->{postcheck}(); - - /* Confirm reset */ - if( needs_hard_reset ) { - ShowWindow( hwndDlg, SW_HIDE ); - - if( !win32ui_confirm("Some options need to reset the machine. Reset?" ) ) { - /* Cancel new settings */ - settings_copy( &settings_current, &original_settings ); - settings_free( &original_settings ); - - ShowWindow( hwndDlg, SW_SHOW ); - return; - } - } - - settings_free( &original_settings ); - -CODE - } - - print " $_->{posthook}();\n\n" if $_->{posthook}; - - print << "CODE"; - win32statusbar_set_visibility( settings_current.statusbar ); - display_refresh_all(); - - EndDialog( hwndDlg, 0 ); -} - -static BOOL CALLBACK -menu_options_$_->{name}_proc( HWND hwndDlg, UINT msg, WPARAM wParam GCC_UNUSED, - LPARAM lParam GCC_UNUSED ) -{ - switch( msg ) - { - case WM_INITDIALOG: - { - /* FIXME: save the handle returned by LoadIcon() in win32ui.c */ - SendMessage( hwndDlg, WM_SETICON, ICON_SMALL, - (LPARAM)LoadIcon( fuse_hInstance, "win32_icon" ) ); - - /* initialize the controls with current settings */ - menu_options_$_->{name}_init( hwndDlg ); - - return TRUE; - } - - case WM_COMMAND: - switch( LOWORD( wParam ) ) - { - case IDOK: - /* Read the controls and apply the settings */ - menu_options_$_->{name}_done( hwndDlg ); - return 0; - - case IDCANCEL: - EndDialog( hwndDlg, 0 ); - return 0; - } - break; - - case WM_CLOSE: - EndDialog( hwndDlg, 0 ); - return 0; - } - - return FALSE; -} - -void -menu_options_$_->{name}( int action GCC_UNUSED ) -{ - fuse_emulation_pause(); - - DialogBox( fuse_hInstance, MAKEINTRESOURCE( IDD_$optname ), - fuse_hWnd, (DLGPROC) menu_options_$_->{name}_proc ); - - fuse_emulation_unpause(); -} - -CODE -} - - print << "CODE"; - -#endif /* #ifdef UI_WIN32 */ - -CODE diff --git a/fuse/ui/win32/picture.c b/fuse/ui/win32/picture.c deleted file mode 100755 index 1d4eaab..0000000 --- a/fuse/ui/win32/picture.c +++ /dev/null @@ -1,565 +0,0 @@ -/* picture.c: Win32 routines to draw the keyboard picture - Copyright (c) 2002-2019 Philip Kendall, Marek Januszewski, Stuart Brady, - Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include - -#ifdef USE_LIBPNG -#include -#include -#endif - -#include "display.h" -#include "picture.h" -#include "utils.h" -#include "win32internals.h" - -/* An RGB image of the keyboard picture */ -/* the memory will be allocated by Windows ( height * width * 4 bytes ) */ -static libspectrum_byte *picture; -static const int picture_pitch = DISPLAY_ASPECT_WIDTH * 4; - -static HWND hDialogPicture = NULL; -static HBITMAP picture_BMP = NULL; -static int min_height; -static int min_width; - -static HWND create_dialog( int width, int height ); - -static void draw_screen( libspectrum_byte *screen, int border ); - -static LRESULT WINAPI picture_wnd_proc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); - -#ifdef PNG_SIMPLIFIED_READ_SUPPORTED - -static void draw_png( libspectrum_byte *buffer, size_t size ); -static int read_png_file( const char *filename, png_bytep *buffer, - size_t *size, int *width, int *height ); - -#endif /* #ifdef PNG_SIMPLIFIED_READ_SUPPORTED */ - -int -win32ui_picture( const char *filename, win32ui_picture_format format ) -{ - /* Dialog already open? */ - if( hDialogPicture != NULL ) - return 0; - - switch( format ) { - - case PICTURE_PNG: - { - -#ifdef PNG_SIMPLIFIED_READ_SUPPORTED - int width, height; - png_bytep buffer; - size_t size; - - if( read_png_file( filename, &buffer, &size, &width, &height ) ) - return 1; - - hDialogPicture = create_dialog( width, height ); - if( hDialogPicture == NULL ) - return 1; - - draw_png( buffer, size ); - - free( buffer ); - break; -#else - /* PNG format not supported */ - return 1; -#endif /* #ifdef PNG_SIMPLIFIED_READ_SUPPORTED */ - } - - case PICTURE_SCR: - { - utils_file screen; - - if( utils_read_screen( filename, &screen ) ) - return 1; - - hDialogPicture = create_dialog( DISPLAY_ASPECT_WIDTH, - DISPLAY_SCREEN_HEIGHT ); - if( hDialogPicture == NULL ) - return 1; - - draw_screen( screen.buffer, 0 ); - - utils_close_file( &screen ); - break; - } - - default: - /* Unsupported format */ - return 1; - - } - - ShowWindow( hDialogPicture, SW_SHOW ); - - /* Keep focus on Fuse's main window */ - SetForegroundWindow( fuse_hWnd ); - - return 0; -} - -static void -resize_dialog( HWND dialog ) -{ - RECT wr_dialog, cr_dialog, wr_button, wr_frame, rc; - HWND button_hWnd, frame_hWnd; - - /* Dialog dimensions */ - GetWindowRect( dialog, &wr_dialog ); - GetClientRect( dialog, &cr_dialog ); - OffsetRect( &wr_dialog, -wr_dialog.left, -wr_dialog.top ); - OffsetRect( &cr_dialog, -cr_dialog.left, -cr_dialog.top ); - - /* Move Close button */ - SetRectEmpty( &rc ); - rc.top = 7; /* bottom spacing (DLUs) */ - MapDialogRect( dialog, &rc ); - - button_hWnd = GetDlgItem( dialog, IDCLOSE ); - GetWindowRect( button_hWnd, &wr_button ); - wr_button.left = ( cr_dialog.right - - ( wr_button.right - wr_button.left ) ) / 2; - wr_button.top = cr_dialog.bottom - ( wr_button.bottom - wr_button.top ) - - rc.top; - - SetWindowPos( button_hWnd, NULL, wr_button.left, wr_button.top, 0, 0, - SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); - - /* Give any unused space to picture frame */ - frame_hWnd = GetDlgItem( dialog, IDC_PICTURE_FRAME ); - SetRectEmpty( &rc ); - rc.bottom = 7 + 7; /* spacing above and below button (DLUs) */ - MapDialogRect( dialog, &rc ); - GetWindowRect( button_hWnd, &wr_button ); - rc.bottom += wr_button.bottom - wr_button.top; /* button height */ - wr_frame.bottom = cr_dialog.bottom - rc.bottom; - wr_frame.right = cr_dialog.right; - - SetWindowPos( frame_hWnd, NULL, 0, 0, wr_frame.right, wr_frame.bottom, - SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS ); -} - -static void -inflate_dialog( HWND dialog, int width, int height ) -{ - RECT wr_dialog, cr_dialog, wr_button, rc; - HWND button_hWnd; - - /* Dialog dimensions */ - GetWindowRect( dialog, &wr_dialog ); - GetClientRect( dialog, &cr_dialog ); - OffsetRect( &wr_dialog, -wr_dialog.left, -wr_dialog.top ); - OffsetRect( &cr_dialog, -cr_dialog.left, -cr_dialog.top ); - - /* Button dimensions */ - button_hWnd = GetDlgItem( dialog, IDCLOSE ); - GetWindowRect( button_hWnd, &wr_button ); - OffsetRect( &wr_button, -wr_button.left, -wr_button.top ); - - /* Button spacing */ - SetRectEmpty( &rc ); - rc.bottom = 7 + 7; /* top spacing + bottom spacing (DLUs) */ - rc.right = 7 + 7; /* left spacing + right spacing (DLUs) */ - MapDialogRect( dialog, &rc ); - rc.bottom += wr_button.bottom; /* pixels */ - rc.right += wr_button.right; /* pixels */ - - /* Image dimensions */ - rc.bottom += height; /* pixels */ - if( width > rc.right ) - rc.right = width; /* pixels */ - - /* Window decorations */ - rc.bottom += wr_dialog.bottom - cr_dialog.bottom; - rc.right += wr_dialog.right - cr_dialog.right; - - SetWindowPos( dialog, NULL, 0, 0, rc.right, rc.bottom, - SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE ); - - min_width = rc.right; - min_height = rc.bottom; - - resize_dialog( dialog ); -} - -static void -move_dialog( HWND dialog, HWND parent ) -{ - RECT rc_workarea, rc_parent, wr_dialog, rc; - int placed = 0; - - SystemParametersInfo( SPI_GETWORKAREA, 0, &rc_workarea, 0 ); - GetWindowRect( parent, &rc_parent ); - GetWindowRect( dialog, &wr_dialog ); - - /* Place centered below Fuse's main window */ - if( !placed ) { - CopyRect( &rc, &wr_dialog ); - OffsetRect( &rc, -rc.left, -rc.top ); - OffsetRect( &rc, -rc.right/2, 0 ); - OffsetRect( &rc, ( rc_parent.right - rc_parent.left ) / 2, 0 ); - OffsetRect( &rc, rc_parent.left, rc_parent.bottom ); - if( rc.left >= rc_workarea.left && rc.right <= rc_workarea.right && - rc.bottom <= rc_workarea.bottom ) - placed = 1; - } - - /* Place right to Fuse's main window */ - if( !placed ) { - CopyRect( &rc, &wr_dialog ); - OffsetRect( &rc, -rc.left, -rc.top ); - OffsetRect( &rc, rc_parent.right, rc_parent.top ); - if( rc.right <= rc_workarea.right && rc.bottom <= rc_workarea.bottom ) - placed = 1; - } - - /* Place left to Fuse's main window */ - if( !placed ) { - CopyRect( &rc, &wr_dialog ); - OffsetRect( &rc, -rc.left, -rc.top ); - OffsetRect( &rc, rc_parent.left - rc.right, rc_parent.top ); - if( rc.left >= rc_workarea.left && rc.bottom <= rc_workarea.bottom ) - placed = 1; - } - - /* Move the dialog or leave at initial position */ - if( placed ) { - SetWindowPos( dialog, NULL, rc.left, rc.top, 0, 0, - SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); - } -} - -static HWND -create_dialog( int width, int height ) -{ - HWND dialog; - - dialog = CreateDialog( fuse_hInstance, MAKEINTRESOURCE( IDD_PICTURE ), - fuse_hWnd, (DLGPROC)picture_wnd_proc ); - - if( dialog == NULL ) - return NULL; - - inflate_dialog( dialog, width, height ); - move_dialog( dialog, fuse_hWnd ); - - /* Create the picture buffer */ - BITMAPINFO picture_BMI; - memset( &picture_BMI, 0, sizeof( picture_BMI ) ); - picture_BMI.bmiHeader.biSize = sizeof( picture_BMI.bmiHeader ); - picture_BMI.bmiHeader.biWidth = width; - /* negative to avoid "shep-mode": */ - picture_BMI.bmiHeader.biHeight = -height; - picture_BMI.bmiHeader.biPlanes = 1; - picture_BMI.bmiHeader.biBitCount = 32; - picture_BMI.bmiHeader.biCompression = BI_RGB; - picture_BMI.bmiHeader.biSizeImage = 0; - picture_BMI.bmiHeader.biXPelsPerMeter = 0; - picture_BMI.bmiHeader.biYPelsPerMeter = 0; - picture_BMI.bmiHeader.biClrUsed = 0; - picture_BMI.bmiHeader.biClrImportant = 0; - picture_BMI.bmiColors[0].rgbRed = 0; - picture_BMI.bmiColors[0].rgbGreen = 0; - picture_BMI.bmiColors[0].rgbBlue = 0; - picture_BMI.bmiColors[0].rgbReserved = 0; - - HDC dc = GetDC( dialog ); - picture_BMP = CreateDIBSection( dc, &picture_BMI, DIB_RGB_COLORS, - (void **)&picture, NULL, 0 ); - ReleaseDC( dialog, dc ); - - return dialog; -} - -static void -destroy_dialog( void ) -{ - DestroyWindow( hDialogPicture ); - hDialogPicture = NULL; - - DeleteObject( picture_BMP ); - picture_BMP = NULL; -} - -static void -resizing_dialog( WPARAM wParam, LPARAM lParam ) -{ - RECT *rc; - int width, height; - - rc = (RECT *)lParam; - width = rc->right - rc->left; - height = rc->bottom - rc->top; - - /* Force dialog minimum size to fit original picture size */ - if( height < min_height ) { - if( wParam == WMSZ_TOP || wParam == WMSZ_TOPLEFT || - wParam == WMSZ_TOPRIGHT ) - rc->top = rc->bottom - min_height; - else - rc->bottom = rc->top + min_height; - } - - if( width < min_width ) { - if( wParam == WMSZ_LEFT || - wParam == WMSZ_TOPLEFT || - wParam == WMSZ_BOTTOMLEFT ) - rc->left = rc->right - min_width; - else - rc->right = rc->left + min_width; - } -} - -static int -draw_frame( LPDRAWITEMSTRUCT drawitem ) -{ - float scale_x, scale_y, scale_factor; - int offset_x, offset_y; - int scaled_width, scaled_height; - int allocation_width, allocation_height; - BITMAP bitmap_info; - RECT rc; - - if( !( drawitem->itemAction & ODA_DRAWENTIRE ) ) - return FALSE; - - HDC pic_dc = CreateCompatibleDC( drawitem->hDC ); - HBITMAP old_bmp = SelectObject( pic_dc, picture_BMP ); - GetObject( picture_BMP, sizeof( BITMAP ), &bitmap_info ); - - allocation_width = drawitem->rcItem.right - drawitem->rcItem.left; - allocation_height = drawitem->rcItem.bottom - drawitem->rcItem.top; - - scale_x = (float)allocation_width / bitmap_info.bmWidth; - scale_y = (float)allocation_height / bitmap_info.bmHeight; - scale_factor = scale_x < scale_y ? scale_x : scale_y; - - scaled_width = bitmap_info.bmWidth * scale_factor; - scaled_height = bitmap_info.bmHeight * scale_factor; - offset_x = ( allocation_width - scaled_width ) / 2; - offset_y = ( allocation_height - scaled_height ) / 2; - - StretchBlt( drawitem->hDC, offset_x, offset_y, - scaled_width, - scaled_height, - pic_dc, 0, 0, bitmap_info.bmWidth, bitmap_info.bmHeight, - SRCCOPY ); - - SelectObject( pic_dc, old_bmp ); - DeleteDC( pic_dc ); - - /* Erase background (hopefully) without flickering */ - if( offset_y > 0 ) { - rc.left = 0; - rc.top = 0; - rc.right = allocation_width; - rc.bottom = offset_y; - FillRect( drawitem->hDC, &rc, (HBRUSH) GetStockObject( BLACK_BRUSH ) ); - - rc.left = 0; - rc.top = offset_y + scaled_height; - rc.right = allocation_width; - rc.bottom = allocation_height; - FillRect( drawitem->hDC, &rc, (HBRUSH) GetStockObject( BLACK_BRUSH ) ); - } - - if( offset_x > 0 ) { - rc.left = 0; - rc.top = 0; - rc.right = offset_x; - rc.bottom = allocation_height; - FillRect( drawitem->hDC, &rc, (HBRUSH) GetStockObject( BLACK_BRUSH ) ); - - rc.left = offset_x + scaled_width; - rc.top = 0; - rc.right = allocation_width; - rc.bottom = allocation_height; - FillRect( drawitem->hDC, &rc, (HBRUSH) GetStockObject( BLACK_BRUSH ) ); - } - - return TRUE; -} - -static LRESULT WINAPI -picture_wnd_proc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) -{ - switch( msg ) { - case WM_SIZE: - resize_dialog( hWnd ); - return 0; - - case WM_SIZING: - resizing_dialog( wParam, lParam ); - return TRUE; - - case WM_DRAWITEM: - if( wParam == IDC_PICTURE_FRAME ) - return draw_frame( (LPDRAWITEMSTRUCT) lParam ); - break; - - case WM_COMMAND: - if( LOWORD( wParam ) == IDCLOSE ) { - destroy_dialog(); - return 0; - } - break; - - case WM_CLOSE: - destroy_dialog(); - return 0; - } - - return FALSE; -} - -static void -draw_screen( libspectrum_byte *screen, int border ) -{ - int i, x, y, ink, paper; - libspectrum_byte attr, data; - - GdiFlush(); - - for( y=0; y < DISPLAY_BORDER_HEIGHT; y++ ) { - for( x=0; x < DISPLAY_ASPECT_WIDTH; x++ ) { - *(libspectrum_dword*)( picture + y * picture_pitch + 4 * x ) = - win32display_colours[border]; - *(libspectrum_dword*)( - picture + - ( y + DISPLAY_BORDER_HEIGHT + DISPLAY_HEIGHT ) * picture_pitch + - 4 * x - ) = win32display_colours[ border ]; - } - } - - for( y=0; y> 3 ); - paper = ( attr & ( 0x0f << 3 ) ) >> 3; - - data = screen[ display_line_start[y]+x ]; - - for( i=0; i<8; i++ ) { - libspectrum_dword pix = - win32display_colours[ ( data & 0x80 ) ? ink : paper ]; - - /* rearrange pixel components */ - pix = ( pix & 0x0000ff00 ) | - ( ( pix & 0x000000ff ) << 16 ) | - ( ( pix & 0x00ff0000 ) >> 16 ); - - *(libspectrum_dword*)( - picture + - ( y + DISPLAY_BORDER_HEIGHT ) * picture_pitch + - 4 * ( 8 * x + DISPLAY_BORDER_ASPECT_WIDTH + i ) - ) = pix; - data <<= 1; - } - } - - } -} - -#ifdef PNG_SIMPLIFIED_READ_SUPPORTED - -static void -draw_png( libspectrum_byte *buffer, size_t size ) -{ - GdiFlush(); - memcpy( picture, buffer, size ); -} - -static int -read_png_file( const char *filename, png_bytep *buffer, size_t *size, - int *width, int *height ) -{ - utils_file png_file; - int error = utils_read_auxiliary_file( filename, &png_file, - UTILS_AUXILIARY_LIB ); - if( error == -1 ) { - return 1; - } - if( error ) return 1; - - /* Initialize the 'png_image' structure */ - png_image image; - memset( &image, 0, sizeof( image ) ); - image.version = PNG_IMAGE_VERSION; - image.opaque = NULL; - - if( png_image_begin_read_from_memory( &image, png_file.buffer, - png_file.length ) == 0 ) { - utils_close_file( &png_file ); - return 1; - } - - image.format = PNG_FORMAT_BGRA; - *buffer = malloc( PNG_IMAGE_SIZE( image ) ); - - if( *buffer == NULL ) { - png_image_free( &image ); - utils_close_file( &png_file ); - return 1; - } - *size = PNG_IMAGE_SIZE( image ); - - if( !png_image_finish_read( &image, NULL, *buffer, 0, NULL ) ) { - png_image_free( &image ); - free( *buffer ); - utils_close_file( &png_file ); - return 1; - } - - *width = PNG_IMAGE_ROW_STRIDE( image ) / - PNG_IMAGE_PIXEL_SIZE( PNG_FORMAT_BGRA ); - *height = PNG_IMAGE_SIZE( image ) / PNG_IMAGE_ROW_STRIDE( image ); - png_image_free( &image ); - utils_close_file( &png_file ); - - return 0; -} - -#endif /* #ifdef PNG_SIMPLIFIED_READ_SUPPORTED */ diff --git a/fuse/ui/win32/picture.h b/fuse/ui/win32/picture.h deleted file mode 100755 index ebb5476..0000000 --- a/fuse/ui/win32/picture.h +++ /dev/null @@ -1,25 +0,0 @@ -/* picture.h: Win32 routines to draw the keyboard picture - Copyright (c) 2008 Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#define IDD_PICTURE 1200 -#define IDC_PICTURE_FRAME 1201 diff --git a/fuse/ui/win32/picture.rc b/fuse/ui/win32/picture.rc deleted file mode 100755 index be6428e..0000000 --- a/fuse/ui/win32/picture.rc +++ /dev/null @@ -1,38 +0,0 @@ -/* picture.rc: Win32 resource file for the keyboard picture - Copyright (c) 2008 Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include -#include - -#include "picture.h" - -IDD_PICTURE DIALOG DISCARDABLE 0, 0, 50, 28 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION - | WS_SYSMENU | WS_THICKFRAME | WS_CLIPCHILDREN -EXSTYLE WS_EX_APPWINDOW -CAPTION "Fuse - Keyboard" -FONT 8, "Ms Shell Dlg 2" -BEGIN - CONTROL "", IDC_PICTURE_FRAME, WC_STATIC, SS_OWNERDRAW, 0, 0, 1, 1 - DEFPUSHBUTTON "Close", IDCLOSE, 0, 7, 50, 14 -END diff --git a/fuse/ui/win32/pokefinder.c b/fuse/ui/win32/pokefinder.c deleted file mode 100644 index 6ee8665..0000000 --- a/fuse/ui/win32/pokefinder.c +++ /dev/null @@ -1,373 +0,0 @@ -/* pokefinder.c: Win32 interface to the poke finder - Copyright (c) 2004 Marek Januszwski - Copyright (c) 2015 Sergio Baldoví - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include "debugger/debugger.h" -#include "pokefinder.h" -#include "pokefinder/pokefinder.h" -#include "ui/ui.h" -#include "win32internals.h" - -void menu_machine_pokefinder( int action ); -void move_button( int button, int dlg_height ); -static void possible_click( LPNMITEMACTIVATE lpnmitem ); -static void update_pokefinder( void ); -static void win32ui_pokefinder_incremented( void ); -static void win32ui_pokefinder_decremented( void ); -static void win32ui_pokefinder_search( void ); -static void win32ui_pokefinder_reset( void ); -static void win32ui_pokefinder_close( void ); - -/* Pokefinder window handle */ -HWND fuse_hPFWnd; - -#define MAX_POSSIBLE 20 - -int possible_page[ MAX_POSSIBLE ]; -libspectrum_word possible_offset[ MAX_POSSIBLE ]; -int initial_width = 0; -int initial_height = 0; -HWND lv_hWnd = NULL; -int lv_width = 0; - -static INT_PTR CALLBACK -win32ui_pokefinder_proc( HWND hWnd GCC_UNUSED, UINT msg, - WPARAM wParam, LPARAM lParam ) -{ - int height; - - switch( msg ) { - - case WM_COMMAND: - switch( LOWORD( wParam ) ) { - case IDCLOSE: - case IDCANCEL: - win32ui_pokefinder_close(); - return TRUE; - case IDC_PF_INC: - win32ui_pokefinder_incremented(); - return TRUE; - case IDC_PF_DEC: - win32ui_pokefinder_decremented(); - return TRUE; - case IDC_PF_SEARCH: - win32ui_pokefinder_search(); - return TRUE; - case IDC_PF_RESET: - win32ui_pokefinder_reset(); - return TRUE; - } - break; - - case WM_SIZE: - height = HIWORD( lParam ); - move_button( IDC_PF_INC, height ); - move_button( IDC_PF_DEC, height ); - move_button( IDC_PF_SEARCH, height ); - move_button( IDC_PF_RESET, height ); - move_button( IDCLOSE, height ); - return TRUE; - - case WM_CLOSE: - win32ui_pokefinder_close(); - return TRUE; - - case WM_NOTIFY: - switch ( ( ( LPNMHDR ) lParam )->code ) { - case NM_DBLCLK: - possible_click( ( LPNMITEMACTIVATE ) lParam ); - return TRUE; /* The return value for this notification is not used */ - } - break; - } - return FALSE; -} - -void -move_button( int button, int dlg_height ) -{ - HWND ctrl_hWnd; - RECT rect; - int x, y; - - ctrl_hWnd = GetDlgItem( fuse_hPFWnd, button ); - GetWindowRect( ctrl_hWnd, &rect ); - MapWindowPoints( 0, fuse_hPFWnd, (POINT *)&rect, 2 ); - x = rect.left; - y = dlg_height - ( rect.bottom - rect.top ) - 10; - SetWindowPos( ctrl_hWnd, 0, x, y, 0, 0, - SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); -} - -static void -update_pokefinder( void ) -{ - size_t page, offset, bank, bank_offset; - TCHAR buffer[256], *possible_text[2] = { &buffer[0], &buffer[128] }; - int rcx, rcy; - DWORD dw_res; - - /* clear the listview */ - SendDlgItemMessage( fuse_hPFWnd, IDC_PF_LIST, LVM_DELETEALLITEMS, 0, 0 ); - - /* display suspected locations if < 20 */ - int i = 0; - LV_ITEM lvi; - lvi.mask = LVIF_TEXT; - - if( pokefinder_count && pokefinder_count <= MAX_POSSIBLE ) { - - size_t which = 0; - - for( page = 0; page < MEMORY_PAGES_IN_16K * SPECTRUM_RAM_PAGES; page++ ) { - memory_page *mapping = &memory_map_ram[page]; - bank = mapping->page_num; - - for( offset = 0; offset < MEMORY_PAGE_SIZE; offset++ ) - if( ! (pokefinder_impossible[page][offset/8] & 1 << (offset & 7)) ) { - bank_offset = mapping->offset + offset; - - possible_page[ which ] = bank; - possible_offset[ which ] = bank_offset; - which++; - - _sntprintf( possible_text[0], 128, "%d", (unsigned)bank ); - _sntprintf( possible_text[1], 128, "0x%04X", (unsigned)bank_offset ); - - /* set new count of items */ - SendDlgItemMessage( fuse_hPFWnd, IDC_PF_LIST, LVM_SETITEMCOUNT, - i, 0 ); - - /* add the item */ - lvi.iItem = i; - lvi.iSubItem = 0; - lvi.pszText = possible_text[0]; - SendDlgItemMessage( fuse_hPFWnd, IDC_PF_LIST, LVM_INSERTITEM, 0, - ( LPARAM ) &lvi ); - lvi.iSubItem = 1; - lvi.pszText = possible_text[1]; - SendDlgItemMessage( fuse_hPFWnd, IDC_PF_LIST, LVM_SETITEM, 0, - ( LPARAM ) &lvi ); - - i++; - } - } - - /* show the listview */ - ShowWindow( lv_hWnd, SW_SHOW ); - - /* change the size of the listview */ - dw_res = SendMessage( lv_hWnd, LVM_APPROXIMATEVIEWRECT, pokefinder_count, - MAKELPARAM( -1, -1 ) ); - rcx = lv_width; /* same width */ - rcy = HIWORD( dw_res ); - SetWindowPos( lv_hWnd, NULL, 0, 0, rcx, rcy, - SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE ); - - rcx = initial_width; - rcy += initial_height + 10; - } else { - /* hide the listview */ - ShowWindow( lv_hWnd, SW_HIDE ); - - rcx = initial_width; - rcy = initial_height; - } - - /* change the size of the dialog */ - SetWindowPos( fuse_hPFWnd, NULL, 0, 0, rcx, rcy, - SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE ); - - /* print possible locations */ - _sntprintf( buffer, 256, "Possible locations: %lu", - (unsigned long)pokefinder_count ); - SendDlgItemMessage( fuse_hPFWnd, IDC_PF_LOCATIONS, WM_SETTEXT, 0, - (LPARAM) buffer ); -} - -void -menu_machine_pokefinder( int action GCC_UNUSED ) -{ - RECT rect; - int cx; - - if (fuse_hPFWnd == NULL) { - /* FIXME: Implement accelerators for this dialog */ - fuse_hPFWnd = CreateDialog( fuse_hInstance, - MAKEINTRESOURCE( IDD_POKEFINDER ), - fuse_hWnd, - ( DLGPROC ) win32ui_pokefinder_proc ); - if ( fuse_hPFWnd == NULL ) { - win32_verror( 1 ); /* FIXME: improve this function */ - return; - } - - /* store initial dialog dimensions */ - GetWindowRect( fuse_hPFWnd, &rect ); - initial_width = rect.right - rect.left; - initial_height = rect.bottom - rect.top; - - /* Set text limit */ - SendDlgItemMessage( fuse_hPFWnd, IDC_PF_EDIT, EM_LIMITTEXT, 4, 0 ); - - /* set extended listview style to select full row, when an item - is selected */ - DWORD lv_ext_style; - lv_ext_style = SendDlgItemMessage( fuse_hPFWnd, IDC_PF_LIST, - LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0 ); - lv_ext_style |= LVS_EX_FULLROWSELECT; - SendDlgItemMessage( fuse_hPFWnd, IDC_PF_LIST, - LVM_SETEXTENDEDLISTVIEWSTYLE, 0, lv_ext_style ); - - /* calculate columns width */ - lv_hWnd = GetDlgItem( fuse_hPFWnd, IDC_PF_LIST ); - GetClientRect( lv_hWnd, &rect ); - cx = rect.right - rect.left; - cx >>= 1; - - /* create columns */ - LVCOLUMN lvc; - lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT ; - lvc.fmt = LVCFMT_LEFT; - lvc.cx = cx; - lvc.pszText = (LPTSTR) TEXT( "Page" ); - SendDlgItemMessage( fuse_hPFWnd, IDC_PF_LIST, LVM_INSERTCOLUMN, 0, - ( LPARAM ) &lvc ); - lvc.mask |= LVCF_SUBITEM; - lvc.cx = cx; - lvc.pszText = (LPTSTR) TEXT( "Offset" ); - SendDlgItemMessage( fuse_hPFWnd, IDC_PF_LIST, LVM_INSERTCOLUMN, 1, - ( LPARAM ) &lvc ); - - /* store listview width */ - GetWindowRect( lv_hWnd, &rect ); - lv_width = rect.right - rect.left; - } else { - SetActiveWindow( fuse_hPFWnd ); - } - update_pokefinder(); -} - -static void -win32ui_pokefinder_incremented( void ) -{ - pokefinder_incremented(); - update_pokefinder(); -} - -static void -win32ui_pokefinder_decremented( void ) -{ - pokefinder_decremented(); - update_pokefinder(); -} - -static void -win32ui_pokefinder_search( void ) -{ - long value; - TCHAR *buffer, *endptr; - int buffer_size, base; - HWND hwnd_control; - - /* poll the size of the value in Search box first */ - buffer_size = SendDlgItemMessage( fuse_hPFWnd, IDC_PF_EDIT, WM_GETTEXTLENGTH, - (WPARAM) 0, (LPARAM) 0 ); - buffer = malloc( ( buffer_size + 1 ) * sizeof( TCHAR ) ); - if( buffer == NULL ) { - ui_error( UI_ERROR_ERROR, "Out of memory in %s.", __func__ ); - return; - } - - /* get the value in Search box first */ - if( SendDlgItemMessage( fuse_hPFWnd, IDC_PF_EDIT, WM_GETTEXT, - (WPARAM) ( buffer_size + 1 ), - (LPARAM) buffer ) != buffer_size ) { - ui_error( UI_ERROR_ERROR, "Couldn't get the content of the Search text box" ); - return; - } - - errno = 0; - base = ( !_tcsncmp( _T("0x"), buffer, strlen( _T("0x") ) ) )? 16 : 10; - value = _tcstol( buffer, &endptr, base ); - - if( errno || value < 0 || value > 255 || endptr == buffer ) { - free( buffer ); - ui_error( UI_ERROR_ERROR, "Invalid value: use an integer from 0 to 255" ); - hwnd_control = GetDlgItem( fuse_hPFWnd, IDC_PF_EDIT ); - SendMessage( fuse_hPFWnd, WM_NEXTDLGCTL, (WPARAM) hwnd_control, TRUE ); - return; - } - free( buffer ); - - pokefinder_search( value ); - update_pokefinder(); -} - -static void -win32ui_pokefinder_reset( void ) -{ - pokefinder_clear(); - update_pokefinder(); -} - -static void -win32ui_pokefinder_close( void ) -{ - DestroyWindow( fuse_hPFWnd ); - fuse_hPFWnd = NULL; -} - -static void -possible_click( LPNMITEMACTIVATE lpnmitem ) -{ - /* FIXME: implement equivalent of GTK's select-via-keyboard to enter here */ - - int error; - libspectrum_word row; - - if( lpnmitem->iItem < 0 ) return; - - row = lpnmitem->iItem; - - error = debugger_breakpoint_add_address( - DEBUGGER_BREAKPOINT_TYPE_WRITE, memory_source_ram, possible_page[ row ], - possible_offset[ row ], 0, DEBUGGER_BREAKPOINT_LIFE_PERMANENT, NULL - ); - if( error ) return; - - ui_debugger_update(); -} - -void -win32ui_pokefinder_clear( void ) -{ - pokefinder_clear(); - if( fuse_hPFWnd != NULL ) update_pokefinder(); -} diff --git a/fuse/ui/win32/pokefinder.h b/fuse/ui/win32/pokefinder.h deleted file mode 100644 index a909dab..0000000 --- a/fuse/ui/win32/pokefinder.h +++ /dev/null @@ -1,32 +0,0 @@ -/* pokefinder.h: Win32 interface to the poke finder - Copyright (c) 2004 Marek Januszwski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#define IDD_POKEFINDER 1500 -#define IDC_PF_SEARCH_FOR 1501 -#define IDC_PF_EDIT 1502 -#define IDC_PF_LOCATIONS 1503 -#define IDC_PF_LIST 1504 -#define IDC_PF_INC 1505 -#define IDC_PF_DEC 1506 -#define IDC_PF_SEARCH 1507 -#define IDC_PF_RESET 1508 diff --git a/fuse/ui/win32/pokefinder.rc b/fuse/ui/win32/pokefinder.rc deleted file mode 100644 index 96c45d6..0000000 --- a/fuse/ui/win32/pokefinder.rc +++ /dev/null @@ -1,46 +0,0 @@ -/* res_pokefinder.rc: Win32 interface to the poke finder - Copyright (c) 2004 Marek Januszwski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include "pokefinder.h" - -IDD_POKEFINDER DIALOGEX DISCARDABLE 6,6,330,49 -CAPTION "Fuse - Poke Finder" -STYLE WS_POPUP | WS_CAPTION | WS_VISIBLE | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -FONT 8,"Ms Shell Dlg 2",400,0,1 -BEGIN - CTEXT "Search for:", IDC_PF_SEARCH_FOR, 20, 10, 38, 8 - EDITTEXT IDC_PF_EDIT, 70, 7, 80, 14, - WS_CHILD | WS_TABSTOP | WS_VISIBLE, WS_EX_CLIENTEDGE - - CTEXT "Possible locations: 6", IDC_PF_LOCATIONS, 173, 10, 150, 8 - CONTROL "", IDC_PF_LIST, "SysListView32", - WS_CHILD | WS_TABSTOP | LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS, - 173, 25, 150, 39, WS_EX_CLIENTEDGE - - PUSHBUTTON "&Incremented", IDC_PF_INC, 7, 28, 60, 14 - PUSHBUTTON "&Decremented", IDC_PF_DEC, 71, 28, 60, 14 - DEFPUSHBUTTON "&Search", IDC_PF_SEARCH, 135, 28, 60, 14 - PUSHBUTTON "&Reset", IDC_PF_RESET, 199, 28, 60, 14 - PUSHBUTTON "&Close", IDCLOSE, 263, 28, 60, 14 -END diff --git a/fuse/ui/win32/pokemem.c b/fuse/ui/win32/pokemem.c deleted file mode 100644 index 2e5e9d7..0000000 --- a/fuse/ui/win32/pokemem.c +++ /dev/null @@ -1,654 +0,0 @@ -/* pokemem.c: Win32 interface to the poke memory - Copyright (c) 2011-2015 Philip Kendall, Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include "fuse.h" -#include "pokemem.h" -#include "pokefinder/pokemem.h" -#include "ui/ui.h" -#include "win32internals.h" - -void menu_machine_pokememory( int action ); -void initialize_dialog( HWND hwnd_dialog ); -void create_custom_edit( HWND parent, int item, int subitem ); -void move_custom_edit( HWND hwnd_c_edit, HWND hwnd_parent ); -void trainer_add( gpointer data, gpointer user_data ); -void pokemem_update_list( void ); -void pokemem_update_trainer( int index ); -void pokemem_add_custom_poke( void ); -INT_PTR CALLBACK win32ui_pokemem_proc( HWND hWnd, UINT msg, WPARAM wParam, - LPARAM lParam ); -LRESULT CALLBACK listview_proc( HWND hWnd, UINT msg, WPARAM wParam, - LPARAM lParam ); -LRESULT CALLBACK edit_proc( HWND hWnd, UINT msg, WPARAM wParam, - LPARAM lParam ); - -HWND fuse_hPMWnd = NULL; -HWND hwnd_edit = NULL; -int item_edit, subitem_edit; -BOOL cancel_edit = FALSE; - -void -menu_machine_pokememory( int action GCC_UNUSED ) -{ - fuse_emulation_pause(); - - pokemem_autoload_pokfile(); - - DialogBox( fuse_hInstance, MAKEINTRESOURCE( IDD_POKEMEM ), - fuse_hWnd, (DLGPROC) win32ui_pokemem_proc ); - - fuse_emulation_unpause(); -} - -void -ui_pokemem_selector( const char *filename ) -{ - fuse_emulation_pause(); - - pokemem_read_from_file( filename ); - - DialogBox( fuse_hInstance, MAKEINTRESOURCE( IDD_POKEMEM ), - fuse_hWnd, (DLGPROC) win32ui_pokemem_proc ); - - fuse_emulation_unpause(); -} - -INT_PTR CALLBACK -win32ui_pokemem_proc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) -{ - switch( msg ) { - case WM_INITDIALOG: - initialize_dialog( hWnd ); - return TRUE; - - case WM_COMMAND: - switch( LOWORD( wParam ) ) { - case IDOK: - pokemem_update_list(); - EndDialog( hWnd, wParam ); - return 0; - case IDCLOSE: - case IDCANCEL: - EndDialog( hWnd, wParam ); - return 0; - case IDC_PM_ADD: - pokemem_add_custom_poke(); - return 0; - } - break; - - case WM_CLOSE: - EndDialog( hWnd, wParam ); - return 0; - - case WM_NOTIFY: - if( LOWORD( wParam ) == IDC_PM_LIST ) { - NMHDR *nmhdr = (NMHDR *) lParam; - LPNMLISTVIEW lpnmitem; - - switch( nmhdr->code ) { - - case LVN_ITEMCHANGING: - { - lpnmitem = (LPNMLISTVIEW) lParam; - if( lpnmitem->uChanged & LVIF_STATE ) { - unsigned int new_state, old_state; - new_state = ( lpnmitem->uNewState & LVIS_STATEIMAGEMASK ) >> 12; - old_state = ( lpnmitem->uOldState & LVIS_STATEIMAGEMASK ) >> 12; - trainer_t *trainer = (trainer_t *)lpnmitem->lParam; - - /* Prevent the check of disabled trainers */ - if( new_state != old_state && trainer->disabled ) - { - SetWindowLongPtr( hWnd, DWLP_MSGRESULT, TRUE ); - return TRUE; - } - } - break; - } - - case LVN_ITEMCHANGED: - { - lpnmitem = (LPNMLISTVIEW) lParam; - - if( lpnmitem->uChanged & LVIF_STATE && lpnmitem->iItem >= 0 ) { - unsigned int new_state, old_state; - new_state = ( lpnmitem->uNewState & LVIS_STATEIMAGEMASK ) >> 12; - old_state = ( lpnmitem->uOldState & LVIS_STATEIMAGEMASK ) >> 12; - trainer_t *trainer = (trainer_t *)lpnmitem->lParam; - - /* Trainer checked, ask for custom value if needed */ - if( new_state != old_state && new_state == 2 && !trainer->active - && trainer->ask_value ) { - ListView_SetItemState( nmhdr->hwndFrom, lpnmitem->iItem, - LVIS_SELECTED, LVIS_SELECTED ); - create_custom_edit( nmhdr->hwndFrom, lpnmitem->iItem, 1 ); - } - - break; - } - } - } - } - break; - } - - return FALSE; -} - -LRESULT CALLBACK -listview_proc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) -{ - switch( msg ) { - - case WM_DESTROY: - { - WNDPROC orig_proc = (WNDPROC) GetProp( hWnd, "original_proc" ); - SetWindowLongPtr( hWnd, GWLP_WNDPROC, (LONG_PTR) orig_proc ); - RemoveProp( hWnd, "original_proc" ); - break; - } - - case WM_VSCROLL: - /* do scroll and move edit */ - if( hwnd_edit ) { - PostMessage( hWnd, WM_USER, (WPARAM) hwnd_edit, (LPARAM) hWnd ); - } - break; - - case WM_HSCROLL: - /* do scroll and move edit */ - if( hwnd_edit ) { - PostMessage( hWnd, WM_USER, (WPARAM) hwnd_edit, (LPARAM) hWnd ); - } - break; - - case WM_USER: - move_custom_edit( (HWND)wParam, (HWND)lParam ); - break; - - case WM_LBUTTONDOWN: - { - if( hwnd_edit ) SendMessage( hwnd_edit, WM_KILLFOCUS,0,0 ); - - LVHITTESTINFO itemclicked; - itemclicked.pt.x = (long) LOWORD( lParam ); - itemclicked.pt.y = (long) HIWORD( lParam ); - - int result = ListView_SubItemHitTest( hWnd, &itemclicked ); - - /* Clicked on Value column? */ - if( result >= 0 && itemclicked.iSubItem ) { - - /* Get trainer */ - LV_ITEM lvi; - memset( &lvi, 0, sizeof( lvi ) ); - lvi.mask = LVIF_PARAM; - lvi.iItem = itemclicked.iItem; - SendMessage( hWnd, LVM_GETITEM, 0, (LPARAM)&lvi ); - trainer_t *trainer = (trainer_t *)lvi.lParam; - - /* Ask for custom value */ - if( !trainer->active && trainer->ask_value ) { - ListView_SetItemState( hWnd, itemclicked.iItem, LVIS_SELECTED, - LVIS_SELECTED ); - create_custom_edit( hWnd, itemclicked.iItem, 1 ); - return TRUE; - } - } - - break; - } - - case WM_NOTIFY: - { - NMHDR *nmhdr = (NMHDR *) lParam; - - switch( nmhdr->code ) { - - case LVN_ENDLABELEDIT: - { - LV_DISPINFO* dispinfo = (LV_DISPINFO*)lParam; - LVITEM lvi; - long val; - - /* Edit cancelled? */ - if( !dispinfo->item.pszText ) return TRUE; - - memset( &lvi, 0, sizeof( lvi ) ); - lvi.iItem = dispinfo->item.iItem; - lvi.iSubItem = dispinfo->item.iSubItem; - lvi.pszText = ( dispinfo->item.cchTextMax > 1 )? - dispinfo->item.pszText : (LPTSTR) TEXT( "0" ); - - /* Validate value */ - val = _ttol( lvi.pszText ); - if( val > 256 ) { - val = 0; - lvi.pszText = (LPTSTR) TEXT( "0" ); - } - - /* Update listview */ - SendMessage( hWnd, LVM_SETITEMTEXT, (WPARAM) lvi.iItem, - (LPARAM) &lvi ); - - /* Update trainer */ - memset( &lvi, 0, sizeof( lvi ) ); - lvi.mask = LVIF_PARAM; - lvi.iItem = dispinfo->item.iItem; - SendMessage( hWnd, LVM_GETITEM, 0, (LPARAM) &lvi ); - trainer_t *trainer = (trainer_t *)lvi.lParam; - trainer->value = val; - - return TRUE; - } - } - } - } - - WNDPROC orig_proc = (WNDPROC) GetProp( hWnd, "original_proc" ); - return CallWindowProc( orig_proc, hWnd, msg, wParam, lParam ); -} - -LRESULT CALLBACK -edit_proc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) -{ - switch( msg ) { - - case WM_DESTROY: - { - WNDPROC orig_proc = (WNDPROC) GetProp( hWnd, "original_proc" ); - SetWindowLongPtr( hWnd, GWLP_WNDPROC, (LONG_PTR) orig_proc ); - RemoveProp( hWnd, "original_proc" ); - hwnd_edit = NULL; - break; - } - - case WM_GETDLGCODE: - { - /* Allow ESC and Return keystroke capture */ - MSG *m = (MSG *)lParam; - if( m && ( m->wParam == VK_RETURN || m->wParam == VK_ESCAPE ) ) - return DLGC_WANTALLKEYS; - break; - } - - case WM_KEYDOWN: - { - if( wParam == VK_RETURN ) { - /* Lost focus to confirm value */ - SetFocus( GetParent( hWnd ) ); - return TRUE; - } - else if ( wParam == VK_ESCAPE ) { - /* Lost focus to cancel edit */ - cancel_edit = TRUE; - SetFocus( GetParent( hWnd ) ); - return TRUE; - } - break; - } - - case WM_KILLFOCUS: - { - /* Notify list end of label edit */ - LV_DISPINFO lvDispinfo; - memset( &lvDispinfo, 0, sizeof( LV_DISPINFO ) ); - lvDispinfo.hdr.hwndFrom = hWnd; - lvDispinfo.hdr.idFrom = GetDlgCtrlID( hWnd ); - lvDispinfo.hdr.code = LVN_ENDLABELEDIT; - lvDispinfo.item.mask = LVIF_TEXT; - lvDispinfo.item.iItem = item_edit; - lvDispinfo.item.iSubItem = subitem_edit; - lvDispinfo.item.pszText = NULL; - - if( !cancel_edit ) { - TCHAR szEditText[4]; - GetWindowText( hWnd, szEditText, 4 ); - lvDispinfo.item.pszText = szEditText; - lvDispinfo.item.cchTextMax = lstrlen( szEditText ) + 1; - } - SendMessage( GetParent( hWnd ), WM_NOTIFY, (WPARAM) IDC_PM_LIST, - (LPARAM) &lvDispinfo ); - - DestroyWindow( hWnd ); - return TRUE; - } - } - - WNDPROC orig_proc = (WNDPROC) GetProp( hWnd, "original_proc" ); - return CallWindowProc( orig_proc, hWnd, msg, wParam, lParam ); -} - -void -initialize_dialog( HWND hwnd_dialog ) -{ - HWND hwnd_list; - RECT rect; - int cx; - - fuse_hPMWnd = hwnd_dialog; - hwnd_list = GetDlgItem( hwnd_dialog, IDC_PM_LIST ); - - /* Replace message handler */ - WNDPROC orig_proc = (WNDPROC) GetWindowLongPtr( hwnd_list, GWLP_WNDPROC ); - SetProp( hwnd_list, "original_proc", (HANDLE) orig_proc ); - SetWindowLongPtr( hwnd_list, GWLP_WNDPROC, (LONG_PTR) (WNDPROC) listview_proc ); - - /* Set text limits */ - SendDlgItemMessage( hwnd_dialog, IDC_PM_BANK_EDIT, EM_LIMITTEXT, 1, 0 ); - SendDlgItemMessage( hwnd_dialog, IDC_PM_ADDR_EDIT, EM_LIMITTEXT, 5, 0 ); - SendDlgItemMessage( hwnd_dialog, IDC_PM_VALUE_EDIT, EM_LIMITTEXT, 3, 0 ); - - /* Set extended listview style to select full row, when an item - is selected */ - DWORD lv_ext_style; - lv_ext_style = SendMessage( hwnd_list, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0 ); - lv_ext_style |= LVS_EX_FULLROWSELECT; - lv_ext_style |= LVS_EX_CHECKBOXES; - SendMessage( hwnd_list, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, lv_ext_style ); - - /* Calculate columns width, reserve space for vertical scrollbar */ - NONCLIENTMETRICS ncm; - ncm.cbSize = sizeof( NONCLIENTMETRICS ); - SystemParametersInfo( SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0 ); - GetClientRect( hwnd_list, &rect ); - cx = rect.right - rect.left - ncm.iScrollWidth; - - /* Create trainer column */ - LVCOLUMN lvc; - lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT; - lvc.fmt = LVCFMT_LEFT; - lvc.cx = cx - ( cx >> 2 ); - lvc.pszText = (LPTSTR) TEXT( "Trainer" ); - SendMessage( hwnd_list, LVM_INSERTCOLUMN, 0, (LPARAM) &lvc ); - - /* Create value column */ - lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; - lvc.cx = cx >> 2; - lvc.pszText = (LPTSTR) TEXT( "Value" ); - SendMessage( hwnd_list, LVM_INSERTCOLUMN, 1, (LPARAM) &lvc ); - - /* Fill listview with data */ - if( trainer_list ) { - /* Allocate memory */ - guint length = g_slist_length( trainer_list ); - SendMessage( hwnd_list, LVM_SETITEMCOUNT, length, 0 ); - - /* Loop data model */ - g_slist_foreach( trainer_list, trainer_add, hwnd_list ); - } -} - -void -trainer_add( gpointer data, gpointer user_data ) -{ - trainer_t *trainer = data; - HWND hwnd_list = (HWND) user_data; - TCHAR buffer[81]; - int i, state; - LV_ITEM lvi; - - if( !trainer ) return; - - /* Get count of items */ - i = SendMessage( hwnd_list, LVM_GETITEMCOUNT, 0, 0 ); - - /* add trainer */ - memset( &lvi, 0, sizeof( lvi ) ); - lvi.mask = LVIF_TEXT | LVIF_PARAM; - lvi.iItem = i; - lvi.iSubItem = 0; - _sntprintf( buffer, 80, "%s", trainer->name ); - buffer[80] = '\0'; - lvi.pszText = buffer; - lvi.lParam = (LPARAM)trainer; - SendMessage( hwnd_list, LVM_INSERTITEM, 0, (LPARAM) &lvi ); - - /* add value */ - if( trainer->ask_value ) { - _sntprintf( buffer, 80, "%d", trainer->value ); - memset( &lvi, 0, sizeof( lvi ) ); - lvi.mask = LVIF_TEXT; - lvi.iItem = i; - lvi.iSubItem = 1; - lvi.pszText = buffer; - SendMessage( hwnd_list, LVM_SETITEM, 0, (LPARAM) &lvi ); - } - - /* mark trainer checked or disabled */ - if( trainer->disabled ) - state = 0; - else - state = ( trainer->active )? 2 : 1; - - memset( &lvi, 0, sizeof( lvi ) ); - lvi.mask = LVIF_STATE; - lvi.state = INDEXTOSTATEIMAGEMASK( state ); - lvi.stateMask = LVIS_STATEIMAGEMASK; - SendMessage( hwnd_list, LVM_SETITEMSTATE, i, (LPARAM) &lvi ); -} - -void -create_custom_edit( HWND parent, int item, int subitem ) -{ - RECT subitemrect; - int width, height; - - /* Get item bounds */ - subitemrect.top = subitem; - subitemrect.left = LVIR_BOUNDS; - SendMessage( parent, LVM_GETSUBITEMRECT, item, (LPARAM) &subitemrect ); - height = subitemrect.bottom - subitemrect.top; - width = subitemrect.right - subitemrect.left; - - /* Create custom edit */ - hwnd_edit = CreateWindowEx( WS_EX_CLIENTEDGE, "EDIT", "", - WS_CHILD | WS_VISIBLE | ES_NUMBER, - subitemrect.left, subitemrect.top, width, height, - parent, (HMENU) IDC_PM_LIST_EDIT, - GetModuleHandle( NULL ), NULL ); - if( !hwnd_edit ) return; - - /* Replace message handler */ - WNDPROC orig_proc = (WNDPROC) GetWindowLongPtr( hwnd_edit, GWLP_WNDPROC ); - SetProp( hwnd_edit, "original_proc", (HANDLE) orig_proc ); - SetWindowLongPtr( hwnd_edit, GWLP_WNDPROC, (LONG_PTR) (WNDPROC) edit_proc ); - - /* Set proper font custom edit */ - HFONT hFont = (HFONT) SendMessage( parent, WM_GETFONT, 0, 0 ); - SendMessage( hwnd_edit, WM_SETFONT, (WPARAM) hFont, (LPARAM) FALSE ); - - /* Set custom edit text */ - TCHAR szEditText[4]; - SendMessage( hwnd_edit, EM_LIMITTEXT, 3, 0 ); - ListView_GetItemText( parent, item, subitem, szEditText, 4 ); - SendMessage( hwnd_edit, WM_SETTEXT, 0, (LPARAM) szEditText ); - - /* Focus edit control and select text */ - SetFocus( hwnd_edit ); - SendMessage( hwnd_edit, EM_SETSEL, 0, -1 ); - - item_edit = item; - subitem_edit = subitem; - cancel_edit = FALSE; -} - -void -move_custom_edit( HWND hwnd_c_edit, HWND hwnd_parent ) -{ - HWND hwnd_header; - RECT header_rect, item_rect; - int width, height; - - /* Get current item position */ - item_rect.top = subitem_edit; - item_rect.left = LVIR_BOUNDS; - SendMessage( hwnd_parent, LVM_GETSUBITEMRECT, item_edit, (LPARAM) &item_rect ); - - /* Get header position */ - hwnd_header = (HWND)SendMessage( hwnd_parent, LVM_GETHEADER, 0, 0 ); - GetWindowRect( hwnd_header, &header_rect ); - MapWindowPoints( HWND_DESKTOP, hwnd_parent, (LPPOINT) &header_rect, 2 ); - - /* Move Edit along with item */ - if( item_rect.top >= header_rect.bottom ) { - width = item_rect.right - item_rect.left; - height = item_rect.bottom - item_rect.top; - InvalidateRect( hwnd_parent, &item_rect, FALSE ); - SetWindowPos( hwnd_c_edit, NULL, item_rect.left, item_rect.top, - width, height, SWP_NOZORDER | SWP_SHOWWINDOW ); - } - else { - /* Hide custom edit when scrolls above header */ - SetWindowPos( hwnd_c_edit, NULL, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOZORDER | SWP_NOSIZE | SWP_HIDEWINDOW ); - } -} - -void -pokemem_update_list( void ) -{ - int i, items; - - /* Get count of items */ - items = SendDlgItemMessage( fuse_hPMWnd, IDC_PM_LIST, LVM_GETITEMCOUNT, - 0, 0 ); - - for( i = 0; i < items; i++ ) { - pokemem_update_trainer( i ); - } -} - -void -pokemem_update_trainer( int index ) -{ - int selected; - trainer_t *trainer; - LV_ITEM lvi; - - memset( &lvi, 0, sizeof( lvi ) ); - lvi.mask = LVIF_STATE | LVIF_PARAM; - lvi.iItem = index; - lvi.stateMask = LVIS_STATEIMAGEMASK; - SendDlgItemMessage( fuse_hPMWnd, IDC_PM_LIST, LVM_GETITEM, 0, (LPARAM)&lvi ); - - trainer = (trainer_t *) lvi.lParam; - selected = ( ( lvi.state >> 12 ) == 2 ); - - if( selected ) { - pokemem_trainer_activate( trainer ); - } else { - pokemem_trainer_deactivate( trainer ); - } -} - -void -pokemem_add_custom_poke( void ) -{ - long b, a, v; - TCHAR buffer[8]; - int length, buffer_size = 8; - HWND hwnd_control; - trainer_t *trainer; - - /* Parse bank */ - length = SendDlgItemMessage( fuse_hPMWnd, IDC_PM_BANK_EDIT, WM_GETTEXT, - (WPARAM) buffer_size, (LPARAM) buffer ); - - b = ( length )? _ttol( buffer ) : 8; - - if( b < 0 || b > 8 ) { - ui_error( UI_ERROR_ERROR, "Invalid bank: use a number from 0 to 8" ); - hwnd_control = GetDlgItem( fuse_hPMWnd, IDC_PM_BANK_EDIT ); - SendMessage( fuse_hPMWnd, WM_NEXTDLGCTL, (WPARAM) hwnd_control, TRUE ); - return; - } - - /* Parse address */ - length = SendDlgItemMessage( fuse_hPMWnd, IDC_PM_ADDR_EDIT, WM_GETTEXT, - (WPARAM) buffer_size, (LPARAM) buffer ); - - /* TODO: accept hex address */ - a = ( length )? _ttol( buffer ) : 0; - - if( !length || a < 0 || a > 65535 ) { - ui_error( UI_ERROR_ERROR, - "Invalid address: use a number from 0 to 65535" ); - hwnd_control = GetDlgItem( fuse_hPMWnd, IDC_PM_ADDR_EDIT ); - SendMessage( fuse_hPMWnd, WM_NEXTDLGCTL, (WPARAM) hwnd_control, TRUE ); - return; - } - - /* Parse value */ - length = SendDlgItemMessage( fuse_hPMWnd, IDC_PM_VALUE_EDIT, WM_GETTEXT, - (WPARAM) buffer_size, (LPARAM) buffer ); - - v = ( length )? _ttol( buffer ) : 0; - - if( !length || v < 0 || v > 256 ) { - ui_error( UI_ERROR_ERROR, "Invalid value: use a number from 0 to 256" ); - hwnd_control = GetDlgItem( fuse_hPMWnd, IDC_PM_VALUE_EDIT ); - SendMessage( fuse_hPMWnd, WM_NEXTDLGCTL, (WPARAM) hwnd_control, TRUE ); - return; - } - - /* Updadate model and view */ - trainer = pokemem_trainer_list_add( b, a, v ); - if( !trainer ) { - ui_error( UI_ERROR_ERROR, "Cannot add trainer" ); - return; - } - - hwnd_control = GetDlgItem( fuse_hPMWnd, IDC_PM_LIST ); - trainer_add( trainer, hwnd_control ); - - /* Mark custom trainer for activate */ - if( !trainer->active && !trainer->disabled ) { - LV_ITEM lvi; - int index; - - memset( &lvi, 0, sizeof( lvi ) ); - lvi.mask = LVIF_STATE; - lvi.state = INDEXTOSTATEIMAGEMASK( 2 ); - lvi.stateMask = LVIS_STATEIMAGEMASK; - index = SendDlgItemMessage( fuse_hPMWnd, IDC_PM_LIST, LVM_GETITEMCOUNT, - 0, 0 ) - 1; - SendDlgItemMessage( fuse_hPMWnd, IDC_PM_LIST, LVM_SETITEMSTATE, - (WPARAM) index, (LPARAM) &lvi ); - } - - /* Clear custom fields */ - SetDlgItemText( fuse_hPMWnd, IDC_PM_BANK_EDIT, NULL ); - SetDlgItemText( fuse_hPMWnd, IDC_PM_ADDR_EDIT, NULL ); - SetDlgItemText( fuse_hPMWnd, IDC_PM_VALUE_EDIT, NULL ); - - /* Focus for new input */ - hwnd_control = GetDlgItem( fuse_hPMWnd, IDC_PM_ADDR_EDIT ); - SendMessage( fuse_hPMWnd, WM_NEXTDLGCTL, (WPARAM) hwnd_control, TRUE ); -} diff --git a/fuse/ui/win32/pokemem.h b/fuse/ui/win32/pokemem.h deleted file mode 100644 index 748a100..0000000 --- a/fuse/ui/win32/pokemem.h +++ /dev/null @@ -1,34 +0,0 @@ -/* pokemem.h: Win32 interface to the poke memory - Copyright (c) 2011 Philip Kendall, Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#define IDD_POKEMEM 1900 -#define IDC_PM_BANK 1901 -#define IDC_PM_BANK_EDIT 1902 -#define IDC_PM_ADDRESS 1903 -#define IDC_PM_ADDR_EDIT 1904 -#define IDC_PM_VALUE 1905 -#define IDC_PM_VALUE_EDIT 1906 -#define IDC_PM_ADD 1907 -#define IDC_PM_ACTIVE_POK 1908 -#define IDC_PM_LIST 1909 -#define IDC_PM_LIST_EDIT 1910 diff --git a/fuse/ui/win32/pokemem.rc b/fuse/ui/win32/pokemem.rc deleted file mode 100644 index f40385f..0000000 --- a/fuse/ui/win32/pokemem.rc +++ /dev/null @@ -1,49 +0,0 @@ -/* pokemem.rc: Win32 interface to the poke memory - Copyright (c) 2011 Philip Kendall, Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include "pokemem.h" - -IDD_POKEMEM DIALOGEX DISCARDABLE 6,6,314,171 -CAPTION "Fuse - Poke Memory" -STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_MODALFRAME -FONT 8,"Ms Shell Dlg 2",400,0,1 -BEGIN - LTEXT "Bank:", IDC_PM_BANK, 7, 10, 30, 8 - EDITTEXT IDC_PM_BANK_EDIT, 41, 7, 40, 14, - WS_CHILD | WS_TABSTOP | WS_VISIBLE | ES_NUMBER, WS_EX_CLIENTEDGE - LTEXT "Address:", IDC_PM_ADDRESS, 88, 10, 30, 8 - EDITTEXT IDC_PM_ADDR_EDIT, 122, 7, 40, 14, - WS_CHILD | WS_TABSTOP | WS_VISIBLE | ES_NUMBER, WS_EX_CLIENTEDGE - LTEXT "Value:", IDC_PM_VALUE, 169, 10, 30, 8 - EDITTEXT IDC_PM_VALUE_EDIT, 203, 7, 40, 14, - WS_CHILD | WS_TABSTOP | WS_VISIBLE | ES_NUMBER, WS_EX_CLIENTEDGE - PUSHBUTTON "&Add", IDC_PM_ADD, 257, 7, 50, 14 - - CTEXT "Choose active POKES:", IDC_PM_ACTIVE_POK, 7, 28, 300, 8 - CONTROL "", IDC_PM_LIST, "SysListView32", WS_CHILD | WS_TABSTOP | - WS_VISIBLE | LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS, - 7, 39, 300, 104, WS_EX_CLIENTEDGE - - DEFPUSHBUTTON "&OK", IDOK, 183, 150, 60, 14 - PUSHBUTTON "&Cancel", IDCANCEL, 247, 150, 60, 14 -END diff --git a/fuse/ui/win32/rollback.c b/fuse/ui/win32/rollback.c deleted file mode 100644 index b4ab8d2..0000000 --- a/fuse/ui/win32/rollback.c +++ /dev/null @@ -1,133 +0,0 @@ -/* rollback.c: select a rollback point - Copyright (c) 2004-2008 Philip Kendall, Marek Januszewski - Copyright (c) 2015 Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include /* windows.h must be included prior to commctrl.h */ - -#include "fuse.h" -#include "ui/ui.h" -#include "win32internals.h" - -#include "rollback.h" - -static int current_block; - -static void -dialog_init( HWND hwndDlg ) -{ - /* set extended listview style to select full row, when an item is selected */ - DWORD lv_ext_style; - lv_ext_style = SendDlgItemMessage( hwndDlg, IDC_ROLLBACK_LV, - LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0 ); - lv_ext_style |= LVS_EX_FULLROWSELECT; - SendDlgItemMessage( hwndDlg, IDC_ROLLBACK_LV, - LVM_SETEXTENDEDLISTVIEWSTYLE, 0, lv_ext_style ); - - /* Create the column in the listview */ - LVCOLUMN lvc; - lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT ; - lvc.fmt = LVCFMT_LEFT; - lvc.cx = 100; /* FIXME: preferably calculate the whole length */ - lvc.pszText = (LPTSTR) TEXT( "Seconds" ); - SendDlgItemMessage( hwndDlg, IDC_ROLLBACK_LV, LVM_INSERTCOLUMN, 0, - ( LPARAM ) &lvc ); -} - -static int -update_list( HWND hwndDlg, GSList *points ) -{ - LV_ITEM lvi; - - SendDlgItemMessage( hwndDlg, IDC_ROLLBACK_LV, LVM_DELETEALLITEMS, 0, 0 ); - - lvi.iSubItem = 0; - lvi.mask = LVIF_TEXT; - - while( points ) { - TCHAR buffer[256]; - TCHAR *buffer2[1] = { buffer }; - - _sntprintf( buffer, 256, "%.2f", GPOINTER_TO_INT( points->data ) / 50.0 ); - - lvi.iItem = SendDlgItemMessage( hwndDlg, IDC_ROLLBACK_LV, - LVM_GETITEMCOUNT, 0, 0 ); - lvi.pszText = buffer2[0]; - SendDlgItemMessage( hwndDlg, IDC_ROLLBACK_LV, LVM_INSERTITEM, 0, - ( LPARAM ) &lvi ); - - points = points->next; - } - - return 0; -} - -static INT_PTR CALLBACK -dialog_proc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) -{ - switch( uMsg ) { - - case WM_INITDIALOG: - dialog_init( hwndDlg ); - update_list( hwndDlg, ( GSList * ) lParam ); - return FALSE; - - case WM_COMMAND: - switch( LOWORD( wParam ) ) { - case IDOK: - EndDialog( hwndDlg, SendDlgItemMessage( hwndDlg, IDC_ROLLBACK_LV, - LVM_GETSELECTIONMARK, 0, 0 ) ); - return 0; - - case IDCANCEL: - EndDialog( hwndDlg, -1 ); - return 0; - } - break; - - case WM_CLOSE: - EndDialog( hwndDlg, -1 ); - return 0; - } - return FALSE; -} - -int -ui_get_rollback_point( GSList *points ) -{ - int result; - - fuse_emulation_pause(); - - current_block = -1; - - result = DialogBoxParam( fuse_hInstance, MAKEINTRESOURCE( IDD_ROLLBACK ), - fuse_hWnd, dialog_proc, ( LPARAM ) points ); - - fuse_emulation_unpause(); - - return result; -} diff --git a/fuse/ui/win32/rollback.h b/fuse/ui/win32/rollback.h deleted file mode 100644 index bf1f1f8..0000000 --- a/fuse/ui/win32/rollback.h +++ /dev/null @@ -1,25 +0,0 @@ -/* rollback.h: select a rollback point - Copyright (c) 2008 Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#define IDD_ROLLBACK 1600 -#define IDC_ROLLBACK_LV 1601 diff --git a/fuse/ui/win32/rollback.rc b/fuse/ui/win32/rollback.rc deleted file mode 100644 index bd6bb00..0000000 --- a/fuse/ui/win32/rollback.rc +++ /dev/null @@ -1,35 +0,0 @@ -/* rollback.rc: select a rollback point - Copyright (c) 2008 Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include "rollback.h" - -IDD_ROLLBACK DIALOGEX 0,0,125,100 -STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_FIXEDSYS | WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "Fuse - Select Rollback Point" -FONT 8,"Ms Shell Dlg 2",400,0,1 -BEGIN - CONTROL "",IDC_ROLLBACK_LV,"SysListView32",WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_REPORT,0,0,125,75, WS_EX_CLIENTEDGE - DEFPUSHBUTTON "OK",IDOK,5,80,50,14 - PUSHBUTTON "Cancel",IDCANCEL,70,80,50,14 -END diff --git a/fuse/ui/win32/roms.c b/fuse/ui/win32/roms.c deleted file mode 100644 index 81e0b2c..0000000 --- a/fuse/ui/win32/roms.c +++ /dev/null @@ -1,269 +0,0 @@ -/* roms.c: ROM selector dialog box - Copyright (c) 2003-2008 Philip Kendall, Marek Januszewski - Copyright (c) 2015 Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include "fuse.h" -#include "roms.h" -#include "settings.h" -#include "ui/ui.h" -#include "win32internals.h" - -static void add_rom( HWND hwndDlg, size_t start, size_t row, - int is_peripheral ); -static void select_new_rom( HWND hedit ); -static void roms_done( HWND hwndDlg, LONG_PTR lParam ); -static INT_PTR CALLBACK roms_proc( HWND hwndDlg, UINT uMsg, - WPARAM wParam, LPARAM lParam ); -static void roms_init( HWND hwndDlg, LPARAM lParam ); - -/* FIXME: use GWL_USERDATA whenever more suitable, and use - MapDialogRect whenever drawing the interface at runtime (options - dialog for example */ - -/* The edit boxes used to display the current ROMs */ -static HWND rom[ SETTINGS_ROM_COUNT ]; - -struct callback_info { - - size_t start, n; - int is_peripheral; - TCHAR title[ 256 ]; - -}; - -int -menu_select_roms_with_title( const char *title, size_t start, size_t n, - int is_peripheral ) -{ - struct callback_info info; - - /* Firstly, stop emulation */ - fuse_emulation_pause(); - - _sntprintf( info.title, 256, "Fuse - Select ROMs - %s", title ); - info.start = start; - info.n = n; - info.is_peripheral = is_peripheral; - - DialogBoxParam( fuse_hInstance, MAKEINTRESOURCE( IDD_ROMS ), fuse_hWnd, - ( DLGPROC ) roms_proc, ( LPARAM ) &info ); - - /* And then carry on with emulation again */ - fuse_emulation_unpause(); - - return 0; -} - -static INT_PTR CALLBACK -roms_proc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) -{ - HWND hedit; - - switch( uMsg ) { - - case WM_INITDIALOG: - roms_init( hwndDlg, lParam ); - /* save callback_info in userdata of this dialog */ - SetWindowLongPtr( hwndDlg, GWLP_USERDATA, ( LONG_PTR ) lParam ); - return FALSE; - - case WM_COMMAND: - switch( LOWORD( wParam ) ) { - - case IDOK: - roms_done( hwndDlg, GetWindowLongPtr( ( HWND ) hwndDlg, GWLP_USERDATA ) ); - EndDialog( hwndDlg, 0 ); - return 0; - - case IDCANCEL: - EndDialog( hwndDlg, 0 ); - return 0; - - default: - if( HIWORD( wParam ) == BN_CLICKED ) { - hedit = ( HWND ) GetWindowLongPtr( ( HWND ) lParam, GWLP_USERDATA ); - if( hedit > 0 ) { - select_new_rom( hedit ); - return 0; - } - } - break; - } - break; - - case WM_CLOSE: - EndDialog( hwndDlg, 0 ); - return 0; - } - return FALSE; -} - -static void -roms_init( HWND hwndDlg, LPARAM lParam ) -{ - size_t i; - struct callback_info *info; - - info = ( struct callback_info * ) lParam; - - for( i = 0; i < info->n; i++ ) - add_rom( hwndDlg, info->start, i, info->is_peripheral ); - - /* Move the OK and Cancel buttons */ - RECT rect; - - rect.left = 25; rect.top = ( info->n * 30 ) + 5; - rect.right = 25 + 50; rect.bottom = ( info->n * 30 ) + 5 + 14; - MapDialogRect( hwndDlg, &rect ); - MoveWindow( GetDlgItem( hwndDlg, IDOK ), - rect.left, rect.top, - rect.right - rect.left, rect.bottom - rect.top, - FALSE ); - - rect.left = 85; rect.top = ( info->n * 30 ) + 5; - rect.right = 85 + 50; rect.bottom = ( info->n * 30 ) + 5 + 14; - MapDialogRect( hwndDlg, &rect ); - MoveWindow( GetDlgItem( hwndDlg, IDCANCEL ), - rect.left, rect.top, - rect.right - rect.left, rect.bottom - rect.top, - FALSE ); - - /* resize the dialog as needed */ - RECT window_rect, client_rect; - - GetWindowRect( hwndDlg, &window_rect ); - GetClientRect( hwndDlg, &client_rect ); - - rect.left = 0; rect.top = 0; - rect.right = 163; rect.bottom = ( info->n * 30 ) + 24; - MapDialogRect( hwndDlg, &rect ); - - /* rect now contains the size of the client area in pixels, - now add window's absolute position on the screen */ - rect.left += window_rect.left; - rect.top += window_rect.top; - - /* now just add the difference between client area and window area */ - rect.right += ( window_rect.right - window_rect.left ) - - ( client_rect.right - client_rect.left ); - rect.bottom += ( window_rect.bottom - window_rect.top ) - - ( client_rect.bottom - client_rect.top ); - - /* MoveWindow doesn't really take rect, instead it's X, Y, sizeX and sizeY */ - MoveWindow( hwndDlg, rect.left, rect.top, rect.right, rect.bottom, FALSE ); -} - -static void -add_rom( HWND hwndDlg, size_t start, size_t row, int is_peripheral ) -{ - RECT rect; - HFONT font; - HWND hgroup, hedit, hbutton; - TCHAR buffer[ 80 ], **setting; - - _sntprintf( buffer, 80, "ROM %lu", (unsigned long)row ); - - font = ( HFONT ) SendMessage( hwndDlg, WM_GETFONT, 0, 0 ); - - /* create a groupbox */ - rect.left = 0; rect.top = ( row * 30 ); - rect.right = 160; rect.bottom = ( row * 30 ) + 30; - MapDialogRect( hwndDlg, &rect ); - hgroup = CreateWindowEx( 0, WC_BUTTON, buffer, - WS_VISIBLE | WS_CHILD | BS_GROUPBOX, - rect.left, rect.top, - rect.right - rect.left, rect.bottom - rect.top, - hwndDlg, 0, fuse_hInstance, 0 ); - SendMessage( hgroup, WM_SETFONT, ( WPARAM ) font, FALSE ); - - /* create an edit */ - setting = settings_get_rom_setting( &settings_current, start + row, - is_peripheral ); - - rect.left = 5; rect.top = ( row * 30 ) + 10; - rect.right = 5 + 110; rect.bottom = ( row * 30 ) + 10 + 14; - MapDialogRect( hwndDlg, &rect ); - hedit = CreateWindowEx( 0, WC_EDIT, *setting, - WS_VISIBLE | WS_CHILD | WS_TABSTOP - | WS_BORDER | ES_AUTOHSCROLL, - rect.left, rect.top, - rect.right - rect.left, rect.bottom - rect.top, - hwndDlg, 0, fuse_hInstance, 0 ); - SendMessage( hedit, WM_SETFONT, ( WPARAM ) font, FALSE ); - - rom[ row ] = hedit; - - /* create a select... button */ - rect.left = 120; rect.top = ( row * 30 ) + 10; - rect.right = 120 + 35; rect.bottom = ( row * 30 ) + 10 + 14; - MapDialogRect( hwndDlg, &rect ); - hbutton = CreateWindowEx( 0, WC_BUTTON, TEXT( "Select..." ), - WS_VISIBLE | WS_CHILD | WS_TABSTOP, - rect.left, rect.top, - rect.right - rect.left, rect.bottom - rect.top, - hwndDlg, 0, fuse_hInstance, 0 ); - SendMessage( hbutton, WM_SETFONT, ( WPARAM ) font, FALSE ); - - /* associate handle to the edit box with each Select button as user data */ - SetWindowLongPtr( hbutton, GWLP_USERDATA, ( LONG_PTR ) hedit ); -} - -static void -select_new_rom( HWND hedit ) -{ - TCHAR *filename; - - filename = ui_get_open_filename( "Fuse - Select ROM" ); - if( !filename ) return; - - SendMessage( hedit, WM_SETTEXT, 0, ( LPARAM ) filename ); -} - -static void -roms_done( HWND hwndDlg, LONG_PTR lParam ) -{ - size_t i; - - TCHAR **setting; TCHAR *string; - size_t string_len; - - struct callback_info *info = ( struct callback_info * ) lParam; - - for( i = 0; i < info->n; i++ ) { - - setting = settings_get_rom_setting( &settings_current, info->start + i, - info->is_peripheral ); - - string_len = SendMessage( rom[i], WM_GETTEXTLENGTH, 0, 0 ); - string = malloc( sizeof( TCHAR ) * ( string_len + 1 ) ); - SendMessage( rom[i], WM_GETTEXT, string_len + 1, ( LPARAM ) string ); - - settings_set_string( setting, string ); - free( string ); - } -} diff --git a/fuse/ui/win32/roms.h b/fuse/ui/win32/roms.h deleted file mode 100644 index 7466063..0000000 --- a/fuse/ui/win32/roms.h +++ /dev/null @@ -1,24 +0,0 @@ -/* roms.h: ROM selector dialog box - Copyright (c) 2008 Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#define IDD_ROMS 1100 diff --git a/fuse/ui/win32/roms.rc b/fuse/ui/win32/roms.rc deleted file mode 100644 index c422a4a..0000000 --- a/fuse/ui/win32/roms.rc +++ /dev/null @@ -1,46 +0,0 @@ -/* roms.rc: ROM selector dialog box - Copyright (c) 2008 Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include "roms.h" - -IDD_ROMS DIALOGEX 0,0,163,84 -STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_FIXEDSYS | WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "Fuse - Select ROMs" -FONT 8,"Ms Shell Dlg 2",400,0,1 -BEGIN -/* this is created at runtime in roms.c - using the positions and sizes like below */ -/* - GROUPBOX "ROM 0",IDC_STATIC,0,0,160,30 - EDITTEXT IDC_EDIT1,5,10,110,16,ES_AUTOHSCROLL - PUSHBUTTON "Select...",IDC_BUTTON1,120,10,35,14 - - GROUPBOX "ROM 1",IDC_STATIC,0,30,160,30 - EDITTEXT IDC_EDIT2,5,40,110,16,ES_AUTOHSCROLL - PUSHBUTTON "Select...",IDC_BUTTON2,120,40,35,14 -*/ - - DEFPUSHBUTTON "OK",IDOK,25,70,50,14 - PUSHBUTTON "Cancel",IDCANCEL,85,65,50,14 -END diff --git a/fuse/ui/win32/select_template.h b/fuse/ui/win32/select_template.h deleted file mode 100644 index 3297723..0000000 --- a/fuse/ui/win32/select_template.h +++ /dev/null @@ -1,25 +0,0 @@ -/* select_template.h: Machine Select dialog box - Copyright (c) 2008 Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#define IDD_SELECT_DIALOG 1000 -#define IDC_SELECT_OFFSET 1001 diff --git a/fuse/ui/win32/select_template.rc b/fuse/ui/win32/select_template.rc deleted file mode 100644 index 2effb3f..0000000 --- a/fuse/ui/win32/select_template.rc +++ /dev/null @@ -1,35 +0,0 @@ -/* select_template.rc: Machine Select dialog box - Copyright (c) 2008 Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include "select_template.h" - -IDD_SELECT_DIALOG DIALOGEX 0,0,177,247 -STYLE DS_MODALFRAME | DS_SETFONT | DS_CENTER | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "Fuse - Select" -FONT 8,"Ms Shell Dlg 2",400,0,1 -BEGIN -/* those will be generated at runtime on WM_INITDIALOG - easier to control the size and position */ -/* DEFPUSHBUTTON "&OK",IDOK,6,193,75,23 */ -/* PUSHBUTTON "&Cancel",IDCANCEL,90,193,75,23 */ -END diff --git a/fuse/ui/win32/statusbar.c b/fuse/ui/win32/statusbar.c deleted file mode 100644 index bb79925..0000000 --- a/fuse/ui/win32/statusbar.c +++ /dev/null @@ -1,289 +0,0 @@ -/* statusbar.c: routines for updating the status bar - Copyright (c) 2004-2008 Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include - -#include "settings.h" -#include "ui/ui.h" -#include "win32internals.h" - -HBITMAP - icon_tape_inactive, icon_tape_active, - icon_mdr_inactive, icon_mdr_active, - icon_disk_inactive, icon_disk_active, - icon_pause_inactive, icon_pause_active, - icon_mouse_inactive, icon_mouse_active; - -ui_statusbar_item icons_order[5] = { - UI_STATUSBAR_ITEM_MOUSE, - UI_STATUSBAR_ITEM_PAUSED, - UI_STATUSBAR_ITEM_DISK, - UI_STATUSBAR_ITEM_MICRODRIVE, - UI_STATUSBAR_ITEM_TAPE, -}; - -ui_statusbar_state icons_status[5] = { - UI_STATUSBAR_STATE_NOT_AVAILABLE, /* disk */ - UI_STATUSBAR_STATE_NOT_AVAILABLE, /* microdrive */ - UI_STATUSBAR_STATE_NOT_AVAILABLE, /* mouse */ - UI_STATUSBAR_STATE_NOT_AVAILABLE, /* paused */ - UI_STATUSBAR_STATE_NOT_AVAILABLE /* tape */ -}; - -int icons_part_width = 140; /* will be calculated dynamically later */ -int icons_part_height = 27; -int icons_part_margin = 2; - -/* Status bar handle */ -HWND fuse_hStatusWindow; - -void -win32statusbar_create( HWND hWnd ) -{ - DWORD dwStyle; - - /* FIXME: destroy those icons later on using DeleteObject */ - - icon_tape_inactive = LoadImage( fuse_hInstance, "win32bmp_tape_inactive", - IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); - icon_tape_active = LoadImage( fuse_hInstance, "win32bmp_tape_active", - IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); - - icon_mdr_inactive = LoadImage( fuse_hInstance, "win32bmp_mdr_inactive", - IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); - icon_mdr_active = LoadImage( fuse_hInstance, "win32bmp_mdr_active", - IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); - - icon_disk_inactive = LoadImage( fuse_hInstance, "win32bmp_disk_inactive", - IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); - icon_disk_active = LoadImage( fuse_hInstance, "win32bmp_disk_active", - IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); - - icon_pause_inactive = LoadImage( fuse_hInstance, "win32bmp_pause_inactive", - IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); - icon_pause_active = LoadImage( fuse_hInstance, "win32bmp_pause_active", - IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); - - icon_mouse_inactive = LoadImage( fuse_hInstance, "win32bmp_mouse_inactive", - IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); - icon_mouse_active = LoadImage( fuse_hInstance, "win32bmp_mouse_active", - IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); - - dwStyle = WS_CHILD | SBARS_SIZEGRIP; - if( settings_current.statusbar ) dwStyle = dwStyle | WS_VISIBLE; - - fuse_hStatusWindow = CreateWindowEx( 0, STATUSCLASSNAME, NULL, dwStyle, - 0, 0, 0, 0, hWnd, (HMENU)ID_STATUSBAR, - fuse_hInstance, NULL ); - - /* minimum size of the status bar is the height of the highest icon */ - SendMessage( fuse_hStatusWindow, SB_SETMINHEIGHT, icons_part_height, 0 ); - - /* force redraw to apply the minimum height */ - SendMessage( fuse_hStatusWindow, WM_SIZE, 0, 0 ); -} - -int -win32statusbar_set_visibility( int visible ) -{ - int current_state; - - current_state = IsWindowVisible( fuse_hStatusWindow ); - if( current_state == visible ) return 0; - - if( visible ) { - ShowWindow( fuse_hStatusWindow, SW_SHOW ); - } else { - ShowWindow( fuse_hStatusWindow, SW_HIDE ); - } - - /* Update main window size */ - win32ui_fuse_resize( win32display_scaled_width(), win32display_scaled_height() ); - - return 0; -} - -void -win32statusbar_update_machine( const char *name ) -{ - SendMessage( fuse_hStatusWindow, SB_SETTEXT, (WPARAM) 0, (LPARAM) name ); -} - -int -ui_statusbar_update( ui_statusbar_item item, ui_statusbar_state state ) -{ - /* Fix flickering on +2A, +3 and +3e machines because of high refresh rate */ - if( item == UI_STATUSBAR_ITEM_DISK && icons_status[ item ] == state ) return 0; - - icons_status[ item ] = state; - - SendMessage( fuse_hStatusWindow, SB_SETTEXT, 1 | SBT_OWNERDRAW, 0 ); - - return 0; -} - -int -ui_statusbar_update_speed( float speed ) -{ - TCHAR buffer[8]; - - _sntprintf( buffer, 8, "\t%3.0f%%", speed ); /* \t centers the text */ - SendMessage( fuse_hStatusWindow, SB_SETTEXT, (WPARAM) 2, - (LPARAM) buffer); - - return 0; -} - -void -win32statusbar_redraw( HWND hWnd, LPARAM lParam ) -{ - DRAWITEMSTRUCT* di; - HDC src_dc, dest_dc, mask_dc; - RECT rc_item; - HBITMAP src_bmp, src_bmp_mask; - HBITMAP old_bmp, old_bmp_mask; - BITMAP bmp; - size_t i; - int new_icons_part_width; - - src_bmp = 0; - - di = ( DRAWITEMSTRUCT* ) lParam; - dest_dc = di->hDC; - rc_item = di->rcItem; - - new_icons_part_width = 0; - - for( i=0; i<5; i++ ) { - - switch( icons_order[ i ] ) { - case UI_STATUSBAR_ITEM_DISK: - switch( icons_status[ UI_STATUSBAR_ITEM_DISK ] ) { - case UI_STATUSBAR_STATE_NOT_AVAILABLE: - src_bmp = NULL; break; - case UI_STATUSBAR_STATE_ACTIVE: - src_bmp = icon_disk_active; break; - default: - src_bmp = icon_disk_inactive; break; - } - break; - - case UI_STATUSBAR_ITEM_MOUSE: - src_bmp = ( icons_status[ UI_STATUSBAR_ITEM_MOUSE ] == UI_STATUSBAR_STATE_ACTIVE ? - icon_mouse_active : icon_mouse_inactive ); - break; - - case UI_STATUSBAR_ITEM_PAUSED: - src_bmp = ( icons_status[ UI_STATUSBAR_ITEM_PAUSED ] == UI_STATUSBAR_STATE_ACTIVE ? - icon_pause_active : icon_pause_inactive ); - break; - - case UI_STATUSBAR_ITEM_MICRODRIVE: - switch( icons_status[ UI_STATUSBAR_ITEM_MICRODRIVE ] ) { - case UI_STATUSBAR_STATE_NOT_AVAILABLE: - src_bmp = NULL; break; - case UI_STATUSBAR_STATE_ACTIVE: - src_bmp = icon_mdr_active; break; - default: - src_bmp = icon_mdr_inactive; break; - } - break; - - case UI_STATUSBAR_ITEM_TAPE: - src_bmp = ( icons_status[ UI_STATUSBAR_ITEM_TAPE ] == UI_STATUSBAR_STATE_ACTIVE ? - icon_tape_active : icon_tape_inactive ); - break; - } - - if( src_bmp != NULL ) { - new_icons_part_width += icons_part_margin; - - /* create a bitmap mask on the fly */ - GetObject( src_bmp, sizeof( bmp ), &bmp ); - src_bmp_mask = CreateBitmap( bmp.bmWidth, bmp.bmHeight, 1, 1, NULL ); - src_dc = CreateCompatibleDC( NULL ); - mask_dc = CreateCompatibleDC( NULL ); - old_bmp = SelectObject( src_dc, src_bmp ); - old_bmp_mask = SelectObject( mask_dc, src_bmp_mask ); - SetBkColor( src_dc, RGB( 0, 0, 0 ) ); - BitBlt( mask_dc, 0, 0, bmp.bmWidth, bmp.bmHeight, src_dc, 0, 0, SRCCOPY ); - BitBlt( src_dc, 0, 0, bmp.bmWidth, bmp.bmHeight, mask_dc, 0, 0, SRCINVERT ); - - /* blit the transparent icon onto the status bar */ - SelectObject( mask_dc, src_bmp_mask ); - BitBlt( dest_dc, rc_item.left + new_icons_part_width, - rc_item.top + ( icons_part_height - bmp.bmHeight ) - - ( 2 * icons_part_margin ), - bmp.bmWidth, bmp.bmHeight, mask_dc, 0, 0, SRCAND ); - - SelectObject( src_dc, src_bmp ); - BitBlt( dest_dc, rc_item.left + new_icons_part_width, - rc_item.top + ( icons_part_height - bmp.bmHeight ) - - ( 2 * icons_part_margin ), - bmp.bmWidth, bmp.bmHeight, src_dc, 0, 0, SRCPAINT ); - - SelectObject( src_dc, old_bmp ); - SelectObject( mask_dc, old_bmp_mask ); - DeleteDC( src_dc ); - DeleteDC( mask_dc ); - DeleteObject( src_bmp_mask ); - - new_icons_part_width += bmp.bmWidth; - } - } - - if( new_icons_part_width > 0 ) new_icons_part_width += icons_part_margin; - /* FIXME: if the calculations are correction I shouldn't be adding this */ - new_icons_part_width += ( 2 * icons_part_margin ); - - /* Resize icons part if needed */ - if( new_icons_part_width != icons_part_width ) { - icons_part_width = new_icons_part_width; - win32statusbar_resize( fuse_hWnd, 0, 0 ); - } -} - -void -win32statusbar_resize( HWND hWnd, WPARAM wParam GCC_UNUSED, LPARAM lParam ) -{ - const int speed_bar_width = 70; - RECT rcClient; - - /* divide status bar */ - int parts[3]; - - if( LOWORD( lParam ) > 0 ) { - parts[0] = LOWORD( lParam ); - } - else { - GetClientRect( hWnd, &rcClient ); - parts[0] = rcClient.right - rcClient.left; - } - - parts[0] = parts[0] - icons_part_width - speed_bar_width; - parts[1] = parts[0] + icons_part_width; - parts[2] = parts[1] + speed_bar_width; - SendMessage( fuse_hStatusWindow, SB_SETPARTS, 3, ( LPARAM ) &parts ); -} diff --git a/fuse/ui/win32/statusbar.rc b/fuse/ui/win32/statusbar.rc deleted file mode 100644 index 0c35758..0000000 --- a/fuse/ui/win32/statusbar.rc +++ /dev/null @@ -1,33 +0,0 @@ -/* statusbar.rc: icons for the status bar - Copyright (c) 2004 Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -win32bmp_disk_active BITMAP "ui/win32/icons/disk_active.bmp" -win32bmp_disk_inactive BITMAP "ui/win32/icons/disk_inactive.bmp" -win32bmp_mdr_active BITMAP "ui/win32/icons/mdr_active.bmp" -win32bmp_mdr_inactive BITMAP "ui/win32/icons/mdr_inactive.bmp" -win32bmp_pause_active BITMAP "ui/win32/icons/pause_active.bmp" -win32bmp_pause_inactive BITMAP "ui/win32/icons/pause_inactive.bmp" -win32bmp_tape_active BITMAP "ui/win32/icons/tape_active.bmp" -win32bmp_tape_inactive BITMAP "ui/win32/icons/tape_inactive.bmp" -win32bmp_mouse_active BITMAP "ui/win32/icons/mouse_active.bmp" -win32bmp_mouse_inactive BITMAP "ui/win32/icons/mouse_inactive.bmp" diff --git a/fuse/ui/win32/win32display.c b/fuse/ui/win32/win32display.c deleted file mode 100644 index f8efeae..0000000 --- a/fuse/ui/win32/win32display.c +++ /dev/null @@ -1,525 +0,0 @@ -/* win32display.c: Routines for dealing with the Win32 GDI display - Copyright (c) 2003 Philip Kendall, Marek Januszewski, Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include "display.h" -#include "fuse.h" -#include "machine.h" -#include "settings.h" -#include "ui/ui.h" -#include "ui/uidisplay.h" -#include "ui/scaler/scaler.h" -#include "win32internals.h" - -/* The size of a 1x1 image in units of - DISPLAY_ASPECT WIDTH x DISPLAY_SCREEN_HEIGHT */ -int image_scale; - -/* The height and width of a 1x1 image in pixels */ -int image_width, image_height; - -/* A copy of every pixel on the screen, replaceable by plotting directly into - rgb_image below */ -libspectrum_word - win32display_image[ 2 * DISPLAY_SCREEN_HEIGHT ][ DISPLAY_SCREEN_WIDTH ]; -ptrdiff_t win32display_pitch = DISPLAY_SCREEN_WIDTH * - sizeof( libspectrum_word ); - -/* An RGB image of the Spectrum screen; slightly bigger than the real - screen to handle the smoothing filters which read around each pixel */ -static unsigned char rgb_image[ 4 * 2 * ( DISPLAY_SCREEN_HEIGHT + 4 ) * - ( DISPLAY_SCREEN_WIDTH + 3 ) ]; -static const int rgb_pitch = ( DISPLAY_SCREEN_WIDTH + 3 ) * 4; - -/* The scaled image */ -static unsigned char scaled_image[ MAX_SCALE * DISPLAY_SCREEN_HEIGHT * - MAX_SCALE * DISPLAY_SCREEN_WIDTH * 2 ]; -static const ptrdiff_t scaled_pitch = MAX_SCALE * DISPLAY_SCREEN_WIDTH * 2; - -/* Win32 specific variables */ -static void *win32_pixdata; -static BITMAPINFO fuse_BMI; -static HBITMAP fuse_BMP; -static RECT invalidated_area; - -static const unsigned char rgb_colours[16][3] = { - - { 0, 0, 0 }, - { 0, 0, 192 }, - { 192, 0, 0 }, - { 192, 0, 192 }, - { 0, 192, 0 }, - { 0, 192, 192 }, - { 192, 192, 0 }, - { 192, 192, 192 }, - { 0, 0, 0 }, - { 0, 0, 255 }, - { 255, 0, 0 }, - { 255, 0, 255 }, - { 0, 255, 0 }, - { 0, 255, 255 }, - { 255, 255, 0 }, - { 255, 255, 255 }, - -}; - -libspectrum_dword win32display_colours[16]; -static libspectrum_dword bw_colours[16]; - -/* The current size of the window (in units of DISPLAY_SCREEN_*) */ -static int win32display_current_size=1; - -static int init_colours( void ); -static void register_scalers( int force_scaler ); -static void win32display_load_gfx_mode( void ); - -void -blit( void ) -{ - PAINTSTRUCT ps; - HDC dest_dc, src_dc; - HBITMAP src_bmp; - int x, y, width, height; - - dest_dc = BeginPaint( fuse_hWnd, &ps ); - - x = ps.rcPaint.left; - y = ps.rcPaint.top; - width = ps.rcPaint.right - ps.rcPaint.left; - height = ps.rcPaint.bottom - ps.rcPaint.top; - - if( width && height ) { - src_dc = CreateCompatibleDC( dest_dc ); - src_bmp = SelectObject( src_dc, fuse_BMP ); - - BitBlt( dest_dc, x, y, width, height, src_dc, x, y, SRCCOPY ); - - SelectObject( src_dc, src_bmp ); - DeleteDC( src_dc ); - } - - EndPaint( fuse_hWnd, &ps ); -} - -int -win32display_init( void ) -{ - int x, y, error; - libspectrum_dword black; - - error = init_colours(); if( error ) return error; - - black = settings_current.bw_tv ? bw_colours[0] : win32display_colours[0]; - - for( y = 0; y < DISPLAY_SCREEN_HEIGHT + 4; y++ ) - for( x = 0; x < DISPLAY_SCREEN_WIDTH + 3; x++ ) - *(libspectrum_dword*)( rgb_image + y * rgb_pitch + 4 * x ) = black; - - /* create the back buffer */ - - memset( &fuse_BMI, 0, sizeof( fuse_BMI ) ); - fuse_BMI.bmiHeader.biSize = sizeof( fuse_BMI.bmiHeader ); - fuse_BMI.bmiHeader.biWidth = (size_t)( 0.5 * MAX_SCALE * DISPLAY_SCREEN_WIDTH ); - /* negative to avoid "shep-mode": */ - fuse_BMI.bmiHeader.biHeight = -( MAX_SCALE * DISPLAY_SCREEN_HEIGHT ); - fuse_BMI.bmiHeader.biPlanes = 1; - fuse_BMI.bmiHeader.biBitCount = 32; - fuse_BMI.bmiHeader.biCompression = BI_RGB; - fuse_BMI.bmiHeader.biSizeImage = 0; - fuse_BMI.bmiHeader.biXPelsPerMeter = 0; - fuse_BMI.bmiHeader.biYPelsPerMeter = 0; - fuse_BMI.bmiHeader.biClrUsed = 0; - fuse_BMI.bmiHeader.biClrImportant = 0; - fuse_BMI.bmiColors[0].rgbRed = 0; - fuse_BMI.bmiColors[0].rgbGreen = 0; - fuse_BMI.bmiColors[0].rgbBlue = 0; - fuse_BMI.bmiColors[0].rgbReserved = 0; - - HDC dc = GetDC( fuse_hWnd ); - - fuse_BMP = CreateDIBSection( dc, &fuse_BMI, DIB_RGB_COLORS, &win32_pixdata, - NULL, 0 ); - - ReleaseDC( fuse_hWnd, dc ); - - display_ui_initialised = 1; - - return 0; -} - -static int -init_colours( void ) -{ - size_t i; - - for( i = 0; i < 16; i++ ) { - - unsigned char red, green, blue, grey; - - red = rgb_colours[i][0]; - green = rgb_colours[i][1]; - blue = rgb_colours[i][2]; - - /* Addition of 0.5 is to avoid rounding errors */ - grey = ( 0.299 * red + 0.587 * green + 0.114 * blue ) + 0.5; - -#ifdef WORDS_BIGENDIAN - - win32display_colours[i] = red << 24 | green << 16 | blue << 8; - bw_colours[i] = grey << 24 | grey << 16 | grey << 8; - -#else /* #ifdef WORDS_BIGENDIAN */ - - win32display_colours[i] = red | green << 8 | blue << 16; - bw_colours[i] = grey | grey << 8 | grey << 16; - -#endif /* #ifdef WORDS_BIGENDIAN */ - - } - - return 0; -} - -int -win32display_drawing_area_resize( int width, int height, int force_scaler ) -{ - int size; - - size = width / DISPLAY_ASPECT_WIDTH; - if( size > height / DISPLAY_SCREEN_HEIGHT ) - size = height / DISPLAY_SCREEN_HEIGHT; - - /* If we're the same size as before, no need to do anything else */ - if( size == win32display_current_size ) return 0; - - win32display_current_size = size; - - register_scalers( force_scaler ); - - memset( scaled_image, 0, sizeof( scaled_image ) ); - display_refresh_all(); - - return 0; -} - -int -uidisplay_init( int width, int height ) -{ - const char *machine_name; - - image_width = width; image_height = height; - image_scale = width / DISPLAY_ASPECT_WIDTH; - SetRectEmpty( &invalidated_area ); - - register_scalers( 0 ); - - display_refresh_all(); - - if ( scaler_select_scaler( current_scaler ) ) - scaler_select_scaler( SCALER_NORMAL ); - - win32display_load_gfx_mode(); - - machine_name = libspectrum_machine_name( machine_current->machine ); - win32statusbar_update_machine( machine_name ); - - return 0; -} - -static void -register_scalers( int force_scaler ) -{ - scaler_type scaler; - - scaler_register_clear(); - - if( machine_current->timex ) { - scaler_register( SCALER_HALF ); - scaler_register( SCALER_HALFSKIP ); - scaler_register( SCALER_TIMEXTV ); - scaler_register( SCALER_TIMEX1_5X ); - scaler_register( SCALER_TIMEX2X ); - } else { - scaler_register( SCALER_DOUBLESIZE ); - scaler_register( SCALER_TRIPLESIZE ); - scaler_register( SCALER_QUADSIZE ); - scaler_register( SCALER_TV2X ); - scaler_register( SCALER_TV3X ); - scaler_register( SCALER_TV4X ); - scaler_register( SCALER_PALTV2X ); - scaler_register( SCALER_PALTV3X ); - scaler_register( SCALER_PALTV4X ); - scaler_register( SCALER_HQ2X ); - scaler_register( SCALER_HQ3X ); - scaler_register( SCALER_HQ4X ); - scaler_register( SCALER_ADVMAME2X ); - scaler_register( SCALER_ADVMAME3X ); - scaler_register( SCALER_2XSAI ); - scaler_register( SCALER_SUPER2XSAI ); - scaler_register( SCALER_SUPEREAGLE ); - scaler_register( SCALER_DOTMATRIX ); - } - scaler_register( SCALER_NORMAL ); - scaler_register( SCALER_PALTV ); - - scaler = - scaler_is_supported( current_scaler ) ? current_scaler : SCALER_NORMAL; - - if( force_scaler ) { - switch( win32display_current_size ) { - case 1: scaler = machine_current->timex ? SCALER_HALF : SCALER_NORMAL; - break; - case 2: scaler = machine_current->timex ? SCALER_NORMAL : SCALER_DOUBLESIZE; - break; - case 3: scaler = machine_current->timex ? SCALER_TIMEX1_5X : - SCALER_TRIPLESIZE; - break; - case 4: scaler = machine_current->timex ? SCALER_TIMEX2X : - SCALER_QUADSIZE; - break; - } - } - - scaler_select_scaler( scaler ); -} - -void -uidisplay_frame_end( void ) -{ - if( !IsRectEmpty( &invalidated_area ) ) { - - InvalidateRect( fuse_hWnd, &invalidated_area, FALSE ); - - SetRectEmpty( &invalidated_area ); - - UpdateWindow( fuse_hWnd ); - } -} - -void -uidisplay_area( int x, int y, int w, int h ) -{ - float scale = (float)win32display_current_size / image_scale; - int scaled_x, scaled_y, i, yy; - libspectrum_dword *palette; - - /* Extend the dirty region by 1 pixel for scalers - that "smear" the screen, e.g. 2xSAI */ - if( scaler_flags & SCALER_FLAGS_EXPAND ) - scaler_expander( &x, &y, &w, &h, image_width, image_height ); - - scaled_x = scale * x; scaled_y = scale * y; - - palette = settings_current.bw_tv ? bw_colours : win32display_colours; - - /* Create the RGB image */ - for( yy = y; yy < y + h; yy++ ) { - - libspectrum_dword *rgb; libspectrum_word *display; - - rgb = (libspectrum_dword*)( rgb_image + ( yy + 2 ) * rgb_pitch ); - rgb += x + 1; - - display = &win32display_image[yy][x]; - - for( i = 0; i < w; i++, rgb++, display++ ) *rgb = palette[ *display ]; - } - - /* Create scaled image */ - scaler_proc32( &rgb_image[ ( y + 2 ) * rgb_pitch + 4 * ( x + 1 ) ], - rgb_pitch, - &scaled_image[ scaled_y * scaled_pitch + 4 * scaled_x ], - scaled_pitch, w, h ); - - w *= scale; h *= scale; - - /* Blit to the real screen */ - win32display_area( scaled_x, scaled_y, w, h ); -} - -void -win32display_area(int x, int y, int width, int height) -{ - int disp_x,disp_y; - int bottom, right; - long ofs; - RECT r; - char *pixdata = win32_pixdata; - - bottom = y + height; - right = x + width; - - for( disp_y = y; disp_y < bottom; disp_y++ ) { - for( disp_x = x; disp_x < right; disp_x++ ) { - ofs = ( disp_x << 2 ) + ( disp_y * scaled_pitch ); - - pixdata[ ofs + 0 ] = scaled_image[ ofs + 2 ]; /* blue */ - pixdata[ ofs + 1 ] = scaled_image[ ofs + 1 ]; /* green */ - pixdata[ ofs + 2 ] = scaled_image[ ofs + 0 ]; /* red */ - pixdata[ ofs + 3 ] = 0; /* unused */ - } - } - - /* Mark area for updating */ - SetRect( &r, x, y, right, bottom ); - UnionRect( &invalidated_area, &invalidated_area, &r ); -} - -int -uidisplay_hotswap_gfx_mode( void ) -{ - fuse_emulation_pause(); - - /* Setup the new GFX mode */ - win32display_load_gfx_mode(); - - fuse_emulation_unpause(); - - return 0; -} - -int -uidisplay_end( void ) -{ - return 0; -} - -int -win32display_end( void ) -{ - DeleteObject( fuse_BMP ); - - return 0; -} - -/* Set one pixel in the display */ -void -uidisplay_putpixel( int x, int y, int colour ) -{ - if( machine_current->timex ) { - x <<= 1; y <<= 1; - win32display_image[y ][x ] = colour; - win32display_image[y ][x+1] = colour; - win32display_image[y+1][x ] = colour; - win32display_image[y+1][x+1] = colour; - } else { - win32display_image[y][x] = colour; - } -} - -/* Print the 8 pixels in `data' using ink colour `ink' and paper - colour `paper' to the screen at ( (8*x) , y ) */ -void -uidisplay_plot8( int x, int y, libspectrum_byte data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - x <<= 3; - - if( machine_current->timex ) { - int i; - - x <<= 1; y <<= 1; - for( i=0; i<2; i++,y++ ) { - win32display_image[y][x+ 0] = ( data & 0x80 ) ? ink : paper; - win32display_image[y][x+ 1] = ( data & 0x80 ) ? ink : paper; - win32display_image[y][x+ 2] = ( data & 0x40 ) ? ink : paper; - win32display_image[y][x+ 3] = ( data & 0x40 ) ? ink : paper; - win32display_image[y][x+ 4] = ( data & 0x20 ) ? ink : paper; - win32display_image[y][x+ 5] = ( data & 0x20 ) ? ink : paper; - win32display_image[y][x+ 6] = ( data & 0x10 ) ? ink : paper; - win32display_image[y][x+ 7] = ( data & 0x10 ) ? ink : paper; - win32display_image[y][x+ 8] = ( data & 0x08 ) ? ink : paper; - win32display_image[y][x+ 9] = ( data & 0x08 ) ? ink : paper; - win32display_image[y][x+10] = ( data & 0x04 ) ? ink : paper; - win32display_image[y][x+11] = ( data & 0x04 ) ? ink : paper; - win32display_image[y][x+12] = ( data & 0x02 ) ? ink : paper; - win32display_image[y][x+13] = ( data & 0x02 ) ? ink : paper; - win32display_image[y][x+14] = ( data & 0x01 ) ? ink : paper; - win32display_image[y][x+15] = ( data & 0x01 ) ? ink : paper; - } - } else { - win32display_image[y][x+ 0] = ( data & 0x80 ) ? ink : paper; - win32display_image[y][x+ 1] = ( data & 0x40 ) ? ink : paper; - win32display_image[y][x+ 2] = ( data & 0x20 ) ? ink : paper; - win32display_image[y][x+ 3] = ( data & 0x10 ) ? ink : paper; - win32display_image[y][x+ 4] = ( data & 0x08 ) ? ink : paper; - win32display_image[y][x+ 5] = ( data & 0x04 ) ? ink : paper; - win32display_image[y][x+ 6] = ( data & 0x02 ) ? ink : paper; - win32display_image[y][x+ 7] = ( data & 0x01 ) ? ink : paper; - } -} - -/* Print the 16 pixels in `data' using ink colour `ink' and paper - colour `paper' to the screen at ( (16*x) , y ) */ -void -uidisplay_plot16( int x, int y, libspectrum_word data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - int i; - x <<= 4; y <<= 1; - - for( i=0; i<2; i++,y++ ) { - win32display_image[y][x+ 0] = ( data & 0x8000 ) ? ink : paper; - win32display_image[y][x+ 1] = ( data & 0x4000 ) ? ink : paper; - win32display_image[y][x+ 2] = ( data & 0x2000 ) ? ink : paper; - win32display_image[y][x+ 3] = ( data & 0x1000 ) ? ink : paper; - win32display_image[y][x+ 4] = ( data & 0x0800 ) ? ink : paper; - win32display_image[y][x+ 5] = ( data & 0x0400 ) ? ink : paper; - win32display_image[y][x+ 6] = ( data & 0x0200 ) ? ink : paper; - win32display_image[y][x+ 7] = ( data & 0x0100 ) ? ink : paper; - win32display_image[y][x+ 8] = ( data & 0x0080 ) ? ink : paper; - win32display_image[y][x+ 9] = ( data & 0x0040 ) ? ink : paper; - win32display_image[y][x+10] = ( data & 0x0020 ) ? ink : paper; - win32display_image[y][x+11] = ( data & 0x0010 ) ? ink : paper; - win32display_image[y][x+12] = ( data & 0x0008 ) ? ink : paper; - win32display_image[y][x+13] = ( data & 0x0004 ) ? ink : paper; - win32display_image[y][x+14] = ( data & 0x0002 ) ? ink : paper; - win32display_image[y][x+15] = ( data & 0x0001 ) ? ink : paper; - } -} - -static void -win32display_load_gfx_mode( void ) -{ - float scale; - - scale = scaler_get_scaling_factor( current_scaler ); - win32display_drawing_area_resize( scale * image_width, scale * image_height, 0 ); - win32ui_fuse_resize( scale * image_width, scale * image_height ); - - /* Redraw the entire screen... */ - display_refresh_all(); -} - -int -win32display_scaled_width( void ) -{ - return image_width * win32display_current_size; -} - -int -win32display_scaled_height( void ) -{ - return image_height * win32display_current_size; -} diff --git a/fuse/ui/win32/win32internals.h b/fuse/ui/win32/win32internals.h deleted file mode 100755 index 862dec9..0000000 --- a/fuse/ui/win32/win32internals.h +++ /dev/null @@ -1,147 +0,0 @@ -/* win32internals.h: stuff internal to the Win32 UI - Copyright (c) 2004 Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#ifndef FUSE_WIN32INTERNALS_H -#define FUSE_WIN32INTERNALS_H - -#include -#include -#include -#include - -/* FIXME: this should be included as part of windows.h, but is not - because WIN32_LEAN_AND_MEAN is defined along the way somewhere */ -#include - -#include - -#define ID_STATUSBAR 900 - -/* Reduce listview flickering. Defined from WINVER >= 6.00 */ -#ifndef LVS_EX_DOUBLEBUFFER -#define LVS_EX_DOUBLEBUFFER 0x00010000 -#endif - -/* window handler */ -extern HWND fuse_hWnd; - -/* application instance */ -extern HINSTANCE fuse_hInstance; - -/* status bar handle */ -extern HWND fuse_hStatusWindow; - -/* pokefinder window handle */ -extern HWND fuse_hPFWnd; - -/* debugger window handle */ -extern HWND fuse_hDBGWnd; - -/* about window handle */ -extern HWND fuse_hABOWnd; - -/* - * Display routines (win32display.c) - */ - -/* The biggest size screen (in units of DISPLAY_ASPECT_WIDTH x - DISPLAY_SCREEN_HEIGHT ie a Timex screen is size 2) we will be - creating via the scalers */ -#define MAX_SCALE 4 - -/* The colour palette in use */ -extern libspectrum_dword win32display_colours[16]; - -int win32display_init( void ); -int win32display_end( void ); -int win32display_scaled_height( void ); -int win32display_scaled_width( void ); - - -/* Below variables and functions are shared - between win32display.c and win32ui.c */ - -void win32display_area(int x, int y, int width, int height); -int win32display_drawing_area_resize( int width, int height, int force_scaler ); - -void blit( void ); - -/* - * Keyboard routines (win32keyboard.c) - */ - -void win32keyboard_init( void ); -void win32keyboard_end( void ); -void win32keyboard_keypress( WPARAM wParam, LPARAM lParam ); -void win32keyboard_keyrelease( WPARAM wParam, LPARAM lParam ); - -/* - * Mouse routines (win32mouse.c) - */ - -void win32mouse_position( LPARAM lParam ); -void win32mouse_button( int button, int down ); - -/* - * General user interface routines (win32ui.c) - */ - -void win32ui_fuse_resize( int width, int height ); - -int win32ui_confirm( const char *string ); - -typedef enum win32ui_picture_format { - PICTURE_SCR, - PICTURE_PNG, -} win32ui_picture_format; - -int win32ui_picture( const char *filename, win32ui_picture_format format ); - -int win32ui_get_monospaced_font( HFONT *font ); -void win32ui_set_font( HWND hDlg, int nIDDlgItem, HFONT font ); - -int handle_menu( DWORD cmd, HWND okno ); - -void win32_verror( int is_error ); - -void win32ui_process_messages( int process_queue_once ); - -#define WM_USER_EXIT_PROCESS_MESSAGES WM_USER - -/* - * Statusbar routines (statusbar.c) - */ - -void win32statusbar_create( HWND hWnd ); -int win32statusbar_set_visibility( int visible ); -void win32statusbar_redraw( HWND hWnd, LPARAM lParam ); -void win32statusbar_resize( HWND hWnd, WPARAM wParam, LPARAM lParam ); -void win32statusbar_update_machine( const char *name ); - -/* - * Dialog box reset - */ - -void win32ui_pokefinder_clear( void ); - -#endif /* #ifndef FUSE_WIN32INTERNALS_H */ diff --git a/fuse/ui/win32/win32joystick.c b/fuse/ui/win32/win32joystick.c deleted file mode 100644 index 09aa5c4..0000000 --- a/fuse/ui/win32/win32joystick.c +++ /dev/null @@ -1,474 +0,0 @@ -/* win32joystick.c: Joystick emulation - Copyright (c) 2003-2008 Darren Salt, Philip Kendall, Marek Januszewski - Copyright (c) 2015 UB880D - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - - Darren: linux@youmustbejoking.demon.co.uk - -*/ - -#include - -#include -#include - -#include "fuse.h" -#include "input.h" -#include "keyboard.h" -#include "menu.h" -#include "peripherals/joystick.h" -#include "settings.h" -#include "win32internals.h" - -#include "win32joystick.h" - -#if !defined USE_JOYSTICK || defined HAVE_JSW_H - -#include "../uijoystick.c" - -#else /* #if !defined USE_JOYSTICK || defined HAVE_JSW_H */ - -/* Functions to handle Joystick events */ -#include "ui/ui.h" -#include "ui/uijoystick.h" - -static void do_axis( int which, WORD value, - input_key negative, input_key positive ); - -int -ui_joystick_init( void ) -{ - int retval; - JOYINFO joyinfo; - - retval = joyGetNumDevs(); - - if( retval > 0 ) { - - if( joyGetPos( JOYSTICKID1, &joyinfo ) == JOYERR_NOERROR ) { - if( joySetCapture( fuse_hWnd, JOYSTICKID1, 0, FALSE ) != JOYERR_NOERROR ) { - ui_error( UI_ERROR_ERROR, "Couldn't start capture for joystick 1" ); - return 0; - } - } else { - return 0; - } - - } - - if( retval >= 2 ) { - - retval = 2; - - if( joyGetPos( JOYSTICKID2, &joyinfo ) == JOYERR_NOERROR ) { - if( joySetCapture( fuse_hWnd, JOYSTICKID2, 0, FALSE ) != JOYERR_NOERROR ) { - ui_error( UI_ERROR_ERROR, "Couldn't start capture for joystick 2" ); - return 1; - } - } else { - return 1; - } - - } - - return retval; -} - -void -ui_joystick_poll( void ) -{ - /* No action needed; joysticks already handled by the Window messages - sent by mmsystem */ -} - -void -win32joystick_buttonevent( int which_joystick, int button_down, - unsigned int wParam ) -{ - input_event_t event; - int button = 0; - - /* FIXME: buttons higher than 4 are not catched through window messages. - We should use DirectInput. Polling with JoyGetPosEx would take - up to 8 milliseconds in analog joysticks (digital joysticks just - a few clock cycles) */ - if( wParam & JOY_BUTTON1CHG ) button = INPUT_JOYSTICK_FIRE_1; - else if( wParam & JOY_BUTTON2CHG ) button = INPUT_JOYSTICK_FIRE_2; - else if( wParam & JOY_BUTTON3CHG ) button = INPUT_JOYSTICK_FIRE_3; - else if( wParam & JOY_BUTTON4CHG ) button = INPUT_JOYSTICK_FIRE_4; - else return; /* Fuse for Windows supports up to 4 joystick buttons */ - - event.types.joystick.which = which_joystick; - event.type = button_down - ? INPUT_EVENT_JOYSTICK_PRESS : INPUT_EVENT_JOYSTICK_RELEASE; - event.types.joystick.button = button; - input_event( &event ); -} - -void -win32joystick_move( int which_joystick, unsigned short pos_x, - unsigned short pos_y ) -{ - do_axis( which_joystick, pos_x, - INPUT_JOYSTICK_LEFT, INPUT_JOYSTICK_RIGHT ); - do_axis( which_joystick, pos_y, - INPUT_JOYSTICK_UP, INPUT_JOYSTICK_DOWN ); -} - -static void -do_axis( int which, WORD value, input_key negative, input_key positive ) -{ - input_event_t event1, event2; - - event1.types.joystick.which = event2.types.joystick.which = which; - - event1.types.joystick.button = negative; - event2.types.joystick.button = positive; - - /* MS Windows sends a value between 0 and 65535, hopefully those will work */ - if( value > 49152 ) { - event1.type = INPUT_EVENT_JOYSTICK_RELEASE; - event2.type = INPUT_EVENT_JOYSTICK_PRESS; - } else if( value < 16384 ) { - event1.type = INPUT_EVENT_JOYSTICK_PRESS; - event2.type = INPUT_EVENT_JOYSTICK_RELEASE; - } else { - event1.type = INPUT_EVENT_JOYSTICK_RELEASE; - event2.type = INPUT_EVENT_JOYSTICK_RELEASE; - } - - input_event( &event1 ); - input_event( &event2 ); -} - -void -ui_joystick_end( void ) -{ - /* Initialization and unitialization is handled by MS Windows */ -} - -#endif /* #if !defined USE_JOYSTICK || defined HAVE_JSW_H */ - -/* Win32 UI functions to handle Joystick options menus */ -struct button_info { - int *setting; - TCHAR name[80]; - HWND label; /* this is the label on the button */ - HWND static_label; /* this is the label on the static */ - HWND frame; - keyboard_key_name key; -}; - -struct joystick_info { - - int *type; - HWND radio[ JOYSTICK_TYPE_COUNT ]; - - struct button_info button[NUM_JOY_BUTTONS]; -}; - -static void setup_info( struct joystick_info *info, int action ); -static INT_PTR CALLBACK dialog_proc( HWND hwndDlg, UINT uMsg, - WPARAM wParam, LPARAM lParam ); -static void dialog_init( HWND hwndDlg, struct joystick_info *info ); -static void create_joystick_type_selector( struct joystick_info *info, - HWND hwndDlg ); -static void -create_fire_button_selector( const TCHAR *title, struct button_info *info, - HWND hwndDlg ); -static void set_key_text( HWND hlabel, keyboard_key_name key ); -static void joystick_done( LONG_PTR user_data ); -static void show_key_selection_popoup( HWND hwndDlg, LPARAM lParam ); - -void -menu_options_joysticks_select( int action ) -{ - struct joystick_info info; - - fuse_emulation_pause(); - - setup_info( &info, action ); - - DialogBoxParam( fuse_hInstance, MAKEINTRESOURCE( IDD_JOYSTICKS ), - fuse_hWnd, dialog_proc, ( LPARAM ) &info ); - - fuse_emulation_unpause(); -} - -static INT_PTR CALLBACK -dialog_proc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) -{ - switch( uMsg ) { - - case WM_INITDIALOG: - SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam ); - dialog_init( hwndDlg, ( struct joystick_info * ) lParam ); - return FALSE; - - case WM_COMMAND: - switch( LOWORD( wParam ) ) { - case IDC_JOYSTICKS_BUTTON_BUTTON1: - case IDC_JOYSTICKS_BUTTON_BUTTON2: - case IDC_JOYSTICKS_BUTTON_BUTTON3: - case IDC_JOYSTICKS_BUTTON_BUTTON4: - case IDC_JOYSTICKS_BUTTON_BUTTON5: - case IDC_JOYSTICKS_BUTTON_BUTTON6: - case IDC_JOYSTICKS_BUTTON_BUTTON7: - case IDC_JOYSTICKS_BUTTON_BUTTON8: - case IDC_JOYSTICKS_BUTTON_BUTTON9: - case IDC_JOYSTICKS_BUTTON_BUTTON10: - case IDC_JOYSTICKS_BUTTON_BUTTON11: - case IDC_JOYSTICKS_BUTTON_BUTTON12: - case IDC_JOYSTICKS_BUTTON_BUTTON13: - case IDC_JOYSTICKS_BUTTON_BUTTON14: - case IDC_JOYSTICKS_BUTTON_BUTTON15: - show_key_selection_popoup( hwndDlg, lParam ); - return 0; - - case IDOK: - joystick_done( GetWindowLongPtr( hwndDlg, GWLP_USERDATA ) ); - EndDialog( hwndDlg, 0 ); - return 0; - - case IDCANCEL: - EndDialog( hwndDlg, 0 ); - return 0; - } - break; - - case WM_CLOSE: - EndDialog( hwndDlg, 0 ); - return 0; - } - return FALSE; -} - -static void -dialog_init( HWND hwndDlg, struct joystick_info *info ) -{ - size_t i; - create_joystick_type_selector( info, hwndDlg ); - - for( i = 0; i < NUM_JOY_BUTTONS; i++ ) { - - info->button[i].label = GetDlgItem( hwndDlg, - IDC_JOYSTICKS_BUTTON_BUTTON1 + i ); - info->button[i].static_label = GetDlgItem( hwndDlg, - IDC_JOYSTICKS_STATIC_BUTTON1 + i ); - info->button[i].frame = GetDlgItem( hwndDlg, - IDC_JOYSTICKS_GROUP_BUTTON1 + i ); - if( info->button[i].setting ) { - create_fire_button_selector( info->button[i].name, &( info->button[i] ), - hwndDlg ); - } - else { - /* disable the button configuration part of the dialog */ - SendMessage( info->button[i].label, WM_SETTEXT, - 0, ( LPARAM ) TEXT( "N/A" ) ); - SendMessage( info->button[i].static_label, WM_SETTEXT, - 0, ( LPARAM ) TEXT( "N/A" ) ); - EnableWindow( info->button[i].label, FALSE ); - EnableWindow( info->button[i].static_label, FALSE ); - EnableWindow( GetDlgItem( hwndDlg, - IDC_JOYSTICKS_GROUP_BUTTON1 + i ), FALSE ); - } - } -} - -static void -setup_info( struct joystick_info *info, int action ) -{ - size_t i; - - switch( action ) { - - case 1: - info->type = &( settings_current.joystick_1_output ); - info->button[0].setting = &( settings_current.joystick_1_fire_1 ); - info->button[1].setting = &( settings_current.joystick_1_fire_2 ); - info->button[2].setting = &( settings_current.joystick_1_fire_3 ); - info->button[3].setting = &( settings_current.joystick_1_fire_4 ); - info->button[4].setting = &( settings_current.joystick_1_fire_5 ); - info->button[5].setting = &( settings_current.joystick_1_fire_6 ); - info->button[6].setting = &( settings_current.joystick_1_fire_7 ); - info->button[7].setting = &( settings_current.joystick_1_fire_8 ); - info->button[8].setting = &( settings_current.joystick_1_fire_9 ); - info->button[9].setting = &( settings_current.joystick_1_fire_10 ); - info->button[10].setting = &( settings_current.joystick_1_fire_11 ); - info->button[11].setting = &( settings_current.joystick_1_fire_12 ); - info->button[12].setting = &( settings_current.joystick_1_fire_13 ); - info->button[13].setting = &( settings_current.joystick_1_fire_14 ); - info->button[14].setting = &( settings_current.joystick_1_fire_15 ); - for( i = 0; i < NUM_JOY_BUTTONS; i++ ) - _sntprintf( info->button[i].name, 80, "Button %lu", - (unsigned long)i + 1 ); - break; - - case 2: - info->type = &( settings_current.joystick_2_output ); - info->button[0].setting = &( settings_current.joystick_2_fire_1 ); - info->button[1].setting = &( settings_current.joystick_2_fire_2 ); - info->button[2].setting = &( settings_current.joystick_2_fire_3 ); - info->button[3].setting = &( settings_current.joystick_2_fire_4 ); - info->button[4].setting = &( settings_current.joystick_2_fire_5 ); - info->button[5].setting = &( settings_current.joystick_2_fire_6 ); - info->button[6].setting = &( settings_current.joystick_2_fire_7 ); - info->button[7].setting = &( settings_current.joystick_2_fire_8 ); - info->button[8].setting = &( settings_current.joystick_2_fire_9 ); - info->button[9].setting = &( settings_current.joystick_2_fire_10 ); - info->button[10].setting = &( settings_current.joystick_2_fire_11 ); - info->button[11].setting = &( settings_current.joystick_2_fire_12 ); - info->button[12].setting = &( settings_current.joystick_2_fire_13 ); - info->button[13].setting = &( settings_current.joystick_2_fire_14 ); - info->button[14].setting = &( settings_current.joystick_2_fire_15 ); - for( i = 0; i < NUM_JOY_BUTTONS; i++ ) - _sntprintf( info->button[i].name, 80, "Button %lu", - (unsigned long)i + 1 ); - break; - - case 3: - info->type = &( settings_current.joystick_keyboard_output ); - info->button[0].setting = &( settings_current.joystick_keyboard_up ); - _sntprintf( info->button[0].name, 80, "Button for UP" ); - info->button[1].setting = &( settings_current.joystick_keyboard_down ); - _sntprintf( info->button[1].name, 80, "Button for DOWN" ); - info->button[2].setting = &( settings_current.joystick_keyboard_left ); - _sntprintf( info->button[2].name, 80, "Button for LEFT" ); - info->button[3].setting = &( settings_current.joystick_keyboard_right ); - _sntprintf( info->button[3].name, 80, "Button for RIGHT" ); - info->button[4].setting = &( settings_current.joystick_keyboard_fire ); - _sntprintf( info->button[4].name, 80, "Button for FIRE" ); - for( i = 5; i < NUM_JOY_BUTTONS; i++ ) info->button[i].setting = NULL; - break; - - } -} - -static void -create_joystick_type_selector( struct joystick_info *info, HWND hwndDlg ) -{ - size_t i; - HFONT font; - RECT rect; - - font = ( HFONT ) SendMessage( hwndDlg, WM_GETFONT, 0, 0 ); - - for( i = 0; i < JOYSTICK_TYPE_COUNT; i++ ) { - - rect.left = 5; rect.top = i * 10 + 10 ; - rect.right = 5 + 45; rect.bottom = ( i * 10 ) + 10 + 10; - MapDialogRect( hwndDlg, &rect ); - info->radio[ i ] = CreateWindowEx( 0, WC_BUTTON, joystick_name[ i ], - WS_VISIBLE | WS_CHILD | - WS_TABSTOP | BS_AUTORADIOBUTTON, - rect.left, rect.top, - rect.right - rect.left, - rect.bottom - rect.top, - hwndDlg, 0, fuse_hInstance, 0 ); - SendMessage( info->radio[ i ], WM_SETFONT, ( WPARAM ) font, FALSE ); - - if( i == *( info->type ) ) - SendMessage( info->radio[ i ], BM_SETCHECK, BST_CHECKED, 0 ); - } - - rect.left = 0; rect.top = 0; - rect.right = 60; rect.bottom = ( i * 10 ) + 10 + 10 + 5; - MapDialogRect( hwndDlg, &rect ); - MoveWindow( GetDlgItem( hwndDlg, IDR_JOYSTICKS_POPUP ), - rect.left, rect.top, - rect.right - rect.left, rect.bottom - rect.top, - FALSE ); -} - -static void -create_fire_button_selector( const TCHAR *title, struct button_info *info, - HWND hwndDlg ) -{ - SendMessage( info->frame, WM_SETTEXT, 0, ( LPARAM ) title ); - info->key = *info->setting; - set_key_text( info->label, info->key ); - set_key_text( info->static_label, info->key ); - - SetWindowLongPtr( info->label, GWLP_USERDATA, ( LONG_PTR ) info ); -} - -static void -set_key_text( HWND hlabel, keyboard_key_name key ) -{ - const TCHAR *text; - TCHAR buffer[40]; - - text = keyboard_key_text( key ); - - _sntprintf( buffer, 40, "%s", text ); - - SendMessage( hlabel, WM_SETTEXT, 0, ( LPARAM ) buffer ); -} - -static void -joystick_done( LONG_PTR user_data ) -{ - struct joystick_info *info = ( struct joystick_info * ) user_data; - - int i; - - for( i = 0; i < NUM_JOY_BUTTONS; i++ ) - if( info->button[i].setting ) - *info->button[i].setting = info->button[i].key; - - for( i = 0; i < JOYSTICK_TYPE_COUNT; i++ ) { - - if( SendMessage( info->radio[ i ], BM_GETCHECK, 0, 0 ) == BST_CHECKED ) { - *( info->type ) = i; - return; - } - } -} - -static void -show_key_selection_popoup( HWND hwndDlg, LPARAM lParam ) -{ - RECT rect; - HMENU hpopup; - struct button_info *info; - BOOL menu_id; - - info = ( struct button_info * ) GetWindowLongPtr( ( HWND ) lParam, - GWLP_USERDATA ); - /* create a popup right over the button that has been clicked */ - GetWindowRect( ( HWND ) lParam, &rect ); - hpopup = GetSubMenu( LoadMenu( fuse_hInstance, - MAKEINTRESOURCE( IDR_JOYSTICKS_POPUP ) ), 0 ); - /* popup returns the key value */ - menu_id = TrackPopupMenu( hpopup, TPM_LEFTALIGN | TPM_TOPALIGN | - TPM_NONOTIFY | TPM_RETURNCMD | - TPM_RIGHTBUTTON, rect.left, rect.top, 0, - fuse_hWnd, NULL ); - if( menu_id > 0 ) { - /* KEYBOARD_NONE is 0, and TrackPopupMenu returns 0 on error, - so menu id for KEYBOARD_NONE is 1 to distiguish the 2 results */ - if( menu_id != 1 ) - info->key = menu_id; - else - info->key = KEYBOARD_NONE; - set_key_text( info->label, info->key ); - set_key_text( info->static_label, info->key ); - } -} diff --git a/fuse/ui/win32/win32joystick.h b/fuse/ui/win32/win32joystick.h deleted file mode 100644 index 74d4546..0000000 --- a/fuse/ui/win32/win32joystick.h +++ /dev/null @@ -1,90 +0,0 @@ -/* win32joystick.h: Joystick emulation - Copyright (c) 2008 Marek Januszewski - Copyright (c) 2015 UB880D - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - - Darren: linux@youmustbejoking.demon.co.uk - -*/ - -#define IDD_JOYSTICKS 1700 -#define IDC_JOYSTICKS_GROUP_JOYTYPE 1701 - -#define IDC_JOYSTICKS_GROUP_BUTTON1 ( IDC_JOYSTICKS_GROUP_JOYTYPE + 1 ) -#define IDC_JOYSTICKS_GROUP_BUTTON2 ( IDC_JOYSTICKS_GROUP_BUTTON1 + 1 ) -#define IDC_JOYSTICKS_GROUP_BUTTON3 ( IDC_JOYSTICKS_GROUP_BUTTON2 + 1 ) -#define IDC_JOYSTICKS_GROUP_BUTTON4 ( IDC_JOYSTICKS_GROUP_BUTTON3 + 1 ) -#define IDC_JOYSTICKS_GROUP_BUTTON5 ( IDC_JOYSTICKS_GROUP_BUTTON4 + 1 ) -#define IDC_JOYSTICKS_GROUP_BUTTON6 ( IDC_JOYSTICKS_GROUP_BUTTON5 + 1 ) -#define IDC_JOYSTICKS_GROUP_BUTTON7 ( IDC_JOYSTICKS_GROUP_BUTTON6 + 1 ) -#define IDC_JOYSTICKS_GROUP_BUTTON8 ( IDC_JOYSTICKS_GROUP_BUTTON7 + 1 ) -#define IDC_JOYSTICKS_GROUP_BUTTON9 ( IDC_JOYSTICKS_GROUP_BUTTON8 + 1 ) -#define IDC_JOYSTICKS_GROUP_BUTTON10 ( IDC_JOYSTICKS_GROUP_BUTTON9 + 1 ) -#define IDC_JOYSTICKS_GROUP_BUTTON11 ( IDC_JOYSTICKS_GROUP_BUTTON10 + 1 ) -#define IDC_JOYSTICKS_GROUP_BUTTON12 ( IDC_JOYSTICKS_GROUP_BUTTON11 + 1 ) -#define IDC_JOYSTICKS_GROUP_BUTTON13 ( IDC_JOYSTICKS_GROUP_BUTTON12 + 1 ) -#define IDC_JOYSTICKS_GROUP_BUTTON14 ( IDC_JOYSTICKS_GROUP_BUTTON13 + 1 ) -#define IDC_JOYSTICKS_GROUP_BUTTON15 ( IDC_JOYSTICKS_GROUP_BUTTON14 + 1 ) - -#define IDC_JOYSTICKS_STATIC_BUTTON1 ( IDC_JOYSTICKS_GROUP_BUTTON15 + 1 ) -#define IDC_JOYSTICKS_STATIC_BUTTON2 ( IDC_JOYSTICKS_STATIC_BUTTON1 + 1 ) -#define IDC_JOYSTICKS_STATIC_BUTTON3 ( IDC_JOYSTICKS_STATIC_BUTTON2 + 1 ) -#define IDC_JOYSTICKS_STATIC_BUTTON4 ( IDC_JOYSTICKS_STATIC_BUTTON3 + 1 ) -#define IDC_JOYSTICKS_STATIC_BUTTON5 ( IDC_JOYSTICKS_STATIC_BUTTON4 + 1 ) -#define IDC_JOYSTICKS_STATIC_BUTTON6 ( IDC_JOYSTICKS_STATIC_BUTTON5 + 1 ) -#define IDC_JOYSTICKS_STATIC_BUTTON7 ( IDC_JOYSTICKS_STATIC_BUTTON6 + 1 ) -#define IDC_JOYSTICKS_STATIC_BUTTON8 ( IDC_JOYSTICKS_STATIC_BUTTON7 + 1 ) -#define IDC_JOYSTICKS_STATIC_BUTTON9 ( IDC_JOYSTICKS_STATIC_BUTTON8 + 1 ) -#define IDC_JOYSTICKS_STATIC_BUTTON10 ( IDC_JOYSTICKS_STATIC_BUTTON9 + 1 ) -#define IDC_JOYSTICKS_STATIC_BUTTON11 ( IDC_JOYSTICKS_STATIC_BUTTON10 + 1 ) -#define IDC_JOYSTICKS_STATIC_BUTTON12 ( IDC_JOYSTICKS_STATIC_BUTTON11 + 1 ) -#define IDC_JOYSTICKS_STATIC_BUTTON13 ( IDC_JOYSTICKS_STATIC_BUTTON12 + 1 ) -#define IDC_JOYSTICKS_STATIC_BUTTON14 ( IDC_JOYSTICKS_STATIC_BUTTON13 + 1 ) -#define IDC_JOYSTICKS_STATIC_BUTTON15 ( IDC_JOYSTICKS_STATIC_BUTTON14 + 1 ) - -#define IDC_JOYSTICKS_BUTTON_BUTTON1 ( IDC_JOYSTICKS_STATIC_BUTTON15 + 1 ) -#define IDC_JOYSTICKS_BUTTON_BUTTON2 ( IDC_JOYSTICKS_BUTTON_BUTTON1 + 1 ) -#define IDC_JOYSTICKS_BUTTON_BUTTON3 ( IDC_JOYSTICKS_BUTTON_BUTTON2 + 1 ) -#define IDC_JOYSTICKS_BUTTON_BUTTON4 ( IDC_JOYSTICKS_BUTTON_BUTTON3 + 1 ) -#define IDC_JOYSTICKS_BUTTON_BUTTON5 ( IDC_JOYSTICKS_BUTTON_BUTTON4 + 1 ) -#define IDC_JOYSTICKS_BUTTON_BUTTON6 ( IDC_JOYSTICKS_BUTTON_BUTTON5 + 1 ) -#define IDC_JOYSTICKS_BUTTON_BUTTON7 ( IDC_JOYSTICKS_BUTTON_BUTTON6 + 1 ) -#define IDC_JOYSTICKS_BUTTON_BUTTON8 ( IDC_JOYSTICKS_BUTTON_BUTTON7 + 1 ) -#define IDC_JOYSTICKS_BUTTON_BUTTON9 ( IDC_JOYSTICKS_BUTTON_BUTTON8 + 1 ) -#define IDC_JOYSTICKS_BUTTON_BUTTON10 ( IDC_JOYSTICKS_BUTTON_BUTTON9 + 1 ) -#define IDC_JOYSTICKS_BUTTON_BUTTON11 ( IDC_JOYSTICKS_BUTTON_BUTTON10 + 1 ) -#define IDC_JOYSTICKS_BUTTON_BUTTON12 ( IDC_JOYSTICKS_BUTTON_BUTTON11 + 1 ) -#define IDC_JOYSTICKS_BUTTON_BUTTON13 ( IDC_JOYSTICKS_BUTTON_BUTTON12 + 1 ) -#define IDC_JOYSTICKS_BUTTON_BUTTON14 ( IDC_JOYSTICKS_BUTTON_BUTTON13 + 1 ) -#define IDC_JOYSTICKS_BUTTON_BUTTON15 ( IDC_JOYSTICKS_BUTTON_BUTTON14 + 1 ) - -#define IDR_JOYSTICKS_POPUP ( IDC_JOYSTICKS_BUTTON_BUTTON15 + 1 ) - -/* - win32joystick_buttonevent parameters: - which_joystick = 0 => JOYSTICK1 - which_joystick = 1 => JOYSTICK2 - button_down = 1 => button pressed - button_down = 0 => button released -*/ -void win32joystick_buttonevent( int which_joystick, int button_down, - unsigned int wParam ); -void win32joystick_move( int which_joystick, - unsigned short pos_x, unsigned short pos_y ); diff --git a/fuse/ui/win32/win32joystick.rc b/fuse/ui/win32/win32joystick.rc deleted file mode 100644 index d175113..0000000 --- a/fuse/ui/win32/win32joystick.rc +++ /dev/null @@ -1,224 +0,0 @@ -/* win32joystick.rc: Joystick emulation - Copyright (c) 2008 Marek Januszewski - Copyright (c) 2015 UB880D - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - - Darren: linux@youmustbejoking.demon.co.uk - -*/ - -#include "win32joystick.h" - -IDD_JOYSTICKS DIALOGEX 0,0,420,149 -STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_FIXEDSYS | WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "Fuse - Configure Joystick" -FONT 8,"Ms Shell Dlg 2",400,0,1 -BEGIN - GROUPBOX "Joystick type",IDC_JOYSTICKS_GROUP_JOYTYPE,0,0,60,125 - -/* those radio buttons will be created at runtime, - with the sizes and distances like below - - RADIOBUTTON "None",IDC_JOYSTICKS_RADIO_NONE,5,10,45,10 - RADIOBUTTON "Cursor",IDC_JOYSTICKS_RADIO_CURSOR,5,20,45,10 - RADIOBUTTON "Kempston",IDC_JOYSTICKS_RADIO_KEMPSTON,5,30,45,10 - RADIOBUTTON "Sinclair 1",IDC_JOYSTICKS_RADIO_SINCLAIR1,5,40,45,10 - RADIOBUTTON "Sinclair 2",IDC_JOYSTICKS_RADIO_SINCLAIR2,5,50,45,10 - RADIOBUTTON "Timex 1",IDC_JOYSTICKS_RADIO_TIMEX1,5,60,45,10 - RADIOBUTTON "Timex 2",IDC_JOYSTICKS_RADIO_TIMEX2,5,70,45,10 - RADIOBUTTON "Fuller",IDC_JOYSTICKS_RADIO_FULLER,5,80,45,10 -*/ - GROUPBOX "Button 1",IDC_JOYSTICKS_GROUP_BUTTON1,65,0,115,25 - LTEXT "Joystick Fire",IDC_JOYSTICKS_STATIC_BUTTON1,70,10,40,12,SS_CENTERIMAGE - PUSHBUTTON "",IDC_JOYSTICKS_BUTTON_BUTTON1,115,10,60,12 - - GROUPBOX "Button 2",IDC_JOYSTICKS_GROUP_BUTTON2,65,25,115,25 - LTEXT "Joystick Fire",IDC_JOYSTICKS_STATIC_BUTTON2,70,35,40,12,SS_CENTERIMAGE - PUSHBUTTON "",IDC_JOYSTICKS_BUTTON_BUTTON2,115,35,60,12 - - GROUPBOX "Button 3",IDC_JOYSTICKS_GROUP_BUTTON3,65,50,115,25 - LTEXT "Joystick Fire",IDC_JOYSTICKS_STATIC_BUTTON3,70,60,40,12,SS_CENTERIMAGE - PUSHBUTTON "",IDC_JOYSTICKS_BUTTON_BUTTON3,115,60,60,12 - - GROUPBOX "Button 4",IDC_JOYSTICKS_GROUP_BUTTON4,65,75,115,25 - LTEXT "Joystick Fire",IDC_JOYSTICKS_STATIC_BUTTON4,70,85,40,12,SS_CENTERIMAGE - PUSHBUTTON "",IDC_JOYSTICKS_BUTTON_BUTTON4,115,85,60,12 - - GROUPBOX "Button 5",IDC_JOYSTICKS_GROUP_BUTTON5,65,100,115,25 - LTEXT "Joystick Fire",IDC_JOYSTICKS_STATIC_BUTTON5,70,110,40,12,SS_CENTERIMAGE - PUSHBUTTON "",IDC_JOYSTICKS_BUTTON_BUTTON5,115,110,60,12 - - GROUPBOX "Button 6",IDC_JOYSTICKS_GROUP_BUTTON6,185,0,115,25 - LTEXT "Joystick Fire",IDC_JOYSTICKS_STATIC_BUTTON6,190,10,40,12,SS_CENTERIMAGE - PUSHBUTTON "",IDC_JOYSTICKS_BUTTON_BUTTON6,235,10,60,12 - - GROUPBOX "Button 7",IDC_JOYSTICKS_GROUP_BUTTON7,185,25,115,25 - LTEXT "Joystick Fire",IDC_JOYSTICKS_STATIC_BUTTON7,190,35,40,12,SS_CENTERIMAGE - PUSHBUTTON "",IDC_JOYSTICKS_BUTTON_BUTTON7,235,35,60,12 - - GROUPBOX "Button 8",IDC_JOYSTICKS_GROUP_BUTTON8,185,50,115,25 - LTEXT "Joystick Fire",IDC_JOYSTICKS_STATIC_BUTTON8,190,60,40,12,SS_CENTERIMAGE - PUSHBUTTON "",IDC_JOYSTICKS_BUTTON_BUTTON8,235,60,60,12 - - GROUPBOX "Button 9",IDC_JOYSTICKS_GROUP_BUTTON9,185,75,115,25 - LTEXT "Joystick Fire",IDC_JOYSTICKS_STATIC_BUTTON9,190,85,40,12,SS_CENTERIMAGE - PUSHBUTTON "",IDC_JOYSTICKS_BUTTON_BUTTON9,235,85,60,12 - - GROUPBOX "Button 10",IDC_JOYSTICKS_GROUP_BUTTON10,185,100,115,25 - LTEXT "Joystick Fire",IDC_JOYSTICKS_STATIC_BUTTON10,190,110,40,12,SS_CENTERIMAGE - PUSHBUTTON "",IDC_JOYSTICKS_BUTTON_BUTTON10,235,110,60,12 - - GROUPBOX "Button 11",IDC_JOYSTICKS_GROUP_BUTTON11,305,0,115,25 - LTEXT "Joystick Fire",IDC_JOYSTICKS_STATIC_BUTTON11,310,10,40,12,SS_CENTERIMAGE - PUSHBUTTON "",IDC_JOYSTICKS_BUTTON_BUTTON11,355,10,60,12 - - GROUPBOX "Button 12",IDC_JOYSTICKS_GROUP_BUTTON12,305,25,115,25 - LTEXT "Joystick Fire",IDC_JOYSTICKS_STATIC_BUTTON12,310,35,40,12,SS_CENTERIMAGE - PUSHBUTTON "",IDC_JOYSTICKS_BUTTON_BUTTON12,355,35,60,12 - - GROUPBOX "Button 13",IDC_JOYSTICKS_GROUP_BUTTON13,305,50,115,25 - LTEXT "Joystick Fire",IDC_JOYSTICKS_STATIC_BUTTON13,310,60,40,12,SS_CENTERIMAGE - PUSHBUTTON "",IDC_JOYSTICKS_BUTTON_BUTTON13,355,60,60,12 - - GROUPBOX "Button 14",IDC_JOYSTICKS_GROUP_BUTTON14,305,75,115,25 - LTEXT "Joystick Fire",IDC_JOYSTICKS_STATIC_BUTTON14,310,85,40,12,SS_CENTERIMAGE - PUSHBUTTON "",IDC_JOYSTICKS_BUTTON_BUTTON14,355,85,60,12 - - GROUPBOX "Button 15",IDC_JOYSTICKS_GROUP_BUTTON15,305,100,115,25 - LTEXT "Joystick Fire",IDC_JOYSTICKS_STATIC_BUTTON15,310,110,40,12,SS_CENTERIMAGE - PUSHBUTTON "",IDC_JOYSTICKS_BUTTON_BUTTON15,355,110,60,12 - - DEFPUSHBUTTON "OK",IDOK,155,130,50,14 - PUSHBUTTON "Cancel",IDCANCEL,215,130,50,14 -END - -/* FIXME: resource should use KEYBOARD codes from keyboard.h */ - -#define KEYBOARD_NONE 0x00 - -#define KEYBOARD_space 0x20 - -#define KEYBOARD_0 0x30 -#define KEYBOARD_1 0x31 -#define KEYBOARD_2 0x32 -#define KEYBOARD_3 0x33 -#define KEYBOARD_4 0x34 -#define KEYBOARD_5 0x35 -#define KEYBOARD_6 0x36 -#define KEYBOARD_7 0x37 -#define KEYBOARD_8 0x38 -#define KEYBOARD_9 0x39 - -#define KEYBOARD_a 0x61 -#define KEYBOARD_b 0x62 -#define KEYBOARD_c 0x63 -#define KEYBOARD_d 0x64 -#define KEYBOARD_e 0x65 -#define KEYBOARD_f 0x66 -#define KEYBOARD_g 0x67 -#define KEYBOARD_h 0x68 -#define KEYBOARD_i 0x69 -#define KEYBOARD_j 0x6A -#define KEYBOARD_k 0x6B -#define KEYBOARD_l 0x6C -#define KEYBOARD_m 0x6D -#define KEYBOARD_n 0x6E -#define KEYBOARD_o 0x6F -#define KEYBOARD_p 0x70 -#define KEYBOARD_q 0x71 -#define KEYBOARD_r 0x72 -#define KEYBOARD_s 0x73 -#define KEYBOARD_t 0x74 -#define KEYBOARD_u 0x75 -#define KEYBOARD_v 0x76 -#define KEYBOARD_w 0x77 -#define KEYBOARD_x 0x78 -#define KEYBOARD_y 0x79 -#define KEYBOARD_z 0x7A - -#define KEYBOARD_Enter 0x100 -#define KEYBOARD_Caps 0x101 -#define KEYBOARD_Symbol 0x102 - -#define KEYBOARD_JOYSTICK_FIRE 0x1000 - -IDR_JOYSTICKS_POPUP MENU -BEGIN - POPUP "" - BEGIN - MENUITEM "Joystick Fire", KEYBOARD_JOYSTICK_FIRE - - POPUP "Numbers" - BEGIN - MENUITEM "0", KEYBOARD_0 - MENUITEM "1", KEYBOARD_1 - MENUITEM "2", KEYBOARD_2 - MENUITEM "3", KEYBOARD_3 - MENUITEM "4", KEYBOARD_4 - MENUITEM "5", KEYBOARD_5 - MENUITEM "6", KEYBOARD_6 - MENUITEM "7", KEYBOARD_7 - MENUITEM "8", KEYBOARD_8 - MENUITEM "9", KEYBOARD_9 - END - - POPUP "A-M" - BEGIN - MENUITEM "A", KEYBOARD_a - MENUITEM "B", KEYBOARD_b - MENUITEM "C", KEYBOARD_c - MENUITEM "D", KEYBOARD_d - MENUITEM "E", KEYBOARD_e - MENUITEM "F", KEYBOARD_f - MENUITEM "G", KEYBOARD_g - MENUITEM "H", KEYBOARD_h - MENUITEM "I", KEYBOARD_i - MENUITEM "J", KEYBOARD_j - MENUITEM "K", KEYBOARD_k - MENUITEM "L", KEYBOARD_l - MENUITEM "M", KEYBOARD_m - END - - POPUP "N-Z" - BEGIN - MENUITEM "N", KEYBOARD_n - MENUITEM "O", KEYBOARD_o - MENUITEM "P", KEYBOARD_p - MENUITEM "Q", KEYBOARD_q - MENUITEM "R", KEYBOARD_r - MENUITEM "S", KEYBOARD_s - MENUITEM "T", KEYBOARD_t - MENUITEM "U", KEYBOARD_u - MENUITEM "V", KEYBOARD_v - MENUITEM "W", KEYBOARD_w - MENUITEM "X", KEYBOARD_x - MENUITEM "Y", KEYBOARD_y - MENUITEM "Z", KEYBOARD_z - END - - MENUITEM "Space", KEYBOARD_space - MENUITEM "Enter", KEYBOARD_Enter - MENUITEM "Caps Shift", KEYBOARD_Caps - MENUITEM "Symbol Shift", KEYBOARD_Symbol - - MENUITEM "Nothing", 1 - END -END diff --git a/fuse/ui/win32/win32keyboard.c b/fuse/ui/win32/win32keyboard.c deleted file mode 100644 index caea4ce..0000000 --- a/fuse/ui/win32/win32keyboard.c +++ /dev/null @@ -1,155 +0,0 @@ -/* win32keyboard.c: routines for dealing with the Win32 keyboard - Copyright (c) 2003 Marek Januszewski, Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include - -#ifdef HAVE_LIB_GLIB -#include -#endif /* #ifdef HAVE_LIB_GLIB */ - -#include - -#include "display.h" -#include "fuse.h" -#include "keyboard.h" -#include "machine.h" -#include "settings.h" -#include "snapshot.h" -#include "spectrum.h" -#include "tape.h" -#include "utils.h" -#include "win32internals.h" - -/* Map OEM unshifted keys to Fuse input layer keysym */ -extern const keysyms_map_t oem_keysyms_map[]; - -static GHashTable *oem_keysyms_hash; - -static input_key -oem_keysyms_remap( WPARAM wParam ) -{ - const input_key *ptr; - unsigned int mapped_code; - libspectrum_dword unshifted_char; - - mapped_code = MapVirtualKey( wParam, MAPVK_VK_TO_CHAR ); - if( !mapped_code ) return INPUT_KEY_NONE; - - unshifted_char = LOWORD( mapped_code ); - ptr = g_hash_table_lookup( oem_keysyms_hash, &unshifted_char ); - - return ptr ? *ptr : INPUT_KEY_NONE; -} - -void -win32keyboard_init( void ) -{ - keysyms_map_t *ptr3; - - oem_keysyms_hash = g_hash_table_new( g_int_hash, g_int_equal ); - - for( ptr3 = (keysyms_map_t *)oem_keysyms_map; ptr3->ui; ptr3++ ) - g_hash_table_insert( oem_keysyms_hash, &( ptr3->ui ), &( ptr3->fuse ) ); -} - -void -win32keyboard_end( void ) -{ - g_hash_table_destroy( oem_keysyms_hash ); -} - -void -win32keyboard_keypress( WPARAM wParam, LPARAM lParam ) -{ - input_key fuse_keysym; - input_event_t fuse_event; - - switch( wParam ) { - case VK_OEM_1: - case VK_OEM_2: - case VK_OEM_3: - case VK_OEM_4: - case VK_OEM_5: - case VK_OEM_6: - case VK_OEM_7: - case VK_OEM_8: - case VK_OEM_102: - case VK_OEM_COMMA: - case VK_OEM_MINUS: - case VK_OEM_PERIOD: - case VK_OEM_PLUS: - fuse_keysym = oem_keysyms_remap( wParam ); - break; - default: - fuse_keysym = keysyms_remap( wParam ); - break; - } - - if( fuse_keysym == INPUT_KEY_NONE ) return; - - fuse_event.type = INPUT_EVENT_KEYPRESS; - fuse_event.types.key.native_key = fuse_keysym; - fuse_event.types.key.spectrum_key = fuse_keysym; - - input_event( &fuse_event ); -} - -void -win32keyboard_keyrelease( WPARAM wParam, LPARAM lParam ) -{ - input_key fuse_keysym; - input_event_t fuse_event; - - switch( wParam ) { - case VK_OEM_1: - case VK_OEM_2: - case VK_OEM_3: - case VK_OEM_4: - case VK_OEM_5: - case VK_OEM_6: - case VK_OEM_7: - case VK_OEM_8: - case VK_OEM_102: - case VK_OEM_COMMA: - case VK_OEM_MINUS: - case VK_OEM_PERIOD: - case VK_OEM_PLUS: - fuse_keysym = oem_keysyms_remap( wParam ); - break; - default: - fuse_keysym = keysyms_remap( wParam ); - break; - } - - if( fuse_keysym == INPUT_KEY_NONE ) return; - - fuse_event.type = INPUT_EVENT_KEYRELEASE; - fuse_event.types.key.native_key = fuse_keysym; - fuse_event.types.key.spectrum_key = fuse_keysym; - - input_event( &fuse_event ); -} diff --git a/fuse/ui/win32/win32mouse.c b/fuse/ui/win32/win32mouse.c deleted file mode 100644 index 1a4616e..0000000 --- a/fuse/ui/win32/win32mouse.c +++ /dev/null @@ -1,95 +0,0 @@ -/* win32mouse.c: Win32 routines for emulating Spectrum mice - Copyright (c) 2008 Marek Januszewski - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include /* for GET_X_LPARAM and GET_Y_LPARAM */ - -#include "ui/ui.h" -#include "win32internals.h" - -static void -win32mouse_reset_pointer( void ) -{ - RECT rect; - POINT point; - - GetClientRect( fuse_hWnd, &rect ); - - point.x = rect.left + 128; - point.y = rect.top + 128; - - ClientToScreen( fuse_hWnd, &point ); - SetCursorPos( point.x, point.y ); -} - -void -win32mouse_position( LPARAM lParam ) -{ - int x,y; - - if( !ui_mouse_grabbed ) return; - - x = GET_X_LPARAM( lParam ); - y = GET_Y_LPARAM( lParam ); - - if( x != 128 || y != 128 ) - win32mouse_reset_pointer(); - ui_mouse_motion( x - 128, y - 128 ); - return; -} - -void -win32mouse_button( int button, int down ) -/* button is: 1 - left, 2 - middle, 3 - right, down is: 1 - down, 0 - up */ -{ - ui_mouse_button( button, down ); - return; -} - -int -ui_mouse_grab( int startup ) -{ - if( startup ) return 0; - - SetCursor( NULL ); - SetCapture( fuse_hWnd ); - ui_statusbar_update( UI_STATUSBAR_ITEM_MOUSE, UI_STATUSBAR_STATE_ACTIVE ); - return 1; - -/* doesn't seem like SetCapture can return an error */ -/* - ui_error( UI_ERROR_WARNING, "Mouse grab failed" ); - return 0; -*/ -} - -int -ui_mouse_release( int suspend ) -{ - ReleaseCapture(); - SetCursor( LoadCursor( NULL, IDC_ARROW ) ); - ui_statusbar_update( UI_STATUSBAR_ITEM_MOUSE, UI_STATUSBAR_STATE_INACTIVE ); - return 0; -} diff --git a/fuse/ui/win32/win32ui.c b/fuse/ui/win32/win32ui.c deleted file mode 100755 index fd95017..0000000 --- a/fuse/ui/win32/win32ui.c +++ /dev/null @@ -1,1232 +0,0 @@ -/* win32ui.c: Win32 routines for dealing with the user interface - Copyright (c) 2003-2015 Marek Januszewski, Philip Kendall, Stuart Brady - Copyright (c) 2015 Kirben - Copyright (c) 2016 lordhoto - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include -#include - -#include "debugger/debugger.h" -#include "display.h" -#include "fuse.h" -#include "keyboard.h" -#include "menu.h" -#include "peripherals/joystick.h" -#include "psg.h" -#include "rzx.h" -#include "screenshot.h" -#include "select_template.h" -#include "settings.h" -#include "snapshot.h" -#include "tape.h" -#include "timer/timer.h" -#include "ui/ui.h" -#include "ui/win32/menu_data.h" -#include "utils.h" -#include "win32internals.h" -#include "win32joystick.h" - -/* Window handler */ -HWND fuse_hWnd; - -/* Application instance */ -HINSTANCE fuse_hInstance; - -/* fuse_hPrevInstance is needed only to register window class */ -static HINSTANCE fuse_hPrevInstance; - -/* specifies how the main window should be shown: minimized, maximized, etc */ -static int fuse_nCmdShow; - -/* handle to accelartors/keyboard shortcuts */ -static HACCEL hAccels; - -/* machine select dialog's font object */ -static HFONT h_ms_font = NULL; - -/* monospaced font to use with debugger and memory browser */ -static HFONT monospaced_font = NULL; - -/* True if we were paused via the Machine/Pause menu item */ -static int paused = 0; - -/* this helps pause fuse while the main window is minimized */ -static int size_paused = 0; - -/* this helps to finalize some blocking operations */ -static int exit_process_messages = 0; - -/* Structure used by the radio button selection widgets (eg the - graphics filter selectors and Machine/Select) */ -typedef struct win32ui_select_info { - - int length; - int selected; - const char **labels; - LPCTSTR dialog_title; - -} win32ui_select_info; - -static BOOL win32ui_make_menu( void ); - -static int win32ui_lose_focus( HWND hWnd, WPARAM wParam, LPARAM lParam ); -static int win32ui_gain_focus( HWND hWnd, WPARAM wParam, LPARAM lParam ); - -static int win32ui_window_paint( HWND hWnd, WPARAM wParam, LPARAM lParam ); -static int win32ui_window_resize( HWND hWnd, WPARAM wParam, LPARAM lParam ); -static BOOL win32ui_window_resizing( HWND hWnd, WPARAM wParam, LPARAM lParam ); - -static int -selector_dialog( win32ui_select_info *items ); - -static void -handle_drop( HDROP hDrop ) -{ - size_t bufsize; - char *namebuf; - - /* Check that only one file was dropped */ - if( DragQueryFile( hDrop, ~0UL, NULL, 0 ) == 1) { - bufsize = DragQueryFile( hDrop, 0, NULL, 0 ) + 1; - if( ( namebuf = malloc( bufsize ) ) ) { - DragQueryFile( hDrop, 0, namebuf, bufsize ); - - fuse_emulation_pause(); - - utils_open_file( namebuf, tape_can_autoload(), NULL ); - - free( namebuf ); - - display_refresh_all(); - - fuse_emulation_unpause(); - } - } - DragFinish( hDrop ); -} - -static LRESULT WINAPI -fuse_window_proc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) -{ - switch( msg ) { - - case WM_COMMAND: - if( ! handle_menu( LOWORD( wParam ), hWnd ) ) - return 0; - break; - - case WM_DROPFILES: - handle_drop( ( HDROP )wParam ); - return 0; - - case WM_CLOSE: - menu_file_exit( 0 ); - return 0; - - case WM_KEYDOWN: - win32keyboard_keypress( wParam, lParam ); - return 0; - - case WM_KEYUP: - win32keyboard_keyrelease( wParam, lParam ); - return 0; - - case WM_PAINT: - if( ! win32ui_window_paint( hWnd, wParam, lParam ) ) - return 0; - break; - - case WM_SIZING: - if( win32ui_window_resizing( hWnd, wParam, lParam ) ) - return TRUE; - break; - - case WM_SIZE: - if( ! win32ui_window_resize( hWnd, wParam, lParam ) ) - return 0; - break; - - case WM_DRAWITEM: - if( wParam == ID_STATUSBAR ) { - win32statusbar_redraw( hWnd, lParam ); - return TRUE; - } - break; - - case WM_DESTROY: - fuse_exiting = 1; - PostQuitMessage( 0 ); - - /* Stop the paused state to allow us to exit (occurs from main - emulation loop) */ - if( paused ) menu_machine_pause( 0 ); - return 0; - - case WM_ENTERMENULOOP: - case WM_ENTERSIZEMOVE: - { - fuse_emulation_pause(); - return 0; - } - - case WM_EXITMENULOOP: - case WM_EXITSIZEMOVE: - { - fuse_emulation_unpause(); - return 0; - } - - case WM_LBUTTONUP: - win32mouse_button( 1, 0 ); - return 0; - - case WM_LBUTTONDOWN: - win32mouse_button( 1, 1 ); - return 0; - - case WM_MBUTTONUP: - win32mouse_button( 2, 0 ); - return 0; - - case WM_MBUTTONDOWN: - win32mouse_button( 2, 1 ); - return 0; - - case WM_RBUTTONUP: - win32mouse_button( 3, 0 ); - return 0; - - case WM_RBUTTONDOWN: - win32mouse_button( 3, 1 ); - return 0; - - case WM_MOUSEMOVE: - win32mouse_position( lParam ); - return 0; - - case WM_SETCURSOR: - /* prevent the cursor from being redrawn if fuse has grabbed the mouse */ - if( ui_mouse_grabbed ) - return TRUE; - else - return( DefWindowProc( hWnd, msg, wParam, lParam ) ); - - case WM_ACTIVATE: - if( ( LOWORD( wParam ) == WA_ACTIVE ) || - ( LOWORD( wParam ) == WA_CLICKACTIVE ) ) - win32ui_gain_focus( hWnd, wParam, lParam ); - else if( LOWORD( wParam ) == WA_INACTIVE ) - win32ui_lose_focus( hWnd, wParam, lParam ); - /* We'll call DefWindowProc to get keyboard focus when debugger window - is open and inactive */ - break; - - case WM_USER_EXIT_PROCESS_MESSAGES: - /* Odd case when message loop is overridden by a modal dialog. This - should not be caught here, so we delay this notification */ - exit_process_messages++; - return 0; - - case WM_ERASEBKGND: - /* Improves speed and avoid flickering when main window is invalidated by - another window */ - return TRUE; - -#if defined USE_JOYSTICK && !defined HAVE_JSW_H - - case MM_JOY1BUTTONDOWN: - win32joystick_buttonevent( 0, 1, wParam ); - break; - - case MM_JOY1BUTTONUP: - win32joystick_buttonevent( 0, 0, wParam ); - break; - - case MM_JOY2BUTTONDOWN: - win32joystick_buttonevent( 1, 1, wParam ); - break; - - case MM_JOY2BUTTONUP: - win32joystick_buttonevent( 1, 0, wParam ); - break; - - case MM_JOY1MOVE: - win32joystick_move( 0, LOWORD( lParam ), HIWORD( lParam ) ); - break; - - case MM_JOY2MOVE: - win32joystick_move( 1, LOWORD( lParam ), HIWORD( lParam ) ); - break; - -#endif /* if defined USE_JOYSTICK && !defined HAVE_JSW_H */ - - } - return( DefWindowProc( hWnd, msg, wParam, lParam ) ); -} - -/* this is where windows program begins */ -int WINAPI -WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, - int nCmdShow ) -{ - /* remember those values for window creation in ui_init */ - fuse_hInstance = hInstance; - fuse_nCmdShow = nCmdShow; - fuse_hPrevInstance = hPrevInstance; - -/* HACK: __argc, __argv are broken and return zero when using mingwrt 4.0+ - on MinGW. - HACK: MinGW-w64 based toolchains neither feature _argc nor _argv. The 32 bit - incarnation only defines __MINGW32__. This leads to build breakage due to - missing declarations. Luckily MinGW-w64 based toolchains define - __MINGW64_VERSION_foo macros inside _mingw.h, which is included from all - system headers. Thus we abuse that to detect them. -*/ -#if defined( __GNUC__ ) && defined( __MINGW32__ ) \ - && !defined( __MINGW64_VERSION_MAJOR ) - return fuse_main( _argc, _argv ); -#else - return fuse_main( __argc, __argv ); -#endif - - /* FIXME: how do deal with returning wParam */ -} - -int -ui_init( int *argc, char ***argv ) -{ - /* register window class */ - WNDCLASS wc; - - if( !fuse_hPrevInstance ) { - wc.lpszClassName = "Fuse"; - wc.lpfnWndProc = fuse_window_proc; - wc.style = CS_OWNDC; - wc.hInstance = fuse_hInstance; - wc.hIcon = LoadIcon( fuse_hInstance, "win32_icon" ); - wc.hCursor = LoadCursor( NULL, IDC_ARROW ); - wc.hbrBackground = (HBRUSH)( COLOR_WINDOW+1 ); - wc.lpszMenuName = "win32_menu"; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - - if( !RegisterClass( &wc ) ) - return 0; - } - - /* create the window */ - fuse_hWnd = CreateWindow( "Fuse", "Fuse", WS_OVERLAPPED | WS_CAPTION | - WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_CLIPCHILDREN, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - NULL, NULL, fuse_hInstance, NULL ); - - /* init windows controls such as the status bar */ - InitCommonControls(); - - /* menu is created in rc file, but we still need to set initial state */ - win32ui_make_menu(); - - /* load keyboard shortcuts */ - hAccels = LoadAccelerators( fuse_hInstance, "win32_accel" ); - - /* status bar */ - win32statusbar_create( fuse_hWnd ); - - /* set the initial size of the drawing area */ - RECT wr, cr, statr; - int w_ofs, h_ofs; - - GetWindowRect( fuse_hWnd, &wr ); - GetClientRect( fuse_hWnd, &cr ); - GetClientRect( fuse_hStatusWindow, &statr ); - - w_ofs = ( wr.right - wr.left ) - ( cr.right - cr.left ); - h_ofs = ( wr.bottom - wr.top ) - ( cr.bottom - cr.top ); - if( settings_current.statusbar ) h_ofs += ( statr.bottom - statr.top ); - - MoveWindow( fuse_hWnd, wr.left, wr.top, - DISPLAY_ASPECT_WIDTH + w_ofs, - DISPLAY_SCREEN_HEIGHT + h_ofs, - FALSE ); - - /* init the display area */ - if( win32display_init() ) return 1; - - win32keyboard_init(); - - /* show the window finally */ - ShowWindow( fuse_hWnd, fuse_nCmdShow ); - UpdateWindow( fuse_hWnd ); - - /* window will accept dragging and dropping */ - DragAcceptFiles( fuse_hWnd, TRUE ); - - ui_mouse_present = 1; - - return 0; -} - -static BOOL -win32ui_make_menu( void ) -{ - /* Start various menus in the 'off' state */ - ui_menu_activate( UI_MENU_ITEM_AY_LOGGING, 0 ); - ui_menu_activate( UI_MENU_ITEM_FILE_MOVIE_RECORDING, 0 ); - ui_menu_activate( UI_MENU_ITEM_MACHINE_PROFILER, 0 ); - ui_menu_activate( UI_MENU_ITEM_RECORDING, 0 ); - ui_menu_activate( UI_MENU_ITEM_RECORDING_ROLLBACK, 0 ); - ui_menu_activate( UI_MENU_ITEM_TAPE_RECORDING, 0 ); -#ifdef HAVE_LIB_XML2 - ui_menu_activate( UI_MENU_ITEM_FILE_SVG_CAPTURE, 0 ); -#endif - return FALSE; -} - -int -ui_event( void ) -{ - win32ui_process_messages( 1 ); - - return 0; -} - -int -ui_end( void ) -{ - int error; - - win32keyboard_end(); - - error = win32display_end(); if( error ) return error; - - /* close the monospaced font handle */ - if( monospaced_font ) { - DeleteObject( monospaced_font ); - monospaced_font = NULL; - } - - return 0; -} - -/* Create a dialog box with the given error message */ -int -ui_error_specific( ui_error_level severity, const char *message ) -{ - /* If we don't have a UI yet, we can't output widgets */ - if( !display_ui_initialised ) return 0; - - switch( severity ) { - - case UI_ERROR_INFO: - MessageBox( fuse_hWnd, message, "Fuse - Info", MB_ICONINFORMATION | MB_OK ); - break; - case UI_ERROR_WARNING: - MessageBox( fuse_hWnd, message, "Fuse - Warning", MB_ICONWARNING | MB_OK ); - break; - case UI_ERROR_ERROR: - MessageBox( fuse_hWnd, message, "Fuse - Error", MB_ICONERROR | MB_OK ); - break; - default: - MessageBox( fuse_hWnd, message, "Fuse - (Unknown Error Level)", - MB_ICONINFORMATION | MB_OK ); - break; - - } - - return 0; -} - -/* The callbacks used by various routines */ - -static int -win32ui_lose_focus( HWND hWnd, WPARAM wParam, LPARAM lParam ) -{ - keyboard_release_all(); - ui_mouse_suspend(); - return 0; -} - -static int -win32ui_gain_focus( HWND hWnd, WPARAM wParam, LPARAM lParam ) -{ - ui_mouse_resume(); - return 0; -} - -/* Called by the menu when File/Exit selected */ -void -menu_file_exit( int action ) -{ - /* FIXME: this should really be sending WM_CLOSE, not duplicate code */ - if( win32ui_confirm( "Exit Fuse?" ) ) { - - if( menu_check_media_changed() ) return; - - DestroyWindow(fuse_hWnd); - } -} - -/* Select a graphics filter from those for which `available' returns - true */ -scaler_type -menu_get_scaler( scaler_available_fn selector ) -{ - scaler_type selected_scaler = SCALER_NUM; - win32ui_select_info items; - int count, i, selection; - scaler_type scaler; - - /* Get count of currently applicable scalars first */ - count = 0; - for( scaler = 0; scaler < SCALER_NUM; scaler++ ) { - if( selector( scaler ) ) count++; - } - - /* Populate win32ui_select_info */ - items.dialog_title = TEXT( "Fuse - Select Scaler" ); - items.labels = malloc( count * sizeof( char * ) ); - items.length = count; - - /* Populate the labels with currently applicable scalars */ - count = 0; - - for( scaler = 0; scaler < SCALER_NUM; scaler++ ) { - - if( !selector( scaler ) ) continue; - - items.labels[ count ] = scaler_name( scaler ); - - if( current_scaler == scaler ) { - items.selected = count; - } - - count++; - } - - /* Start the selection dialog box */ - selection = selector_dialog( &items ); - - if( selection >= 0 ) { - /* Apply the selected scalar */ - count = 0; - - for( i = 0; i < SCALER_NUM; i++ ) { - if( !selector( i ) ) continue; - - if( selection == count ) { - selected_scaler = i; - } - - count++; - } - } - - free( items.labels ); - - return selected_scaler; -} - -/* Machine/Pause */ -void -menu_machine_pause( int action ) -{ - if( paused ) { - paused = 0; - ui_statusbar_update( UI_STATUSBAR_ITEM_PAUSED, - UI_STATUSBAR_STATE_INACTIVE ); - timer_estimate_reset(); - PostMessage( fuse_hWnd, WM_USER_EXIT_PROCESS_MESSAGES, 0, 0 ); - - /* Resume emulation */ - fuse_emulation_unpause(); - } else { - - /* Stop emulation */ - fuse_emulation_pause(); - - paused = 1; - ui_statusbar_update( UI_STATUSBAR_ITEM_PAUSED, UI_STATUSBAR_STATE_ACTIVE ); - win32ui_process_messages( 0 ); - } -} - -/* Called by the menu when Machine/Reset selected */ -void -menu_machine_reset( int action ) -{ - int hard_reset = action; - const char *message = "Reset?"; - - if( hard_reset ) - message = "Hard reset?"; - - if( !win32ui_confirm( message ) ) - return; - - /* Stop any ongoing RZX */ - rzx_stop_recording(); - rzx_stop_playback( 1 ); - - if( machine_reset( hard_reset ) ) { - ui_error( UI_ERROR_ERROR, "couldn't reset machine: giving up!" ); - - /* FIXME: abort() seems a bit extreme here, but it'll do for now */ - fuse_abort(); - } -} - -/* Called by the menu when Machine/Select selected */ -void -menu_machine_select( int action ) -{ - /* FIXME: choosing spectrum SE crashes Fuse sound_frame () at sound.c:477 "ay_change[f].ofs = ( ay_change[f].tstates * sfreq ) / cpufreq;" */ - /* FIXME: choosing some Timexes crashes (win32) fuse as well */ - - int selected_machine; - win32ui_select_info items; - int i; - - /* Stop emulation */ - fuse_emulation_pause(); - - /* Populate win32ui_select_info */ - items.dialog_title = TEXT( "Fuse - Select Machine" ); - items.labels = malloc( machine_count * sizeof( char * ) ); - items.length = machine_count; - - for( i=0; imachine ); - - if( machine_current == machine_types[i] ) { - items.selected = i; - } - } - - /* start the machine select dialog box */ - selected_machine = selector_dialog( &items ); - - if( selected_machine >= 0 && - machine_types[ selected_machine ] != machine_current ) { - machine_select( machine_types[ selected_machine ]->machine ); - } - - free( items.labels ); - - /* Resume emulation */ - fuse_emulation_unpause(); -} - -void -menu_machine_debugger( int action ) -{ - debugger_mode = DEBUGGER_MODE_HALTED; - if( paused ) ui_debugger_activate(); -} - -/* Called on machine selection */ -int -ui_widgets_reset( void ) -{ - win32ui_pokefinder_clear(); - return 0; -} - -void -menu_help_keyboard( int action ) -{ -#ifdef USE_LIBPNG - if( win32ui_picture( "keyboard.png", PICTURE_PNG ) == 0 ) - return; -#endif - - win32ui_picture( "keyboard.scr", PICTURE_SCR ); -} - -/* Functions to activate and deactivate certain menu items */ -static int -set_active( HMENU menu, const char *path, int active ) -{ - int i, menu_count; - char menu_text[255]; - MENUITEMINFO mii; - - if( *path == '/' ) path++; - - menu_count = GetMenuItemCount( menu ); - for( i = 0; i < menu_count; i++ ) { - - if( GetMenuString( menu, i, menu_text, 255, MF_BYPOSITION ) == 0 ) continue; - - const char *p = menu_text, *q = path; - - /* Compare the two strings, but skip hotkey-delimiter characters */ - /* Anything after \t is a shortcut key on Win32 */ - do { - if( *p == '&' ) p++; - if( ! *p || *p == '\t' || *p != *q ) break; - p++; q++; - } while( 1 ); - - if( *p && *p != '\t' ) continue; /* not matched */ - - /* match, but with a submenu */ - if( *q == '/' ) return set_active( GetSubMenu( menu, i ), q, active ); - - if( *q ) continue; /* not matched */ - - /* we have a match */ - mii.fState = active ? MFS_ENABLED : MFS_DISABLED; - mii.fMask = MIIM_STATE; - mii.cbSize = sizeof( MENUITEMINFO ); - SetMenuItemInfo( menu, i, TRUE, &mii ); - - return 0; - } - - return 1; -} - -int -ui_menu_item_set_active( const char *path, int active ) -{ - return set_active( GetMenu( fuse_hWnd ), path, active ); -} - -ui_confirm_joystick_t -ui_confirm_joystick( libspectrum_joystick libspectrum_type, int inputs ) -{ - win32ui_select_info items; - TCHAR title[ 80 ]; - int i, selection; - int selected_joystick; - - if( !settings_current.joy_prompt ) return UI_CONFIRM_JOYSTICK_NONE; - - /* Some space to store the radio options in */ - items.labels = malloc( JOYSTICK_CONN_COUNT * sizeof( char * ) ); - if( !items.labels ) { - ui_error( UI_ERROR_ERROR, "out of memory at %s:%d", __FILE__, __LINE__ ); - return UI_CONFIRM_JOYSTICK_NONE; - } - - /* Stop emulation */ - fuse_emulation_pause(); - - /* Populate win32ui_select_info */ - /* FIXME: libspectrum_joystick_name is not unicode compliant */ - _sntprintf( title, ARRAY_SIZE( title ), _T( "Fuse - Configure %s Joystick" ), - libspectrum_joystick_name( libspectrum_type ) ); - items.dialog_title = title; - items.length = JOYSTICK_CONN_COUNT; - - for( i=0; i= 0 )? selection : UI_CONFIRM_JOYSTICK_NONE; - - free( items.labels ); - - /* And then carry on with emulation again */ - fuse_emulation_unpause(); - - return selected_joystick; -} - -/* - * Font code - */ - -int -win32ui_get_monospaced_font( HFONT *font ) -{ - if( ! monospaced_font ) { - /* Get font height in pixels for current DPI resolution */ - HDC hdc = GetDC( NULL ); - long font_height = -MulDiv( 8, GetDeviceCaps( hdc, LOGPIXELSY ), 72 ); - ReleaseDC( NULL, hdc ); - - *font = CreateFont( font_height, 0, 0, 0, 400, FALSE, FALSE, FALSE, 0, - 400, 2, 1, 1, TEXT( "Courier New" ) ); - if( *font == NULL ) { - ui_error( UI_ERROR_ERROR, "couldn't find a monospaced font" ); - return 1; - } - monospaced_font = *font; - } - else { - *font = monospaced_font; - } - - return 0; -} - -int -window_recommended_width( HWND hwndDlg, LPCTSTR title ) -{ - HDC dc; - SIZE sz; - LONG_PTR window_style; - NONCLIENTMETRICS ncm; - HFONT hCaptionFont, hDefaultFont; - RECT cr, wr; - int width, buttons; - - /* Get window style */ - window_style = GetWindowLongPtr( hwndDlg, GWL_STYLE ); - if( !( window_style & WS_CAPTION ) ) return 0; - - /* Get caption bar font */ - dc = GetDC( hwndDlg ); - if( !dc ) return 0; - ncm.cbSize = sizeof( NONCLIENTMETRICS ); - /* FIXME: iPaddedBorderWidth, - http://msdn.microsoft.com/en-us/library/ms724506%28VS.85%29.aspx */ - SystemParametersInfo( SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0 ); - hCaptionFont = CreateFontIndirect( &ncm.lfCaptionFont ); - hDefaultFont = SelectObject( dc, hCaptionFont ); - - /* Calculate title width (pixels) */ - SetMapMode( dc, MM_TEXT ); - GetTextExtentPoint32( dc, title, _tcslen( title ), &sz ); - width = sz.cx; /* Actually in pixels because of MM_TEXT map mode */ - SelectObject( dc, hDefaultFont ); - DeleteObject( hCaptionFont ); - ReleaseDC( hwndDlg, dc ); - - /* Calculate buttons width (pixels) */ - buttons = 1; /* close button */ - if( window_style & WS_MAXIMIZEBOX ) buttons++; - if( window_style & WS_MINIMIZEBOX ) buttons++; - width += ncm.iCaptionWidth * buttons; - - /* Window decorations width (pixels) */ - GetWindowRect( hwndDlg, &wr ); - GetClientRect( hwndDlg, &cr ); - width += ( wr.right - wr.left ) - ( cr.right - cr.left ); - - /* Icon width (pixels) */ - window_style = GetWindowLongPtr( hwndDlg, GWL_EXSTYLE ); - if( !(window_style & WS_EX_DLGMODALFRAME) ) - width += GetSystemMetrics( SM_CXSMICON ); - - /* Padding, space between text and buttons */ - width += 20; - - return width; -} - -void -win32ui_set_font( HWND hDlg, int nIDDlgItem, HFONT font ) -{ - SendDlgItemMessage( hDlg, nIDDlgItem , WM_SETFONT, (WPARAM) font, FALSE ); -} - -static void -selector_dialog_build( HWND hwndDlg, win32ui_select_info *items ) -{ - int i, left, caption_width, decor_width, decor_height; - int window_width, window_height, client_width, client_height; - DWORD dwStyle; - RECT wr, cr, or; - - /* set the title of the window */ - SendMessage( hwndDlg, WM_SETTEXT, 0, (LPARAM) items->dialog_title ); - - /* Get decorations (pixels) */ - GetWindowRect( hwndDlg, &wr ); - GetClientRect( hwndDlg, &cr ); - decor_width = ( wr.right - wr.left ) - ( cr.right - cr.left ); - decor_height = ( wr.bottom - wr.top ) - ( cr.bottom - cr.top ); - - /* calculate window width (pixels) */ - or.left = or.top = or.bottom = 0; - or.right = 100 + 14 + 5; /* 2 buttons, 2 margins, 1 separation (DLUs) */ - MapDialogRect( hwndDlg, &or ); - - window_width = or.right + decor_width; - caption_width = window_recommended_width( hwndDlg, items->dialog_title ); - if( caption_width > window_width ) window_width = caption_width; - client_width = window_width - decor_width; - - /* create radio buttons */ - client_height = 7; /* Top margin (DLUs) */ - for( i=0; i< items->length; i++ ) { - - dwStyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_AUTORADIOBUTTON; - /* Need for WS_GROUP to allow using arrow up/down to cycle thru this group */ - if( i == 0 ) dwStyle = dwStyle | WS_GROUP; - - or.left = 7; /* Left margin (DLUs) */ - or.top = client_height; /* Top position (DLUs) */ - or.right = 160; /* Control width (DLUs) */ - or.bottom = 9; /* Control height (DLUs) */ - MapDialogRect( hwndDlg, &or ); - client_height += 9; /* Control height (DLUs) */ - - CreateWindow( TEXT( "BUTTON" ), items->labels[i], - dwStyle, - or.left, or.top, or.right, or.bottom, - hwndDlg, (HMENU) (LONG_PTR) ( IDC_SELECT_OFFSET + i ), fuse_hInstance, 0 ); - SendDlgItemMessage( hwndDlg, ( IDC_SELECT_OFFSET + i ), WM_SETFONT, - (WPARAM) h_ms_font, FALSE ); - - /* check the radiobutton corresponding to current label */ - if( i == items->selected ) { - SendDlgItemMessage( hwndDlg, ( IDC_SELECT_OFFSET + i ), BM_SETCHECK, - BST_CHECKED, 0 ); - } - - client_height += 2; /* Separation between radio buttons (DLUs) */ - } - client_height += 5; /* Space after radio buttons (actually 7 DLUs) */ - - /* create OK and Cancel buttons */ - or.left = 5; /* Vertical space between buttons (DLUs) */ - or.top = client_height; /* Position Y (DLUs) */ - or.right = 50; /* Typical width of buttons (DLUs) */ - or.bottom = 14; /* Typical height of buttons (DLUs) */ - MapDialogRect( hwndDlg, &or ); - - left = ( client_width - or.left - ( or.right * 2 ) ) / 2; /* centered */ - CreateWindow( TEXT( "BUTTON" ), TEXT( "&OK" ), - WS_VISIBLE | WS_CHILD | WS_TABSTOP | WS_GROUP | BS_DEFPUSHBUTTON, - left, or.top, or.right, or.bottom, - hwndDlg, (HMENU) IDOK, fuse_hInstance, 0 ); - SendDlgItemMessage( hwndDlg, IDOK, WM_SETFONT, - (WPARAM) h_ms_font, FALSE ); - - left += or.right + or.left; - CreateWindow( TEXT( "BUTTON" ), TEXT( "&Cancel" ), - WS_VISIBLE | WS_CHILD | WS_TABSTOP, - left, or.top, or.right, or.bottom, - hwndDlg, (HMENU) IDCANCEL, fuse_hInstance, 0 ); - SendDlgItemMessage( hwndDlg, IDCANCEL, WM_SETFONT, - (WPARAM) h_ms_font, FALSE ); - - client_height += 21; /* Button height (14) + bottom margin (7) (DLUs) */ - - /* Calculate window heigth (pixels) */ - wr.left = wr.top = wr.right = 0; - wr.bottom = client_height; - MapDialogRect( hwndDlg, &wr ); - window_height = decor_height + wr.bottom; - - /* the following will only change the size of the window */ - SetWindowPos( hwndDlg, NULL, 0, 0, window_width, window_height, - SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE ); -} - -static INT_PTR CALLBACK -selector_dialog_proc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) -{ - int i; - HWND next_item = NULL; - - switch( uMsg ) - { - case WM_INITDIALOG: - /* items are passed to WM_INITDIALOG as lParam */ - selector_dialog_build( hwndDlg, ( win32ui_select_info * ) lParam ); - return TRUE; - - case WM_SETFONT: - h_ms_font = (HFONT) wParam; - return TRUE; /* "This message does not return a value." */ - - case WM_COMMAND: - if ( HIWORD( wParam ) != BN_CLICKED ) break; - - /* service OK and Cancel buttons */ - switch( LOWORD( wParam ) ) - { - case IDOK: - { - /* check which radiobutton is selected and return the selection */ - i = 0; - while( ( next_item = GetNextDlgGroupItem( hwndDlg, next_item, - FALSE ) ) != NULL ) { - if( SendDlgItemMessage( hwndDlg, ( IDC_SELECT_OFFSET + i ), - BM_GETCHECK, 0, 0 ) == BST_CHECKED ) { - EndDialog( hwndDlg, i ); - return TRUE; - } - i++; - } - break; /* program should never reach here */ - } - case IDCANCEL: - EndDialog( hwndDlg, -1 ); - return TRUE; - } - /* service clicking radiobuttons */ - /* FIXME should also be checking if wParam < offset + radio count */ - if( LOWORD( wParam ) >= IDC_SELECT_OFFSET ) - return 0; - break; - - case WM_DESTROY: - EndDialog( hwndDlg, -1 ); - return TRUE; - } - return FALSE; -} - -static int -selector_dialog( win32ui_select_info *items ) -{ - /* selector_dialog will display a modal dialog, with a list of grouped - radiobuttons, OK and Cancel buttons. The radiobuttons' labels, their count, - current selection and dialog title are provided via win32ui_select_info. - The function returns an int corresponding to the selected radiobutton */ - - /* FIXME: fix accelerators for this window */ - - return DialogBoxParam( fuse_hInstance, MAKEINTRESOURCE( IDD_SELECT_DIALOG ), - fuse_hWnd, selector_dialog_proc, ( LPARAM )items ); -} - -void -win32_verror( int is_error ) -{ - if( !is_error ) return; - - DWORD last_error; - static LPVOID err_msg; - last_error = GetLastError(); - FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM, - NULL, last_error, LANG_USER_DEFAULT, - (LPTSTR) &err_msg, 0, NULL ); - MessageBox( fuse_hWnd, err_msg, "Error", MB_OK ); -} - -/* Handler for the main window's WM_PAINT notification. - The handler is an equivalent of GTK's expose_event */ -static int -win32ui_window_paint( HWND hWnd, WPARAM wParam, LPARAM lParam ) -{ - blit(); - return 0; -} - -/* Handler for the main window's WM_SIZE notification */ -static int -win32ui_window_resize( HWND hWnd, WPARAM wParam, LPARAM lParam ) -{ - if( wParam == SIZE_MINIMIZED ) { - if( !size_paused ) { - size_paused = 1; - fuse_emulation_pause(); - - /* Process UI events until the window is restored */ - win32ui_process_messages( 0 ); - } - } else { - win32display_drawing_area_resize( LOWORD( lParam ), HIWORD( lParam ), 1 ); - - /* Resize statusbar and inner parts */ - SendMessage( fuse_hStatusWindow, WM_SIZE, wParam, lParam ); - win32statusbar_resize( hWnd, wParam, lParam ); - - if( size_paused ) { - timer_estimate_reset(); - PostMessage( fuse_hWnd, WM_USER_EXIT_PROCESS_MESSAGES, 0, 0 ); - - size_paused = 0; - fuse_emulation_unpause(); - } - } - - return 0; -} - -/* Handler for the main window's WM_SIZING notification. - The handler is an equivalent of setting window geometry in GTK */ -static BOOL -win32ui_window_resizing( HWND hWnd, WPARAM wParam, LPARAM lParam ) -{ - RECT *selr, wr, cr, statr, or; - int width, height, w_ofs, h_ofs, w_max, h_max; - - selr = (RECT *)lParam; - GetWindowRect( fuse_hWnd, &wr ); - GetClientRect( fuse_hWnd, &cr ); - GetClientRect( fuse_hStatusWindow, &statr ); - - w_ofs = ( wr.right - wr.left ) - ( cr.right - cr.left ); - h_ofs = ( wr.bottom - wr.top ) - ( cr.bottom - cr.top ); - if( settings_current.statusbar ) h_ofs += ( statr.bottom - statr.top ); - - /* max scaler size in desktop workarea */ - SystemParametersInfo( SPI_GETWORKAREA, 0, &or, 0 ); - w_max = ( or.right - or.left ) - w_ofs + DISPLAY_ASPECT_WIDTH / 2; - w_max /= DISPLAY_ASPECT_WIDTH; - h_max = ( or.bottom - or.top ) - h_ofs + DISPLAY_SCREEN_HEIGHT / 2; - h_max /= DISPLAY_SCREEN_HEIGHT; - - if( w_max < h_max ) { - h_max = w_max; - } else { - w_max = h_max; - } - - /* current scaler */ - width = selr->right - selr->left + DISPLAY_ASPECT_WIDTH / 2; - height = selr->bottom - selr->top + DISPLAY_SCREEN_HEIGHT / 2; - - width -= w_ofs; height -= h_ofs; - width /= DISPLAY_ASPECT_WIDTH; height /= DISPLAY_SCREEN_HEIGHT; - - if( wParam == WMSZ_LEFT || wParam == WMSZ_RIGHT ) { - height = width; - } else if( wParam == WMSZ_TOP || wParam == WMSZ_BOTTOM ) { - width = height; - } - - if( width < 1 || height < 1 ) { - width = 1; height = 1; - } - - if( width > w_max || height > h_max ) { - width = w_max; height = h_max; - } - - if( width > MAX_SCALE || height > MAX_SCALE ) { - width = MAX_SCALE; height = MAX_SCALE; - } - - if( width < height ) { - height = width; - } else { - width = height; - } - - width *= DISPLAY_ASPECT_WIDTH; height *= DISPLAY_SCREEN_HEIGHT; - width += w_ofs; height += h_ofs; - - /* Set window size */ - if( wParam == WMSZ_TOP || - wParam == WMSZ_TOPLEFT || - wParam == WMSZ_TOPRIGHT ) { - selr->top = selr->bottom - height; - } else { - selr->bottom = selr->top + height; - } - if( wParam == WMSZ_LEFT || - wParam == WMSZ_TOPLEFT || - wParam == WMSZ_BOTTOMLEFT ) { - selr->left = selr->right - width; - } else { - selr->right = selr->left + width; - } - - return TRUE; -} - -/* The function is an equivalent of GTK's gtk_window_resize, - take care of resizing main window into visible screen */ -void -win32ui_fuse_resize( int width, int height ) -{ - RECT wr, cr, statr, or; - int w_ofs, h_ofs; - - /* Calculate decorations before resizing */ - GetWindowRect( fuse_hWnd, &wr ); - GetClientRect( fuse_hWnd, &cr ); - GetClientRect( fuse_hStatusWindow, &statr ); - - w_ofs = ( wr.right - wr.left ) - ( cr.right - cr.left ); - h_ofs = ( wr.bottom - wr.top ) - ( cr.bottom - cr.top ); - if( settings_current.statusbar ) h_ofs += ( statr.bottom - statr.top ); - - /* Set position inside workarea */ - SystemParametersInfo( SPI_GETWORKAREA, 0, &or, 0 ); - if( wr.left + width + w_ofs > or.right ) wr.left = or.right - width - w_ofs; - if( wr.top + height + h_ofs > or.bottom ) wr.top = or.bottom - height - h_ofs; - if( wr.left < or.left ) wr.left = or.left; - if( wr.top < or.top ) wr.top = or.top; - - MoveWindow( fuse_hWnd, wr.left, wr.top, - width + w_ofs, - height + h_ofs, - TRUE ); -} - -/* win32ui_process_messages() is an equivalent of gtk's gtk_main(), - * it processes messages until it receives WM_USER_EXIT_PROCESS_MESSAGES - * message, which should be sent using: - * PostMessage( fuse_hWnd, WM_USER_EXIT_PROCESS_MESSAGES, 0, 0 ); - * ( equivalent of gtk_main_quit() ); - * With process_queue_once = 1 it checks for messages pending for fuse - * window, processes them and exists. - * With process_queue_once = 0 it processes the messages until it receives - * WM_USER_EXIT_PROCESS_MESSAGES message. - */ -void -win32ui_process_messages( int process_queue_once ) -{ - MSG msg; - int i, processMsg; - HWND hModelessDlgs[] = { fuse_hPFWnd, fuse_hDBGWnd, fuse_hABOWnd }; - - while( 1 ) { - while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { - /* FIXME: rethink this loop, IsDialogMessage in particular */ - processMsg = TRUE; - - for( i = 0; processMsg && i < ARRAY_SIZE( hModelessDlgs ); i++) { - if( IsDialogMessage( hModelessDlgs[i], &msg ) ) processMsg = FALSE; - } - - if( processMsg ) { - if( !TranslateAccelerator( fuse_hWnd, hAccels, &msg ) ) { - if( ( LOWORD( msg.message ) == WM_QUIT ) || - ( LOWORD( msg.message ) == WM_USER_EXIT_PROCESS_MESSAGES ) ) - return; - /* FIXME: set exit flag somewhere */ - TranslateMessage( &msg ); - DispatchMessage( &msg ); - } - } - } - if( process_queue_once ) return; - - /* If we miss WM_USER_EXIT_PROCESS_MESSAGES, the window procedure will - kindly notify us */ - if( exit_process_messages ) { - exit_process_messages--; - return; - } - - WaitMessage(); - } - /* FIXME: somewhere there should be return msg.wParam */ -} diff --git a/fuse/ui/xlib/Makefile.am b/fuse/ui/xlib/Makefile.am deleted file mode 100644 index a2345ec..0000000 --- a/fuse/ui/xlib/Makefile.am +++ /dev/null @@ -1,61 +0,0 @@ -## Process this file with automake to produce Makefile.in -## Copyright (c) 2001-2004 Philip Kendall -## Copyright (c) 2015 Sergio Baldoví - -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -## -## Author contact information: -## -## E-mail: philip-fuse@shadowmagic.org.uk - -if UI_X - -fuse_SOURCES += $(ui_xlib_files) - -BUILT_SOURCES += $(ui_xlib_built) - -endif - - -EXTRA_fuse_SOURCES += $(ui_xlib_files) - -CLEANFILES += $(ui_xlib_built) - -ui_xlib_files = \ - ui/xlib/keysyms.c \ - ui/xlib/xdisplay.c \ - ui/xlib/xdisplay.h \ - ui/xlib/xerror.c \ - ui/xlib/xjoystick.c \ - ui/xlib/xkeyboard.c \ - ui/xlib/xkeyboard.h \ - ui/xlib/xui.c \ - ui/xlib/xui.h - -ui_xlib_built = \ - ui/xlib/keysyms.c \ - ui/xlib/xpixmaps.c - -EXTRA_DIST += \ - ui/xlib/xpixmaps.c \ - ui/xlib/xstatusbar.pl - -ui/xlib/keysyms.c: $(srcdir)/keysyms.pl $(srcdir)/keysyms.dat - @$(MKDIR_P) ui/xlib - $(AM_V_GEN)$(PERL) -I$(srcdir)/perl $(srcdir)/keysyms.pl x $(srcdir)/keysyms.dat > $@.tmp && mv $@.tmp $@ - -ui/xlib/xpixmaps.c: ui/xlib/xstatusbar.pl $(srcdir)/ui/gtk/pixmaps.c - @$(MKDIR_P) ui/xlib - $(AM_V_GEN)$(PERL) -I$(srcdir)/perl $(srcdir)/ui/xlib/xstatusbar.pl $(srcdir)/ui/gtk/pixmaps.c > $@.tmp && mv $@.tmp $@ diff --git a/fuse/ui/xlib/keysyms.c b/fuse/ui/xlib/keysyms.c deleted file mode 100644 index 97ad354..0000000 --- a/fuse/ui/xlib/keysyms.c +++ /dev/null @@ -1,178 +0,0 @@ -/* keysyms.c: UI keysym to Fuse input layer keysym mappings - Copyright (c) 2000-2007 Philip Kendall, Matan Ziv-Av, Russell Marks - Fredrick Meunier, Catalin Mihaila, Stuart Brady - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -/* This file is autogenerated from keysyms.dat by keysyms.pl. - Do not edit unless you know what you're doing! */ - -#include - - -#include "input.h" -#include "keyboard.h" - -#include - -keysyms_map_t keysyms_map[] = { - - { XK_Tab, INPUT_KEY_Tab }, - { XK_Return, INPUT_KEY_Return }, - { XK_Escape, INPUT_KEY_Escape }, - { XK_space, INPUT_KEY_space }, - { XK_exclam, INPUT_KEY_exclam }, - { XK_quotedbl, INPUT_KEY_quotedbl }, - { XK_numbersign, INPUT_KEY_numbersign }, - { XK_dollar, INPUT_KEY_dollar }, - { XK_percent, INPUT_KEY_percent }, - { XK_ampersand, INPUT_KEY_ampersand }, - { XK_apostrophe, INPUT_KEY_apostrophe }, - { XK_parenleft, INPUT_KEY_parenleft }, - { XK_parenright, INPUT_KEY_parenright }, - { XK_asterisk, INPUT_KEY_asterisk }, - { XK_plus, INPUT_KEY_plus }, - { XK_comma, INPUT_KEY_comma }, - { XK_minus, INPUT_KEY_minus }, - { XK_period, INPUT_KEY_period }, - { XK_slash, INPUT_KEY_slash }, - { XK_0, INPUT_KEY_0 }, - { XK_1, INPUT_KEY_1 }, - { XK_2, INPUT_KEY_2 }, - { XK_3, INPUT_KEY_3 }, - { XK_4, INPUT_KEY_4 }, - { XK_5, INPUT_KEY_5 }, - { XK_6, INPUT_KEY_6 }, - { XK_7, INPUT_KEY_7 }, - { XK_8, INPUT_KEY_8 }, - { XK_9, INPUT_KEY_9 }, - { XK_colon, INPUT_KEY_colon }, - { XK_semicolon, INPUT_KEY_semicolon }, - { XK_less, INPUT_KEY_less }, - { XK_equal, INPUT_KEY_equal }, - { XK_greater, INPUT_KEY_greater }, - { XK_question, INPUT_KEY_question }, - { XK_at, INPUT_KEY_at }, - { XK_A, INPUT_KEY_A }, - { XK_B, INPUT_KEY_B }, - { XK_C, INPUT_KEY_C }, - { XK_D, INPUT_KEY_D }, - { XK_E, INPUT_KEY_E }, - { XK_F, INPUT_KEY_F }, - { XK_G, INPUT_KEY_G }, - { XK_H, INPUT_KEY_H }, - { XK_I, INPUT_KEY_I }, - { XK_J, INPUT_KEY_J }, - { XK_K, INPUT_KEY_K }, - { XK_L, INPUT_KEY_L }, - { XK_M, INPUT_KEY_M }, - { XK_N, INPUT_KEY_N }, - { XK_O, INPUT_KEY_O }, - { XK_P, INPUT_KEY_P }, - { XK_Q, INPUT_KEY_Q }, - { XK_R, INPUT_KEY_R }, - { XK_S, INPUT_KEY_S }, - { XK_T, INPUT_KEY_T }, - { XK_U, INPUT_KEY_U }, - { XK_V, INPUT_KEY_V }, - { XK_W, INPUT_KEY_W }, - { XK_X, INPUT_KEY_X }, - { XK_Y, INPUT_KEY_Y }, - { XK_Z, INPUT_KEY_Z }, - { XK_bracketleft, INPUT_KEY_bracketleft }, - { XK_backslash, INPUT_KEY_backslash }, - { XK_bracketright, INPUT_KEY_bracketright }, - { XK_asciicircum, INPUT_KEY_asciicircum }, - { XK_dead_circumflex, INPUT_KEY_dead_circumflex }, - { XK_underscore, INPUT_KEY_underscore }, - { XK_a, INPUT_KEY_a }, - { XK_b, INPUT_KEY_b }, - { XK_c, INPUT_KEY_c }, - { XK_d, INPUT_KEY_d }, - { XK_e, INPUT_KEY_e }, - { XK_f, INPUT_KEY_f }, - { XK_g, INPUT_KEY_g }, - { XK_h, INPUT_KEY_h }, - { XK_i, INPUT_KEY_i }, - { XK_j, INPUT_KEY_j }, - { XK_k, INPUT_KEY_k }, - { XK_l, INPUT_KEY_l }, - { XK_m, INPUT_KEY_m }, - { XK_n, INPUT_KEY_n }, - { XK_o, INPUT_KEY_o }, - { XK_p, INPUT_KEY_p }, - { XK_q, INPUT_KEY_q }, - { XK_r, INPUT_KEY_r }, - { XK_s, INPUT_KEY_s }, - { XK_t, INPUT_KEY_t }, - { XK_u, INPUT_KEY_u }, - { XK_v, INPUT_KEY_v }, - { XK_w, INPUT_KEY_w }, - { XK_x, INPUT_KEY_x }, - { XK_y, INPUT_KEY_y }, - { XK_z, INPUT_KEY_z }, - { XK_braceleft, INPUT_KEY_braceleft }, - { XK_bar, INPUT_KEY_bar }, - { XK_braceright, INPUT_KEY_braceright }, - { XK_asciitilde, INPUT_KEY_asciitilde }, - { XK_BackSpace, INPUT_KEY_BackSpace }, - { XK_KP_Enter, INPUT_KEY_KP_Enter }, - { XK_Up, INPUT_KEY_Up }, - { XK_Down, INPUT_KEY_Down }, - { XK_Left, INPUT_KEY_Left }, - { XK_Right, INPUT_KEY_Right }, - { XK_Insert, INPUT_KEY_Insert }, - { XK_Delete, INPUT_KEY_Delete }, - { XK_Home, INPUT_KEY_Home }, - { XK_End, INPUT_KEY_End }, - { XK_Page_Up, INPUT_KEY_Page_Up }, - { XK_Page_Down, INPUT_KEY_Page_Down }, - { XK_Caps_Lock, INPUT_KEY_Caps_Lock }, - { XK_F1, INPUT_KEY_F1 }, - { XK_F2, INPUT_KEY_F2 }, - { XK_F3, INPUT_KEY_F3 }, - { XK_F4, INPUT_KEY_F4 }, - { XK_F5, INPUT_KEY_F5 }, - { XK_F6, INPUT_KEY_F6 }, - { XK_F7, INPUT_KEY_F7 }, - { XK_F8, INPUT_KEY_F8 }, - { XK_F9, INPUT_KEY_F9 }, - { XK_F10, INPUT_KEY_F10 }, - { XK_F11, INPUT_KEY_F11 }, - { XK_F12, INPUT_KEY_F12 }, - { XK_Shift_L, INPUT_KEY_Shift_L }, - { XK_Shift_R, INPUT_KEY_Shift_R }, - { XK_Control_L, INPUT_KEY_Control_L }, - { XK_Control_R, INPUT_KEY_Control_R }, - { XK_Alt_L, INPUT_KEY_Alt_L }, - { XK_Alt_R, INPUT_KEY_Alt_R }, - { XK_Meta_L, INPUT_KEY_Meta_L }, - { XK_Meta_R, INPUT_KEY_Meta_R }, - { XK_Super_L, INPUT_KEY_Super_L }, - { XK_Super_R, INPUT_KEY_Super_R }, - { XK_Hyper_L, INPUT_KEY_Hyper_L }, - { XK_Hyper_R, INPUT_KEY_Hyper_R }, - { XK_Mode_switch, INPUT_KEY_Mode_switch }, - - { 0, 0 } /* End marker: DO NOT MOVE! */ - -}; - diff --git a/fuse/ui/xlib/xdisplay.c b/fuse/ui/xlib/xdisplay.c deleted file mode 100644 index 52b6921..0000000 --- a/fuse/ui/xlib/xdisplay.c +++ /dev/null @@ -1,1211 +0,0 @@ -/* xdisplay.c: Routines for dealing with drawing the Speccy's screen via Xlib - Copyright (c) 2000-2005 Philip Kendall, Darren Salt, Gergely Szász - Copyright (c) 2015 Stuart Brady - Copyright (c) 2015 Sergio Baldoví - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_SIGINFO_H -#include /* Needed for psignal on Solaris */ -#endif /* #ifdef HAVE_SIGINFO_H */ - -#ifdef HAVE_X11_EXTENSIONS_XSHM_H -#define X_USE_SHM -#endif /* #ifdef HAVE_X11_EXTENSIONS_XSHM_H */ - -#ifdef X_USE_SHM -#include -#include -#include -#endif /* #ifdef X_USE_SHM */ - -#include - -#include "display.h" -#include "fuse.h" -#include "keyboard.h" -#include "machine.h" -#include "peripherals/scld.h" -#include "screenshot.h" -#include "settings.h" -#include "xdisplay.h" -#include "xui.h" -#include "ui/scaler/scaler.h" -#include "ui/ui.h" -#include "ui/uidisplay.h" - -void xstatusbar_init( int size ); - -typedef enum { - MSB_RED = 0, /* 0RGB */ - LSB_RED, /* 0BGR */ - /* ARGB/ABGR RGBA/BGRA ????*/ -} redmask_t; - -static XImage *image = NULL; /* The image structure to draw the - Speccy's screen on */ -static GC gc; /* A graphics context to draw with */ - -Colormap currentMap; /* The used colormap */ - -/* The size of a 1x1 image in units of - DISPLAY_ASPECT WIDTH x DISPLAY_SCREEN_HEIGHT - scale * 4, so 2 => 0.5, 6 => 1.5, 4 => 1.0 */ -static int image_scale = 1; - -/* The height and width of a 1x1 image in pixels */ -static int image_width, image_height, scaled_image_w, scaled_image_h; - -/* An RGB image of the Spectrum screen; slightly bigger than the real - screen to handle the smoothing filters which read around each pixel 16bpp */ -static libspectrum_word - rgb_image[2 * ( DISPLAY_SCREEN_HEIGHT + 4 )][2 * ( DISPLAY_SCREEN_WIDTH + 3 )]; -static const int rgb_pitch = 2 * ( DISPLAY_SCREEN_WIDTH + 3 ); - -/* A scaled copy of the image displayed on the Spectrum's screen */ -static libspectrum_word - scaled_image[4 * DISPLAY_SCREEN_HEIGHT][4 * DISPLAY_SCREEN_WIDTH]; -static const ptrdiff_t scaled_pitch = - 4 * DISPLAY_SCREEN_WIDTH * 2; - -/* A scaled copy of the image displayed on the Spectrum's screen */ -static libspectrum_word - rgb_image_backup[2 * ( DISPLAY_SCREEN_HEIGHT + 4 )][2 * ( DISPLAY_SCREEN_WIDTH + 3 )]; - -static unsigned long colours[128]; -static int colours_allocated = 0; - -/* The current size of the window (in units of DISPLAY_SCREEN_*) */ -static int xdisplay_current_size = 1; -static int xdisplay_depth = -1; -static Visual *xdisplay_visual = NULL; -static int xdisplay_bw = -1; -static redmask_t xdisplay_redpos = MSB_RED; /* red_mask 0xff000 ...*/ -static int rShift = 16, gShift = 8, bShift = 0; - -/* This is a rule of thumb for the maximum number of rects that can be updated - each frame. If more are generated we just update the whole screen */ -typedef struct { - int x; int y; int w; int h; -} X_Rect; -#define MAX_UPDATE_RECT 300 -static X_Rect updated_rects[MAX_UPDATE_RECT]; -static int num_rects = 0; -static libspectrum_byte xdisplay_force_full_refresh = 1; - -#ifdef X_USE_SHM -static XShmSegmentInfo shm_info; -int shm_eventtype; - -static int try_shm( void ); -static int get_shm_id( const int size ); -#endif /* #ifdef X_USE_SHM */ - -static int shm_used = 0; - -typedef void xdisplay_update_rect_t( int x, int y, int w, int h ); - -static xdisplay_update_rect_t *xdisplay_update_rect; -static xdisplay_update_rect_t xdisplay_update_rect_noscale; -static xdisplay_update_rect_t xdisplay_update_rect_scale; - -static int xdisplay_find_visual( void ); -static int xdisplay_allocate_colours4( void ); -static int xdisplay_allocate_colours8( void ); -static int xdisplay_allocate_gc( Window window, GC *new_gc ); - -static int xdisplay_allocate_image( void ); -static void register_scalers( void ); -static void xdisplay_destroy_image( void ); -static void xdisplay_catch_signal( int sig ); - -typedef void xdisplay_putpixel_t( int x, int y, libspectrum_word *color ); - -static xdisplay_putpixel_t *xdisplay_putpixel; - -static xdisplay_putpixel_t xdisplay_putpixel_4; -static xdisplay_putpixel_t xdisplay_putpixel_8; -static xdisplay_putpixel_t xdisplay_putpixel_15; -static xdisplay_putpixel_t xdisplay_putpixel_16; -static xdisplay_putpixel_t xdisplay_putpixel_24; - -#include "ui/xlib/xpixmaps.c" -void xstatusbar_overlay( void ); - -static libspectrum_word pal_colour[16] = { - 0x0000, 0x0017, 0xb800, 0xb817, 0x05e0, 0x05f7, 0xbde0, 0xbdf7, - 0x0000, 0x001f, 0xf800, 0xf81f, 0x07e0, 0x07ff, 0xffe0, 0xffff, -}; - -static libspectrum_word pal_grey[16] = { - 0x0000, 0x39c7, 0x18a3, 0x526a, 0x738e, 0xad55, 0x8430, 0xbdf7, - 0x0000, 0x4a69, 0x20e4, 0x6b4d, 0x94b2, 0xdf1b, 0xb596, 0xffff, -}; - -static int rgb_for_4[] = { - 0x00, 0x00, 0x00, - 0x00, 0x00, 0xBF, - 0xBF, 0x00, 0x00, - 0xBF, 0x00, 0xBF, - 0x00, 0xBF, 0x00, - 0x00, 0xBF, 0xBF, - 0xBF, 0xBF, 0x00, - 0xBF, 0xBF, 0xBF, - 0x00, 0x00, 0x00, - 0x00, 0x00, 0xFF, - 0xFF, 0x00, 0x00, - 0xFF, 0x00, 0xFF, - 0x00, 0xFF, 0x00, - 0x00, 0xFF, 0xFF, - 0xFF, 0xFF, 0x00, - 0xFF, 0xFF, 0xFF -}; - -int -xdisplay_init( void ) -{ - if( xdisplay_find_visual() ) return 1; - if( xdisplay_depth == 4 && xdisplay_allocate_colours4() ) return 1; - if( xdisplay_depth == 8 && xdisplay_allocate_colours8() ) return 1; - if( xdisplay_allocate_gc( xui_mainWindow,&gc ) ) return 1; - if( xdisplay_allocate_image() ) return 1; - ui_statusbar_update( UI_STATUSBAR_ITEM_TAPE, UI_STATUSBAR_STATE_INACTIVE ); - - return 0; -} - -static int -xdisplay_find_visual( void ) -{ - XVisualInfo visual_tmpl; - XVisualInfo *vis; - int nvis, i; - int sel_v = -1; - int sel_v_depth = -1; - int sel_v_class = -1; - - visual_tmpl.screen = xui_screenNum; - vis = XGetVisualInfo( display, - VisualScreenMask, - &visual_tmpl, &nvis ); - if( vis != NULL ) { - for( i = 0; i < nvis; i++ ) { - /* - * Save the visual index and its depth, if this is the first - * truecolor visual, or a visual that is 'preferred' over the - * previous 'best' visual. - */ - if( ( sel_v_depth == -1 && vis[i].depth >= 4 ) || /* depth >= 4 */ - ( vis[i].depth > sel_v_depth && - vis[i].depth <= 16 ) || /* depth up to 16 */ - ( vis[i].depth <= 8 && vis[i].depth == sel_v_depth && - vis[i].class != sel_v_class && - vis[i].class == PseudoColor ) || /* indexed changable palette */ - ( vis[i].depth > 8 && vis[i].depth == sel_v_depth && - vis[i].class != sel_v_class && - vis[i].class == TrueColor ) /* decomposed constatant colors */ - ) { - sel_v = i; - sel_v_depth = vis[i].depth; - sel_v_class = vis[i].class; - } - } - - if ( sel_v != -1 ) { - xdisplay_visual = vis[sel_v].visual; - xdisplay_depth = vis[sel_v].depth; - } - XFree(vis); - } - return sel_v == -1 ? 1 : 0; -} - -static void -xdisplay_putpixel_4( int x, int y, libspectrum_word *colour) -{ - XPutPixel( image, x, y, *colour ); -} - -static void -xdisplay_putpixel_8( int x, int y, libspectrum_word *colour) -{ - unsigned long c = *colour; - - c = ( c & 0x1f ) * 3 / 31 + - ( ( ( ( c >> 5 ) & 0x3f ) * 7 / 63 ) << 2 ) + - ( ( ( c >> 11 ) * 3 / 31 ) << 5 ); - XPutPixel( image, x, y, colours[ c ] ); -} - -static void -xdisplay_putpixel_15( int x, int y, libspectrum_word *colour) -{ - unsigned long c = *colour; - - c = ( c & 0x1f ) + ( ( c >> 1 ) & 0xffe0 ); - XPutPixel( image, x, y, c ); -} - -static void -xdisplay_putpixel_16( int x, int y, libspectrum_word *colour) -{ - XPutPixel( image, x, y, *colour ); -} - -static void -xdisplay_putpixel_24( int x, int y, libspectrum_word *colour) -{ - unsigned long c = *colour; - - c = ( ( ( c & 0x1f ) * 255 / 31 ) << bShift ) + - ( ( ( ( c >> 5 ) & 0x3f ) * 255 / 63 ) << gShift ) + - ( ( ( c >> 11 ) * 255 / 31 ) << rShift ); - XPutPixel( image, x, y, c ); -} - -static int -xdisplay_alloc_colour( Colormap *map, XColor *colour ) -{ - for(;;) { - if( XAllocColor( display, *map, colour ) ) - return 0; - - fprintf(stderr,"%s: XAllocColor failed (%04x %04x %04x)\n", fuse_progname, - colour->red, colour->green, colour->blue ); - if( *map == DefaultColormap( display, xui_screenNum ) ) { - fprintf( stderr,"%s: switching to private colour map\n", fuse_progname ); - *map = XCopyColormapAndFree( display, *map ); - XSetWindowColormap( display, xui_mainWindow, *map ); - /* Need to repeat the failed allocation */ - } else { - return 1; - } - } - return 0; -} - -static int -xdisplay_allocate_colours4( void ) -{ - XColor c; - int i; - - currentMap = DefaultColormap( display, xui_screenNum ); - - if( colours_allocated ) { /* free it */ - XFreeColors( display, currentMap, colours, 16, 0x00 ); - colours_allocated = 0; - } - if( settings_current.bw_tv ) { - for( i=0; i<16; i++ ) { /* grey */ - c.red = c.green = c.blue = - rgb_for_4[i * 3 ] * 19595 / 255 + - rgb_for_4[i * 3 + 1] * 38469 / 255 + - rgb_for_4[i * 3 + 2] * 7471 / 255; - if( xdisplay_alloc_colour( ¤tMap, &c ) ) - return 1; - colours[i] = pal_grey[i] = c.pixel; - } - } else { - for( i=0; i<16; i++ ) { /* rgb */ - c.red = rgb_for_4[i * 3 ] * 65535 / 255; - c.green = rgb_for_4[i * 3 + 1] * 65535 / 255; - c.blue = rgb_for_4[i * 3 + 2] * 65535 / 255; - if( xdisplay_alloc_colour( ¤tMap, &c ) ) - return 1; - colours[i] = pal_colour[i] = c.pixel; - } - } - - colours_allocated = 1; - return 0; -} - -static int -xdisplay_allocate_colours8( void ) -{ - XColor c; - int i, r, g, b; - - currentMap = DefaultColormap( display, xui_screenNum ); - - if( colours_allocated ) { /* free it */ - XFreeColors( display, currentMap, colours, 128, 0x00 ); - colours_allocated = 0; - } - i = 0; - for( r=0; r<4; r++ ) /* rgb232 => 128 */ - for( g=0; g<8; g++ ) - for( b=0; b<4; b++ ) { - if( settings_current.bw_tv ) { - c.red = c.green = c.blue = r * 19595 / 3 + - g * 38469 / 7 + - b * 7471 / 3; - } else { - c.red = r * 65535 / 3; - c.green = g * 65535 / 7; - c.blue = b * 65535 / 3; - } - if( xdisplay_alloc_colour( ¤tMap, &c ) ) - return 1; - colours[i++] = c.pixel; - } - colours_allocated = 1; - - return 0; -} - -static int -xdisplay_allocate_gc( Window window, GC *new_gc ) -{ - unsigned valuemask=0; - XGCValues values; - - *new_gc = XCreateGC( display, window, valuemask, &values ); - - return 0; -} - -static int -xdisplay_allocate_image( void ) -{ - struct sigaction handler; - - handler.sa_handler = xdisplay_catch_signal; - sigemptyset( &handler.sa_mask ); - handler.sa_flags = 0; - sigaction( SIGINT, &handler, NULL ); - -#ifdef X_USE_SHM - shm_used = try_shm(); -#endif /* #ifdef X_USE_SHM */ - - /* If SHM isn't available, or we're not using it for some reason, - just get a normal image */ - if( !shm_used ) { - image = XCreateImage( display, xdisplay_visual, - xdisplay_depth, ZPixmap, 0, NULL, - 4 * DISPLAY_ASPECT_WIDTH, - 4 * DISPLAY_SCREEN_HEIGHT + 4 * PIXMAPS_H, 8, 0 ); -/* - we allocate extra space after the screen for status bar icons - status bar icons total width always smaller than 4xDISPLAY_ASPECT_WIDTH -*/ - if(!image) { - fprintf(stderr,"%s: couldn't create image\n",fuse_progname); - return 1; - } - - if( ( image->data = malloc( image->bytes_per_line * - image->height ) ) == NULL ) { - fprintf(stderr, "%s: out of memory for image data\n", fuse_progname); - return 1; - } - } - if( image ) { - switch( image->red_mask ) { - case 0xff0000: /* 24bit/32bit 0RGB */ - rShift = 16, gShift = 8, bShift = 0; - break; - case 0x0000ff: /* 24bit/32bit 0BGR */ - rShift = 0, gShift = 8, bShift = 16; - break; - case 0xff000000: /* 24bit/32bit RGB0 */ - rShift = 24, gShift = 16, bShift = 8; - break; - case 0x0000ff00: /* 24bit/32bit BGR0 */ - rShift = 8, gShift = 16, bShift = 24; - break; - case 0xf800: /* 16 RGB */ - case 0x7c00: /* 15 RGB */ - xdisplay_redpos = MSB_RED; - break; - case 0x001f: /* 16/15 BGR */ - xdisplay_redpos = LSB_RED; - break; - } - } - - return 0; -} - -#ifdef X_USE_SHM -static int -try_shm( void ) -{ - int id; - int error; - - if( !XShmQueryExtension( display ) ) return 0; - - shm_eventtype = XShmGetEventBase( display ) + ShmCompletion; - image = XShmCreateImage( display, xdisplay_visual, - xdisplay_depth, ZPixmap, - NULL, &shm_info, - 4 * DISPLAY_ASPECT_WIDTH, - 4 * DISPLAY_SCREEN_HEIGHT + 4 * PIXMAPS_H); -/* - we allocate extra space after the screen for status bar icons - status bar icons total width always smaller than 3xDISPLAY_ASPECT_WIDTH -*/ - if( !image ) return 0; - - /* Get an SHM to work with */ - id = get_shm_id( image->bytes_per_line * image->height ); - if( id == -1 ) return 0; - - /* Attempt to attach to the shared memory */ - shm_info.shmid = id; - image->data = shm_info.shmaddr = shmat( id, 0, 0 ); - - /* If we couldn't attach, remove the chunk and give up */ - if( image->data == (void*)-1 ) { - shmctl( id, IPC_RMID, NULL ); - image->data = NULL; - return 0; - } - - /* This may generate an X error */ - xerror_error = 0; xerror_expecting = 1; - error = !XShmAttach( display, &shm_info ); - - /* Force any X errors to occur before we disable traps */ - XSync( display, False ); - xerror_expecting = 0; - - /* If we caught an error, don't use SHM */ - if( error || xerror_error ) { - shmctl( id, IPC_RMID, NULL ); - shmdt( image->data ); image->data = NULL; - return 0; - } - - /* Now flag the chunk for deletion; this will take effect when - everything has detached from it */ - shmctl( id, IPC_RMID, NULL ); - - return 1; -} - -/* Get an SHM ID; also attempt to reclaim any stale chunks we find */ -static int -get_shm_id( const int size ) -{ - key_t key = 'F' << 24 | 'u' << 16 | 's' << 8 | 'e'; - struct shmid_ds shm; - - int id; - - int pollution = 5; - - do { - /* See if a chunk already exists with this key */ - id = shmget( key, size, 0777 ); - - /* If the chunk didn't already exist, try and create one for our - use */ - if( id == -1 ) { - id = shmget( key, size, IPC_CREAT | 0777 ); - continue; /* And then jump to the end of the loop */ - } - - /* If the chunk already exists, try and get information about it */ - if( shmctl( id, IPC_STAT, &shm ) != -1 ) { - - /* If something's actively using this chunk, try another key */ - if( shm.shm_nattch ) { - key++; - } else { /* Otherwise, attempt to remove the chunk */ - - /* If we couldn't remove that chunk, try another key. If we - could, just try again */ - if( shmctl( id, IPC_RMID, NULL ) != 0 ) key++; - } - } else { /* Couldn't get info on the chunk, so try next key */ - key++; - } - - id = -1; /* To prevent early exit from loop */ - - } while( id == -1 && --pollution ); - - return id; -} -#endif /* #ifdef X_USE_SHM */ - -int -uidisplay_init( int width, int height ) -{ - image_width = width; - image_height = height; - if( !scaler_is_supported( current_scaler ) ) { - if( machine_current->timex ) - scaler_select_scaler( SCALER_HALFSKIP ); - else - scaler_select_scaler( SCALER_NORMAL ); - } - - register_scalers(); - display_ui_initialised = 1; - - display_refresh_all(); - return 0; -} - -static void -resize_window( int w, int h ) -{ - if( xdisplay_current_size != w / DISPLAY_ASPECT_WIDTH ) { - XResizeWindow( display, xui_mainWindow, w, h ); - xdisplay_current_size = w / DISPLAY_ASPECT_WIDTH; - } -} - -static void -register_scalers( void ) -{ - int f = -1; - - scaler_register_clear(); - scaler_select_bitformat( 565 ); /* 16bit always */ - - if( xdisplay_depth == 4 ) { - scaler_register( SCALER_NORMAL ); - if( machine_current->timex ) { - scaler_register( SCALER_HALFSKIP ); - scaler_register( SCALER_TIMEX1_5X ); - scaler_register( SCALER_TIMEX2X ); - scaler_register( SCALER_ADVMAME2X ); - } else { - scaler_register( SCALER_DOUBLESIZE ); - scaler_register( SCALER_ADVMAME2X ); - - scaler_register( SCALER_TRIPLESIZE ); - scaler_register( SCALER_ADVMAME3X ); - } - } else { - scaler_register( SCALER_NORMAL ); - scaler_register( SCALER_PALTV ); - if( machine_current->timex ) { - scaler_register( SCALER_HALF ); - scaler_register( SCALER_HALFSKIP ); - scaler_register( SCALER_TIMEXTV ); - scaler_register( SCALER_TIMEX1_5X ); - scaler_register( SCALER_TIMEX2X ); - scaler_register( SCALER_2XSAI ); - scaler_register( SCALER_SUPER2XSAI ); - scaler_register( SCALER_SUPEREAGLE ); - scaler_register( SCALER_ADVMAME2X ); - scaler_register( SCALER_TV2X ); - scaler_register( SCALER_DOTMATRIX ); - scaler_register( SCALER_PALTV2X ); - scaler_register( SCALER_HQ2X ); - } else { - scaler_register( SCALER_DOUBLESIZE ); - scaler_register( SCALER_2XSAI ); - scaler_register( SCALER_SUPER2XSAI ); - scaler_register( SCALER_SUPEREAGLE ); - scaler_register( SCALER_ADVMAME2X ); - scaler_register( SCALER_TV2X ); - scaler_register( SCALER_DOTMATRIX ); - scaler_register( SCALER_PALTV2X ); - scaler_register( SCALER_HQ2X ); - - scaler_register( SCALER_TRIPLESIZE ); - scaler_register( SCALER_ADVMAME3X ); - scaler_register( SCALER_TV3X ); - scaler_register( SCALER_PALTV3X ); - scaler_register( SCALER_HQ3X ); - - scaler_register( SCALER_QUADSIZE ); - scaler_register( SCALER_TV4X ); - scaler_register( SCALER_PALTV4X ); - scaler_register( SCALER_HQ4X ); - } - } - if( current_scaler != SCALER_NUM ) - f = 4.0 * scaler_get_scaling_factor( current_scaler ) * - ( machine_current->timex ? 2 : 1 ); - if( scaler_is_supported( current_scaler ) && - ( xdisplay_current_size * 4 == f ) ) { - uidisplay_hotswap_gfx_mode(); - } else { - int new_scaler, new_timex_scaler; - switch( xdisplay_current_size ) { - case 1: - if( xdisplay_depth == 4 ) { - new_scaler = SCALER_NORMAL; - new_timex_scaler = SCALER_HALFSKIP; - } else { - switch( current_scaler ) { - case SCALER_PALTV: - case SCALER_PALTV2X: - case SCALER_PALTV3X: - case SCALER_PALTV4X: - new_scaler = SCALER_PALTV; - new_timex_scaler = SCALER_HALF; - break; - case SCALER_TV2X: - case SCALER_TV3X: - case SCALER_TV4X: - new_scaler = SCALER_PALTV; - new_timex_scaler = SCALER_HALF; - break; - default: - new_scaler = SCALER_NORMAL; - new_timex_scaler = SCALER_HALF; - break; - } - } - break; - case 2: - if( xdisplay_depth == 4 ) { - new_scaler = SCALER_DOUBLESIZE; - new_timex_scaler = SCALER_NORMAL; - } else { - switch( current_scaler ) { - case SCALER_PALTV: - case SCALER_PALTV2X: - case SCALER_PALTV3X: - case SCALER_PALTV4X: - new_scaler = SCALER_PALTV2X; - new_timex_scaler = SCALER_PALTV; - break; - case SCALER_TV2X: - case SCALER_TV3X: - case SCALER_TV4X: - new_scaler = SCALER_TV2X; - new_timex_scaler = SCALER_PALTV; - break; - case SCALER_2XSAI: - case SCALER_SUPER2XSAI: - case SCALER_SUPEREAGLE: - case SCALER_ADVMAME2X: - case SCALER_ADVMAME3X: - new_scaler = SCALER_ADVMAME2X; - new_timex_scaler = SCALER_NORMAL; - break; - case SCALER_HQ2X: - case SCALER_HQ3X: - case SCALER_HQ4X: - new_scaler = SCALER_HQ2X; - new_timex_scaler = SCALER_NORMAL; - break; - default: - new_scaler = SCALER_DOUBLESIZE; - new_timex_scaler = SCALER_NORMAL; - break; - } - } - break; - case 3: - if( xdisplay_depth == 4 ) { - new_scaler = SCALER_TRIPLESIZE; - new_timex_scaler = SCALER_TIMEX1_5X; - } else { - switch( current_scaler ) { - case SCALER_PALTV: - case SCALER_PALTV2X: - case SCALER_PALTV3X: - case SCALER_PALTV4X: - new_scaler = SCALER_PALTV3X; - new_timex_scaler = SCALER_TIMEX1_5X; - break; - case SCALER_TV2X: - case SCALER_TV3X: - case SCALER_TV4X: - new_scaler = SCALER_TV3X; - new_timex_scaler = SCALER_TIMEX1_5X; - break; - case SCALER_2XSAI: - case SCALER_SUPER2XSAI: - case SCALER_SUPEREAGLE: - case SCALER_ADVMAME2X: - case SCALER_ADVMAME3X: - new_scaler = SCALER_ADVMAME3X; - new_timex_scaler = SCALER_TIMEX1_5X; - break; - case SCALER_HQ2X: - case SCALER_HQ3X: - case SCALER_HQ4X: - new_scaler = SCALER_HQ3X; - new_timex_scaler = SCALER_TIMEX1_5X; - break; - default: - new_scaler = SCALER_TRIPLESIZE; - new_timex_scaler = SCALER_TIMEX1_5X; - break; - } - } - break; - case 4: - if( xdisplay_depth == 4 ) { - new_scaler = SCALER_QUADSIZE; - new_timex_scaler = SCALER_TIMEX2X; - } else { - switch( current_scaler ) { - case SCALER_PALTV: - case SCALER_PALTV2X: - case SCALER_PALTV3X: - case SCALER_PALTV4X: - new_scaler = SCALER_PALTV4X; - new_timex_scaler = SCALER_PALTV2X; - break; - case SCALER_TV2X: - case SCALER_TV3X: - case SCALER_TV4X: - new_scaler = SCALER_TV4X; - new_timex_scaler = SCALER_TV2X; - break; - case SCALER_2XSAI: - case SCALER_SUPER2XSAI: - case SCALER_SUPEREAGLE: - case SCALER_ADVMAME2X: - case SCALER_ADVMAME3X: - new_scaler = SCALER_QUADSIZE; - new_timex_scaler = SCALER_ADVMAME2X; - break; - case SCALER_HQ2X: - case SCALER_HQ3X: - case SCALER_HQ4X: - new_scaler = SCALER_HQ4X; - new_timex_scaler = SCALER_HQ2X; - break; - default: - new_scaler = SCALER_QUADSIZE; - new_timex_scaler = SCALER_TIMEX2X; - break; - } - } - break; - } - scaler_select_scaler( machine_current->timex ? new_timex_scaler : new_scaler ); - } -} - -int -xdisplay_configure_notify( int width, int height ) -{ - int size; - - /* If we're the same size as before, nothing special needed */ - size = width / DISPLAY_ASPECT_WIDTH; - if( size != height / DISPLAY_SCREEN_HEIGHT ) { /* out of aspect */ - if( size > height / DISPLAY_SCREEN_HEIGHT ) { - size = height / DISPLAY_SCREEN_HEIGHT; - width = size * DISPLAY_ASPECT_WIDTH; - } else { - height = size * DISPLAY_SCREEN_HEIGHT; - } - xdisplay_current_size = 0; /* force resize */ - resize_window( width, height ); - } else if( size == xdisplay_current_size ) { - return 0; - } - - /* Else set ourselves to the new height */ - xdisplay_current_size = size; - - /* Get a new scaler */ - register_scalers(); - - return 0; -} - -static void -xdisplay_update_rect_noscale( int x, int y, int w, int h ) -{ - int yy, xx; - - /* Call putpixel multiple times */ - for( yy = y; yy < y + h; yy++ ) - for( xx = x; xx < x + w; xx++ ) - xdisplay_putpixel( xx, yy, &rgb_image[yy + 2][xx + 1] ); - /* Blit to the real screen at the frame end end */ - xdisplay_area( x, y, w, h ); -} - -static void -xdisplay_update_rect_scale( int x, int y, int w, int h ) -{ - int yy = y, xx = x; - - y = y * image_scale >> 2; - x = x * image_scale >> 2; - scaler_proc16( - (libspectrum_byte *)&(rgb_image[yy + 2][xx + 1]), - rgb_pitch * sizeof(rgb_image[0][0]), - (libspectrum_byte *)&(scaled_image[y][x]), - scaled_pitch, - w, h - ); - - w = w * image_scale >> 2; - h = h * image_scale >> 2; - - /* Call putpixel multiple times */ - for( yy = y; yy < y + h; yy++ ) - for( xx = x; xx < x + w; xx++ ) - xdisplay_putpixel( xx, yy, &scaled_image[yy][xx] ); - /* Blit to the real screen */ - xdisplay_area( x, y, w, h ); -} - -void -uidisplay_frame_end( void ) -{ - X_Rect *r, *last_rect; - - /* Force a full redraw if requested */ - if ( xdisplay_force_full_refresh ) { - num_rects = 1; - - updated_rects[0].x = 0; - updated_rects[0].y = 0; - updated_rects[0].w = image_width; - updated_rects[0].h = image_height; - } - - if ( !( ui_widget_level >= 0 ) && num_rects == 0 && !status_updated ) return; - - last_rect = updated_rects + num_rects; - - for( r = updated_rects; r != last_rect; r++ ) - xdisplay_update_rect( r->x, r->y, r->w, r->h ); - if ( settings_current.statusbar ) - xstatusbar_overlay(); - num_rects = 0; - xdisplay_force_full_refresh = 0; -} - -void -uidisplay_frame_save( void ) -{ - memcpy( rgb_image_backup, rgb_image, sizeof( rgb_image ) ); -} - -void -uidisplay_frame_restore( void ) -{ - memcpy( rgb_image, rgb_image_backup, sizeof( rgb_image ) ); - xdisplay_update_rect( 0, 0, image_width, image_height ); -} - -void -uidisplay_area( int x, int y, int w, int h ) -{ - if ( xdisplay_force_full_refresh ) - return; - - if( num_rects == MAX_UPDATE_RECT ) { - xdisplay_force_full_refresh = 1; - return; - } - - /* Extend the dirty region by 1 pixel for scalers - that "smear" the screen, e.g. 2xSAI */ - if( scaler_flags & SCALER_FLAGS_EXPAND ) - scaler_expander( &x, &y, &w, &h, image_width, image_height ); - - updated_rects[num_rects].x = x; - updated_rects[num_rects].y = y; - updated_rects[num_rects].w = w; - updated_rects[num_rects].h = h; - num_rects++; -} - -void -xdisplay_area( int x, int y, int w, int h ) -{ -/* e.g. dwm first expose with too big w and h */ - if( x + w > 4 * DISPLAY_ASPECT_WIDTH ) - w = 4 * DISPLAY_ASPECT_WIDTH - x; - - if( y + h > 4 * DISPLAY_SCREEN_HEIGHT ) - h = 4 * DISPLAY_SCREEN_HEIGHT - y; - - if( shm_used ) { -#ifdef X_USE_SHM - XShmPutImage( display, xui_mainWindow, gc, image, x, y, x, y, w, h, True ); - /* FIXME: should wait for an ShmCompletion event here */ -#endif /* #ifdef X_USE_SHM */ - } else { - XPutImage( display, xui_mainWindow, gc, image, x, y, x, y, w, h ); - } -} - -static void -xdisplay_destroy_image(void) -{ - /* Free the XImage used to store screen data; also frees the malloc'd - data */ -#ifdef X_USE_SHM - if( shm_used ) { - XShmDetach( display, &shm_info ); - shmdt( shm_info.shmaddr ); - image->data = NULL; - shm_used = 0; - } -#endif - if( image ) XDestroyImage( image ); image = NULL; -} - -static void -xdisplay_setup_rgb_putpixel( void ) -{ - switch( xdisplay_depth ) { - case 4: - xdisplay_putpixel = xdisplay_putpixel_4; - break; - case 8: - xdisplay_putpixel = xdisplay_putpixel_8; - break; - case 15: - xdisplay_putpixel = xdisplay_putpixel_15; - break; - case 16: - xdisplay_putpixel = xdisplay_putpixel_16; - break; - case 24: - case 32: - xdisplay_putpixel = xdisplay_putpixel_24; - break; - } - resize_window( scaled_image_w, scaled_image_h ); -} - -int -uidisplay_hotswap_gfx_mode( void ) -{ - image_scale = 4.0 * scaler_get_scaling_factor( current_scaler ); - scaled_image_w = image_width * image_scale >> 2; - scaled_image_h = image_height * image_scale >> 2; - if( current_scaler == SCALER_NORMAL ) - xdisplay_update_rect = xdisplay_update_rect_noscale; - else - xdisplay_update_rect = xdisplay_update_rect_scale; - - xdisplay_force_full_refresh = 1; - - if( settings_current.bw_tv != xdisplay_bw ) { - xdisplay_bw = settings_current.bw_tv; - if( xdisplay_depth == 4 ) - xdisplay_allocate_colours4(); - else if( xdisplay_depth == 8 ) - xdisplay_allocate_colours8(); - } - xdisplay_setup_rgb_putpixel(); - xstatusbar_init( xdisplay_current_size ); - display_refresh_all(); - return 0; -} - -int -uidisplay_end( void ) -{ - display_ui_initialised = 0; - return 0; -} - -static void -xdisplay_catch_signal( int sig ) -{ - xdisplay_end(); - psignal( sig, fuse_progname ); - exit( 1 ); -} - -int -xdisplay_end( void ) -{ - xdisplay_destroy_image(); - /* Free the allocated GC */ - if( gc ) { - XFreeGC( display, gc ); - gc = 0; - } - - return 0; -} - -/* Set one pixel in the display */ -void -uidisplay_putpixel( int x, int y, int colour ) -{ - libspectrum_word pc = settings_current.bw_tv ? pal_grey[ colour ] : - pal_colour[ colour ]; - - if( machine_current->timex ) { - x <<= 1; y <<= 1; - rgb_image[y + 2][x + 1] = pc; - rgb_image[y + 2][x + 2] = pc; - rgb_image[y + 3][x + 1] = pc; - rgb_image[y + 3][x + 2] = pc; - } else { - rgb_image[y + 2][x + 1] = pc; - } -} - -/* Print the 8 pixels in `data' using ink colour `ink' and paper - colour `paper' to the screen at ( (8*x) , y ) */ -void -uidisplay_plot8( int x, int y, libspectrum_byte data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - libspectrum_word *dest; - libspectrum_word pi = settings_current.bw_tv ? pal_grey[ ink ] : - pal_colour[ ink ]; - libspectrum_word pp = settings_current.bw_tv ? pal_grey[ paper ] : - pal_colour[ paper ]; - - if( machine_current->timex ) { - - x <<= 4; y <<= 1; - - dest = &(rgb_image[y + 2][x + 1]); - - *(dest + rgb_pitch) = *dest = ( data & 0x80 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x80 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x40 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x40 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x20 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x20 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x10 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x10 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x08 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x08 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x04 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x04 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x02 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x02 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x01 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x01 ) ? pi : pp; - } else { - x <<= 3; - - dest = &(rgb_image[y + 2][x + 1]); - - *(dest++) = ( data & 0x80 ) ? pi : pp; - *(dest++) = ( data & 0x40 ) ? pi : pp; - *(dest++) = ( data & 0x20 ) ? pi : pp; - *(dest++) = ( data & 0x10 ) ? pi : pp; - *(dest++) = ( data & 0x08 ) ? pi : pp; - *(dest++) = ( data & 0x04 ) ? pi : pp; - *(dest++) = ( data & 0x02 ) ? pi : pp; - *dest = ( data & 0x01 ) ? pi : pp; - } -} - -/* Print the 16 pixels in `data' using ink colour `ink' and paper - colour `paper' to the screen at ( (16*x) , y ) */ -void -uidisplay_plot16( int x, int y, libspectrum_word data, - libspectrum_byte ink, libspectrum_byte paper ) -{ - libspectrum_word *dest; - libspectrum_word pi = settings_current.bw_tv ? pal_grey[ ink ] : - pal_colour[ ink ]; - libspectrum_word pp = settings_current.bw_tv ? pal_grey[ paper ] : - pal_colour[ paper ]; - x <<= 4; y <<= 1; - - dest = &(rgb_image[y + 2][x + 1]); - *(dest + rgb_pitch) = *dest = ( data & 0x8000 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x4000 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x2000 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x1000 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0800 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0400 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0200 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0100 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0080 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0040 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0020 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0010 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0008 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0004 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0002 ) ? pi : pp; dest++; - *(dest + rgb_pitch) = *dest = ( data & 0x0001 ) ? pi : pp; -} - -int -ui_statusbar_update( ui_statusbar_item item, ui_statusbar_state state ) -{ - switch( item ) { - - case UI_STATUSBAR_ITEM_DISK: - pixmap_disk_state = state; - status_updated = 1; - return 0; - - case UI_STATUSBAR_ITEM_PAUSED: - /* We don't support pausing this version of Fuse */ - return 0; - - case UI_STATUSBAR_ITEM_TAPE: - pixmap_tape_state = state; - status_updated = 1; - return 0; - - case UI_STATUSBAR_ITEM_MICRODRIVE: - pixmap_mdr_state = state; - status_updated = 1; - return 0; - - case UI_STATUSBAR_ITEM_MOUSE: - /* We don't support showing a grab icon */ - return 0; - - } - - ui_error( UI_ERROR_ERROR, "Attempt to update unknown statusbar item %d", - item ); - return 1; -} - -int -ui_statusbar_update_speed( float speed ) -{ - char *list[2]; - char buffer[16]; - XTextProperty text; - - list[0] = buffer; - list[1] = 0; - snprintf( buffer, 16, "Fuse - %4.0f%%", speed ); - - XStringListToTextProperty( list, 1, &text); - XSetWMName( display, xui_mainWindow, &text ); - XFree( text.value ); - - return 0; -} diff --git a/fuse/ui/xlib/xdisplay.h b/fuse/ui/xlib/xdisplay.h deleted file mode 100644 index 73822cb..0000000 --- a/fuse/ui/xlib/xdisplay.h +++ /dev/null @@ -1,42 +0,0 @@ -/* xdisplay.h: Routines for dealing with the X display - Copyright (c) 2000 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#ifndef FUSE_XDISPLAY_H -#define FUSE_XDISPLAY_H - -int xdisplay_init( void ); -int xdisplay_end( void ); - -int xdisplay_configure_notify(int width, int height); -void xdisplay_area(int x, int y, int width, int height); - -/* Are we expecting an X error to occur? */ -extern int xerror_expecting; - -/* Which error occurred? */ -extern int xerror_error; - -/* The X error handler */ -int xerror_handler( Display *display, XErrorEvent *error ); - -#endif /* #ifndef FUSE_XDISPLAY_H */ diff --git a/fuse/ui/xlib/xerror.c b/fuse/ui/xlib/xerror.c deleted file mode 100644 index a1bda21..0000000 --- a/fuse/ui/xlib/xerror.c +++ /dev/null @@ -1,64 +0,0 @@ -/* xerror.c: handle X errors - Copyright (c) 2002-2004 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include - -#include - -#include "fuse.h" - -/* Are we expecting an X error to occur? */ -int xerror_expecting; - -/* Which error occurred? */ -int xerror_error; - -#define MESSAGE_MAX_LENGTH 256 - -int -xerror_handler( Display *display, XErrorEvent *error ); - -int -xerror_handler( Display *display, XErrorEvent *error ) -{ - /* If we were expecting an error to occur, just set a flag. Otherwise, - exit in a fairly spectacular fashion */ - if( xerror_expecting ) { - xerror_error = error->error_code; - } else { - - char message[64]; - - XGetErrorText( display, error->error_code, message, 63 ); - - fprintf( stderr, "X Error: %s\n", message ); - - exit( 1 ); - - } - - return 0; -} diff --git a/fuse/ui/xlib/xjoystick.c b/fuse/ui/xlib/xjoystick.c deleted file mode 100644 index 69128dc..0000000 --- a/fuse/ui/xlib/xjoystick.c +++ /dev/null @@ -1,37 +0,0 @@ -/* xjoystick.c: Joystick emulation - Copyright (c) 2003 Darren Salt - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - - Darren: linux@youmustbejoking.demon.co.uk - -*/ - -#include -#include "peripherals/joystick.h" - -#if !defined USE_JOYSTICK || defined HAVE_JSW_H -/* Fake joystick, or override UI-specific handling */ -#include "../uijoystick.c" - -#else /* #if !defined USE_JOYSTICK || defined HAVE_JSW_H */ - -#include "../sdl/sdljoystick.c" - -#endif diff --git a/fuse/ui/xlib/xkeyboard.c b/fuse/ui/xlib/xkeyboard.c deleted file mode 100644 index 526a1c5..0000000 --- a/fuse/ui/xlib/xkeyboard.c +++ /dev/null @@ -1,74 +0,0 @@ -/* xkeyboard.c: X routines for dealing with the keyboard - Copyright (c) 2000-2003 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include - -#include -#include -#include - -#include "display.h" -#include "fuse.h" -#include "keyboard.h" -#include "machine.h" -#include "settings.h" -#include "snapshot.h" -#include "spectrum.h" -#include "tape.h" -#include "ui/ui.h" -#include "xkeyboard.h" - -static void -get_keysyms( XKeyEvent *event, input_event_t *fuse_event ) -{ - KeySym native, spectrum; - - /* Get keysyms taking into account Shift, Caps_Lock, Mode_switch modifiers */ - XLookupString( event, NULL, 0, &native, NULL ); - fuse_event->types.key.native_key = keysyms_remap( native ); - - spectrum = XLookupKeysym( event, 0 ); - fuse_event->types.key.spectrum_key = keysyms_remap( spectrum ); -} - -void xkeyboard_keypress(XKeyEvent *event) -{ - input_event_t fuse_event; - - fuse_event.type = INPUT_EVENT_KEYPRESS; - get_keysyms( event, &fuse_event ); - - input_event( &fuse_event ); -} - -void xkeyboard_keyrelease(XKeyEvent *event) -{ - input_event_t fuse_event; - - fuse_event.type = INPUT_EVENT_KEYRELEASE; - get_keysyms( event, &fuse_event ); - - input_event( &fuse_event ); -} diff --git a/fuse/ui/xlib/xkeyboard.h b/fuse/ui/xlib/xkeyboard.h deleted file mode 100644 index 4bef257..0000000 --- a/fuse/ui/xlib/xkeyboard.h +++ /dev/null @@ -1,30 +0,0 @@ -/* xkeyboard.h: X routines for dealing with the keyboard - Copyright (c) 2000 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#ifndef FUSE_XKEYBOARD_H -#define FUSE_XKEYBOARD_H - -void xkeyboard_keypress(XKeyEvent *event); -void xkeyboard_keyrelease(XKeyEvent *event); - -#endif /* #ifndef FUSE_XKEYBOARD_H */ diff --git a/fuse/ui/xlib/xstatusbar.pl b/fuse/ui/xlib/xstatusbar.pl deleted file mode 100644 index d21fef0..0000000 --- a/fuse/ui/xlib/xstatusbar.pl +++ /dev/null @@ -1,276 +0,0 @@ -#!/usr/bin/perl - -die "usage: $0 " unless @ARGV >= 1; - -my $maxh = 0; -my $o = 0; -my $stat = 0; -my $add_pixmap = ''; - -my (%pxm, %map_map); -my @pxm; -my $check_mask = ''; - -my $do_icon = 0; - -print "/*\n This file generated from ../gtk/pixmaps.c with xstatusbar.pl\n" . - "*/\n\n"; - -my $pixmaps = shift; - -#xpm_read('abc_pixmap.dat', 'abc'); - -$do_icon = 1; -xpm_read($pixmaps, 'icon'); -foreach( sort keys %pxm ) { - print $pxm{$_} . "\n"; - push @pxm, $_ if($_ !~ /_mask$/); -} - -#my $n = 0; -#foreach( @pxm ) { -# print "#define " . uc($_) . " $n\n"; -# $n++; -#} - -#print "\nstatic void *pixmaps[]= {\n"; -#foreach( @pxm ) { -# print " \&$_, " . (defined($map_map{$_ . '_mask'}) ? "\&" . $map_map{$_ . '_mask'} : "NULL") . ",\n"; -#} -#print "};\n"; - - -my $xstates = join(', ', keys %xstates); -my $idx = 1000; -my $w; -foreach(sort keys %xoverlay) { - $idx--; - $w = 900 if /^tape/; - $w = 800 if /^mdr/; - $w = 700 if /^disk/; - $w = 600 if /^pause/; - $w = 500 if /^mouse/; - $overlay{sprintf('%04d', $idx - $w)} = $_; -# print sprintf('%04d', $idx - $w) . " $_\n"; -} -foreach(sort keys %overlay) { - my $n = $overlay{$_}; - my $N = uc $n; -$overlay .= < 0; h-- ) { - int w = pw; - for( ; w > 0; w-- ) { - int i; - for( i = icon_size; i > 0; i-- ) { - xdisplay_putpixel( x, y, colors); - if( icon_size > 1 ) - xdisplay_putpixel( x, y + 1, colors); - if( icon_size > 2 ) - xdisplay_putpixel( x, y + 2, colors); - if( icon_size > 3 ) - xdisplay_putpixel( x, y + 3, colors); - x++; - } - colors++; - } - x -= pw * icon_size; y += icon_size; - } -} -/* put status icons to X(Shm)Image extra area */ -void -xstatusbar_init( int size ) -{ - if( icon_size == size ) - return; - icon_size = size; - -$add_pixmap} - -static void -xstatusbar_put_icon( int x, int w, int h ) -{ - static int dx = 0; - static int dy = 0; - w *= icon_size; x *= icon_size; h *= icon_size; - if( x < 0 || dx == 0 ) { - dx = ( DISPLAY_ASPECT_WIDTH - 2 ) * xdisplay_current_size; - dy = ( DISPLAY_SCREEN_HEIGHT - 2 ) * xdisplay_current_size - PIXMAPS_H * icon_size; - return; - } - dx -= w; - if( shm_used ) { -#ifdef X_USE_SHM - /* FIXME: should wait for an ShmCompletion event here */ - XShmPutImage( display, xui_mainWindow, gc, image, x, - 4 * DISPLAY_SCREEN_HEIGHT, dx, dy, w, h, True ); -#endif /* #ifdef X_USE_SHM */ - } else { - XPutImage( display, xui_mainWindow, gc, image, x, - 4 * DISPLAY_SCREEN_HEIGHT, dx, dy, w, h ); - } - dx -= 4; /* 4px space */ -} - -void -xstatusbar_overlay( void ) -{ - int x = 0, w = 0, h; - xstatusbar_put_icon( -1, 0, 0 ); - -$overlay - status_updated = 0; -} - -EOS - -#static char* [] = { -# -# -# -# -sub xpm_read() { - my $st = ''; - my( $var_name, $width, $height, $colors, $depth, $char, $dim, $w, $h ); - my %colors; - my $col; - my $def; - my $do = $_[1]; - my $mask; - local $offset = 0; - open FILE, '<', $_[0]; - while() { - s!/\*.*\*/!!g; - if( $st eq '' ) { - #static char * [] = { - if( /\s*(static\s+)?char\s*\*\s*([^[]+)\[/ ) { - $var_name = $2; - next if($var_name =~ /tape_marker/); - next if($var_name =~ /pause/); - next if($var_name =~ /mouse/); - $var_name =~ s/gtkpixmap/pixmap/; - %colors = (); - $def = ''; - $col = 'AA'; - $mask = $do eq 'icon' ? 'add mask' : ( $var_name =~ /_mask$/ ? 'mask' : 'no mask'); - $st = '' - } - } elsif( $st eq '' ) { - # [ ] [ XPMEXT ] - if( /\s*\x22\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/ ) { - ($width, $height, $colors, $depth) = ($1, $2, $3, $4); - ($w, $h) = ($width + 1, $height); -# $dim = "$width, $height, \n"; - $maxh = $height if( $do_icon && $mask ne 'mask' && $height > $maxh ); - $st = '' - } - } elsif( $st eq '' ) { - # { } { } - if( /\s*\x22\s*([ -~])\s+c\s+(\x23[0-9a-fA-F]{6}|None)/ ) { - if( substr( $2, 0, 1 ) eq '#' ) { - $_ = '0x' . sprintf('%04x', - ((hex( substr( $2, 1, 2 ) ) >> 3) << 11) + - ((hex( substr( $2, 3, 2 ) ) >> 2) << 5) + - ((hex( substr( $2, 5, 2 ) ) >> 3)) - ); -# $colors{$1} .= sprintf('%04x', $_ ); - $def .= "#define $col $_,\n"; - $colors{$1} = $col; - $mask{$1} = '1,'; - $col++; - } else { - $colors{$1} = '__'; - $mask{$1} = '0,'; - $def = "#define __ 0x0,\n" . $def; - } - $colors--; - $st = '' if( !$colors ) ; - } - } elsif( $st eq '' ) { - # [ ] [ XPMEXT ] - if( /\s*\x22(.{$w})/ ) { - $pxm{$var_name} .= ' ' . join( ' ', map { $colors{chr($_)} } unpack("C[$w]") ) . "\n" if( $mask ne 'mask'); -# $pxm{$var_name . '_mask'} .= ' ' . join( ' ', map { $mask{chr($_)} } unpack("C[$w]") ) . "\n" if( $mask eq 'add mask'); -# $pxm{$var_name} .= ' ' . join( ' ', map { $mask{chr($_)} } unpack("C[$w]") ) . "\n" if( $mask eq 'mask'); - $h--; - if( !$h ) { - $st = ''; - if( $mask ne 'no mask') { - my $mask_name = $mask eq 'mask' ? $var_name : $var_name . '_mask'; - $_ = $pxm{$mask_name}; - if( ! /0/ ) { - if( $mask eq 'add mask') { - delete( $pxm{$var_name . '_mask'}); - } - if( $mask eq 'mask') { - delete( $pxm{$var_name} ); - next; - } - } elsif ($check_mask =~ /\n([^=]+?)=$_=/) { - $map_map{$mask_name} = $1; - if( $mask eq 'add mask') { - delete( $pxm{$var_name . '_mask'}); - } - if( $mask eq 'mask') { - delete( $pxm{$var_name} ); - next; - } - } else { - $map_map{$mask_name} = $mask_name; - $check_mask .= "\n" . $mask_name . "=$_="; - } - } - my $defdim = "#define " . uc($var_name) . "_OFF $offset\n" . - "#define " . uc($var_name) . "_W $width\n" . - "#define " . uc($var_name) . "_H $height"; - if( $do eq 'icon' ) { - $add_pixmap .= " xstatusbar_add_pixmap( " . uc($var_name) . "_OFF, " . uc($var_name) . "_W, " . uc($var_name) . "_H, ${var_name});\n"; - my $name = $var_name; - $name =~ s/_(in)?active$//i; - $xstates{"${name}_state"} = 1; - $xoverlay{$name} = 1; - } - - $offset += $width if( $do eq 'icon' ); - - $pxm{$var_name} = "$def\n$defdim\nstatic libspectrum_word ${var_name}[] = {\n$dim" . $pxm{$var_name} if( $mask ne 'mask'); - $def =~ s/\x23define (..).*/#undef $1/g; - $pxm{$var_name} .= "};\n\n$def" if( $mask ne 'mask'); - - $pxm{$var_name . '_mask'} = "static libspectrum_byte ${var_name}_mask[] = {\n" . $pxm{$var_name . '_mask'} if( $mask eq 'add mask' and defined( $pxm{$var_name . '_mask'} ) ); - $pxm{$var_name} = "static libspectrum_byte ${var_name}[] = {\n" . $pxm{$var_name} if( $mask eq 'mask'); - - $pxm{$var_name . '_mask'} .= "};\n" if( $mask ne 'no mask' and defined( $pxm{$var_name . '_mask'} )); - $maxh = $h if( $do_icon && $mask ne 'mask' && $h > $maxh ); - } - } - } - } - close FILE; -}; diff --git a/fuse/ui/xlib/xui.c b/fuse/ui/xlib/xui.c deleted file mode 100644 index bdee8e5..0000000 --- a/fuse/ui/xlib/xui.c +++ /dev/null @@ -1,301 +0,0 @@ -/* xui.c: Routines for dealing with the Xlib user interface - Copyright (c) 2000-2015 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include - -#include -#include - -#include "display.h" -#include "fuse.h" -#include "keyboard.h" -#include "menu.h" -#include "settings.h" -#include "ui/ui.h" -#include "ui/uidisplay.h" -#include "xdisplay.h" -#include "xkeyboard.h" -#include "xui.h" - -Display *display; /* Which display are we connected to */ -int xui_screenNum; /* Which screen are we using on our - X server? */ -Window xui_mainWindow; /* Window ID for the main Fuse window */ - -Cursor nullpointer; - -static Atom delete_window_atom; - -int -ui_init( int *argc, char ***argv ) -{ - char *displayName=NULL; /* Use default display */ - XWMHints *wmHints; - XSizeHints *sizeHints; - XClassHint *classHint; - char *windowNameList=(char *)"Fuse",*iconNameList=(char *)"Fuse"; - XTextProperty windowName, iconName; - unsigned long windowFlags; - XSetWindowAttributes windowAttributes; - - /* Allocate memory for various things */ - - if( ui_widget_init() ) return 1; - - if(!(wmHints = XAllocWMHints())) { - fprintf(stderr,"%s: failure allocating memory\n", fuse_progname); - return 1; - } - - if(!(sizeHints = XAllocSizeHints())) { - fprintf(stderr,"%s: failure allocating memory\n", fuse_progname); - return 1; - } - - if(!(classHint = XAllocClassHint())) { - fprintf(stderr,"%s: failure allocating memory\n", fuse_progname); - return 1; - } - - if(XStringListToTextProperty(&windowNameList,1,&windowName) == 0 ) { - fprintf(stderr,"%s: structure allocation for windowName failed\n", - fuse_progname); - return 1; - } - - if(XStringListToTextProperty(&iconNameList,1,&iconName) == 0 ) { - fprintf(stderr,"%s: structure allocation for iconName failed\n", - fuse_progname); - return 1; - } - - /* Open a connection to the X server */ - - if ( ( display=XOpenDisplay(displayName)) == NULL ) { - fprintf(stderr,"%s: cannot connect to X server %s\n", fuse_progname, - XDisplayName(displayName)); - return 1; - } - - /* Set up our error handler */ - xerror_expecting = xerror_error = 0; - XSetErrorHandler( xerror_handler ); - - xui_screenNum = DefaultScreen(display); - - /* Create the main window */ - - xui_mainWindow = XCreateSimpleWindow( - display, RootWindow( display, xui_screenNum ), 0, 0, - DISPLAY_ASPECT_WIDTH, DISPLAY_SCREEN_HEIGHT, 0, - BlackPixel( display, xui_screenNum ), WhitePixel( display, xui_screenNum ) - ); - - /* Set standard window properties */ - - sizeHints->flags = PBaseSize | PResizeInc | PMaxSize | PMinSize; - - sizeHints->base_width = 0; - sizeHints->base_height = 0; - - sizeHints->min_width = DISPLAY_ASPECT_WIDTH; - sizeHints->min_height = DISPLAY_SCREEN_HEIGHT; - sizeHints->width_inc = DISPLAY_ASPECT_WIDTH; - sizeHints->height_inc = DISPLAY_SCREEN_HEIGHT; - sizeHints->max_width = 4 * DISPLAY_ASPECT_WIDTH; - sizeHints->max_height = 4 * DISPLAY_SCREEN_HEIGHT; - - if( settings_current.aspect_hint ) { - sizeHints->flags |= PAspect; - sizeHints->min_aspect.x = 4; - sizeHints->min_aspect.y = 3; - sizeHints->max_aspect.x = 4; - sizeHints->max_aspect.y = 3; - } - - wmHints->flags=StateHint | InputHint; - wmHints->initial_state=NormalState; - wmHints->input=True; - - classHint->res_name=(char *)fuse_progname; - classHint->res_class=(char *)"Fuse"; - - XSetWMProperties(display, xui_mainWindow, &windowName, &iconName, - *argv, *argc, sizeHints, wmHints, classHint); - - XFree( windowName.value ); - XFree( iconName.value ); - XFree( sizeHints ); - XFree( wmHints ); - XFree( classHint ); - - /* Ask the server to use its backing store for this window */ - - windowFlags=CWBackingStore; - windowAttributes.backing_store=WhenMapped; - - XChangeWindowAttributes(display, xui_mainWindow, windowFlags, - &windowAttributes); - - /* Select which types of event we want to receive */ - - XSelectInput(display, xui_mainWindow, ExposureMask | KeyPressMask | - KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | - StructureNotifyMask | FocusChangeMask | PointerMotionMask ); - - { - static XColor dummy = { 0, 0, 0, 0, 4, 0 }; - XGCValues xgc; - GC gc; - - Pixmap mask = - XCreatePixmap( display, RootWindow( display, xui_screenNum ), 1, 1, 1 ); - - xgc.function = GXclear; - gc = XCreateGC( display, mask, GCFunction, &xgc ); - XFillRectangle( display, mask, gc, 0, 0, 1, 1 ); - nullpointer = XCreatePixmapCursor( display, mask,mask, &dummy,&dummy, 0,0 ); - XFreePixmap( display, mask ); - XFreeGC( display, gc ); - } - - /* Ask to be notified of window close requests */ - - delete_window_atom = XInternAtom( display, "WM_DELETE_WINDOW", 0 ); - XSetWMProtocols( display, xui_mainWindow, &delete_window_atom, 1 ); - - if( xdisplay_init() ) return 1; - - /* And finally display the window */ - XMapWindow(display,xui_mainWindow); - - ui_mouse_present = 1; - - return 0; -} - -int ui_event(void) -{ - XEvent event; - - XFlush( display ); - while( XEventsQueued( display, QueuedAlready ) ) { - XNextEvent( display, &event ); - - switch(event.type) { - case ConfigureNotify: - xdisplay_configure_notify(event.xconfigure.width, - event.xconfigure.height); - break; - case Expose: - xdisplay_area( event.xexpose.x, event.xexpose.y, - event.xexpose.width, event.xexpose.height ); - break; - case ButtonPress: - ui_mouse_button( event.xbutton.button, 1 ); - break; - case ButtonRelease: - ui_mouse_button( event.xbutton.button, 0 ); - break; - case MotionNotify: - if( ui_mouse_grabbed ) { - ui_mouse_motion( event.xmotion.x - 128, event.xmotion.y - 128 ); - if( event.xmotion.x != 128 || event.xmotion.y != 128 ) - XWarpPointer( display, None, xui_mainWindow, 0, 0, 0, 0, 128, 128 ); - } - break; - case FocusOut: - keyboard_release_all(); - ui_mouse_suspend(); - break; - case FocusIn: - ui_mouse_resume(); - break; - case KeyPress: - xkeyboard_keypress(&(event.xkey)); - break; - case KeyRelease: - xkeyboard_keyrelease(&(event.xkey)); - break; - case ClientMessage: - if( event.xclient.format == 32 && - event.xclient.data.l[0] == delete_window_atom ) { - fuse_emulation_pause(); - menu_file_exit(0); - fuse_emulation_unpause(); - } - break; - } - } - return 0; -} - -int ui_end(void) -{ - int error; - - /* Don't display the window whilst doing all this */ - XUnmapWindow(display,xui_mainWindow); - - /* Tidy up the low level stuff */ - error = xdisplay_end(); if( error ) return error; - - /* Now free up the window itself */ - XDestroyWindow(display,xui_mainWindow); - - /* And disconnect from the X server */ - XCloseDisplay(display); - - ui_widget_end(); - - return 0; -} - -int -ui_mouse_grab( int startup ) -{ - if( startup ) return 0; - - switch( XGrabPointer( display, xui_mainWindow, True, - ButtonPressMask | ButtonReleaseMask | PointerMotionMask, - GrabModeAsync, GrabModeAsync, xui_mainWindow, - nullpointer, CurrentTime ) - ) { - case GrabSuccess: - case GrabNotViewable: - XWarpPointer( display, None, xui_mainWindow, 0, 0, 0, 0, 128, 128 ); - return 1; - default: - ui_error( UI_ERROR_WARNING, "Mouse grab failed" ); - return 0; - } -} - -int -ui_mouse_release( int suspend GCC_UNUSED ) -{ - XUngrabPointer( display, CurrentTime ); - return 0; -} diff --git a/fuse/ui/xlib/xui.h b/fuse/ui/xlib/xui.h deleted file mode 100644 index 5ae1e0d..0000000 --- a/fuse/ui/xlib/xui.h +++ /dev/null @@ -1,36 +0,0 @@ -/* xui.h: Routines for dealing with the Xlib user interface - Copyright (c) 2000 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#ifndef FUSE_XUI_H -#define FUSE_XUI_H - -#ifndef _XLIB_H_ -#include -#endif - -extern Display *display; /* Which display are we connected to? */ -extern int xui_screenNum; /* Which screen are we using on our - X server? */ -extern Window xui_mainWindow; /* Window ID for the main Fuse window */ - -#endif /* #ifndef FUSE_XUI_H */ diff --git a/fuse/utils.c b/fuse/utils.c index 3778c4e..59c0091 100644 --- a/fuse/utils.c +++ b/fuse/utils.c @@ -52,7 +52,6 @@ #include "peripherals/if2.h" #include "pokefinder/pokemem.h" #include "rzx.h" -#include "screenshot.h" #include "settings.h" #include "snapshot.h" #include "tape.h" @@ -426,30 +425,6 @@ utils_read_auxiliary_file( const char *filename, utils_file *file, return 0; } -int -utils_read_screen( const char *filename, utils_file *screen ) -{ - int error; - - error = utils_read_auxiliary_file( filename, screen, UTILS_AUXILIARY_LIB ); - if( error == -1 ) { - ui_error( UI_ERROR_ERROR, "couldn't find screen picture ('%s')", - filename ); - return 1; - } - - if( error ) return error; - - if( screen->length != STANDARD_SCR_SIZE ) { - utils_close_file( screen ); - ui_error( UI_ERROR_ERROR, "screen picture ('%s') is not %d bytes long", - filename, STANDARD_SCR_SIZE ); - return 1; - } - - return 0; -} - char* utils_safe_strdup( const char *src ) { diff --git a/fuse/utils.h b/fuse/utils.h index aa482c4..a39e250 100644 --- a/fuse/utils.h +++ b/fuse/utils.h @@ -51,7 +51,6 @@ int utils_write_file( const char *filename, const unsigned char *buffer, int utils_find_file_path( const char *filename, char *path, utils_aux_type type ); -int utils_read_screen( const char *filename, utils_file *screen ); char* utils_safe_strdup( const char *src ); diff --git a/fuse/z80/coretest.c b/fuse/z80/coretest.c deleted file mode 100644 index 7e50eea..0000000 --- a/fuse/z80/coretest.c +++ /dev/null @@ -1,677 +0,0 @@ -/* coretest.c: Test program for Fuse's Z80 core - Copyright (c) 2003-2017 Philip Kendall - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include - -#include -#include -#include -#include - -#include "fuse.h" -#include "peripherals/disk/beta.h" -#include "peripherals/disk/didaktik.h" -#include "peripherals/disk/disciple.h" -#include "peripherals/disk/opus.h" -#include "peripherals/disk/plusd.h" -#include "peripherals/ide/divide.h" -#include "peripherals/ide/divmmc.h" -#include "peripherals/if1.h" -#include "peripherals/spectranet.h" -#include "peripherals/ula.h" -#include "peripherals/usource.h" -#include "profile.h" -#include "rzx.h" -#include "slt.h" -#include "tape.h" - -#include "event.h" -#include "infrastructure/startup_manager.h" -#include "module.h" -#include "spectrum.h" -#include "ui/ui.h" -#include "z80.h" -#include "z80_macros.h" - -static const char *progname; /* argv[0] */ -static const char *testsfile; /* argv[1] */ - -static int init_dummies( void ); - -libspectrum_dword tstates; -libspectrum_dword event_next_event; - -/* 64Kb of RAM */ -static libspectrum_byte initial_memory[ 0x10000 ], memory[ 0x10000 ]; - -libspectrum_byte readbyte( libspectrum_word address ); -libspectrum_byte readbyte_internal( libspectrum_word address ); - -void writebyte( libspectrum_word address, libspectrum_byte b ); -void writebyte_internal( libspectrum_word address, libspectrum_byte b ); - -static int run_test( FILE *f ); -static int read_test( FILE *f, libspectrum_dword *end_tstates ); - -static void dump_z80_state( void ); -static void dump_memory_state( void ); - -int -main( int argc, char **argv ) -{ - FILE *f; - - progname = argv[0]; - - if( argc < 2 ) { - fprintf( stderr, "Usage: %s \n", progname ); - return 1; - } - - testsfile = argv[1]; - - if( init_dummies() ) return 1; - - /* Initialise the tables used by the Z80 core */ - z80_init( NULL ); - - f = fopen( testsfile, "r" ); - if( !f ) { - fprintf( stderr, "%s: couldn't open tests file `%s': %s\n", progname, - testsfile, strerror( errno ) ); - return 1; - } - - while( run_test( f ) ) { - /* Do nothing */ - } - - if( fclose( f ) ) { - fprintf( stderr, "%s: couldn't close `%s': %s\n", progname, testsfile, - strerror( errno ) ); - return 1; - } - - return 0; -} - -libspectrum_byte -readbyte( libspectrum_word address ) -{ - printf( "%5d MC %04x\n", tstates, address ); - tstates += 3; - return readbyte_internal( address ); -} - -libspectrum_byte -readbyte_internal( libspectrum_word address ) -{ - printf( "%5d MR %04x %02x\n", tstates, address, memory[ address ] ); - return memory[ address ]; -} - -void -writebyte( libspectrum_word address, libspectrum_byte b ) -{ - printf( "%5d MC %04x\n", tstates, address ); - tstates += 3; - writebyte_internal( address, b ); -} - -void -writebyte_internal( libspectrum_word address, libspectrum_byte b ) -{ - printf( "%5d MW %04x %02x\n", tstates, address, b ); - memory[ address ] = b; -} - -void -contend_read( libspectrum_word address, libspectrum_dword time ) -{ - printf( "%5d MC %04x\n", tstates, address ); - tstates += time; -} - -void -contend_read_no_mreq( libspectrum_word address, libspectrum_dword time ) -{ - contend_read( address, time ); -} - -void -contend_write_no_mreq( libspectrum_word address, libspectrum_dword time ) -{ - printf( "%5d MC %04x\n", tstates, address ); - tstates += time; -} - -static void -contend_port_preio( libspectrum_word port ) -{ - if( ( port & 0xc000 ) == 0x4000 ) { - printf( "%5d PC %04x\n", tstates, port ); - } - - tstates++; -} - -static void -contend_port_postio( libspectrum_word port ) -{ - if( port & 0x0001 ) { - - if( ( port & 0xc000 ) == 0x4000 ) { - printf( "%5d PC %04x\n", tstates, port ); tstates++; - printf( "%5d PC %04x\n", tstates, port ); tstates++; - printf( "%5d PC %04x\n", tstates, port ); tstates++; - } else { - tstates += 3; - } - - } else { - - printf( "%5d PC %04x\n", tstates, port ); tstates += 3; - - } -} - -libspectrum_byte -readport( libspectrum_word port ) -{ - libspectrum_byte r = port >> 8; - - contend_port_preio( port ); - - printf( "%5d PR %04x %02x\n", tstates, port, r ); - - contend_port_postio( port ); - - return r; -} - -void -writeport( libspectrum_word port, libspectrum_byte b ) -{ - contend_port_preio( port ); - - printf( "%5d PW %04x %02x\n", tstates, port, b ); - - contend_port_postio( port ); -} - -static int -run_test( FILE *f ) -{ - size_t i; - - /* Get ourselves into a known state */ - z80_reset( 1 ); tstates = 0; - for( i = 0; i < 0x10000; i += 4 ) { - memory[ i ] = 0xde; memory[ i + 1 ] = 0xad; - memory[ i + 2 ] = 0xbe; memory[ i + 3 ] = 0xef; - } - - if( read_test( f, &event_next_event ) ) return 0; - - /* Grab a copy of the memory for comparison at the end */ - memcpy( initial_memory, memory, 0x10000 ); - - z80_do_opcodes(); - - /* And dump our final state */ - dump_z80_state(); - dump_memory_state(); - - printf( "\n" ); - - return 1; -} - -static int -read_test( FILE *f, libspectrum_dword *end_tstates ) -{ - unsigned af, bc, de, hl, af_, bc_, de_, hl_, ix, iy, sp, pc, memptr; - unsigned i, r, iff1, iff2, im; - unsigned end_tstates2; - unsigned address; - char test_name[ 80 ]; - - do { - - if( !fgets( test_name, sizeof( test_name ), f ) ) { - - if( feof( f ) ) return 1; - - fprintf( stderr, "%s: error reading test description from `%s': %s\n", - progname, testsfile, strerror( errno ) ); - return 1; - } - - } while( test_name[0] == '\n' ); - - /* FIXME: how should we read/write our data types? */ - if( fscanf( f, "%x %x %x %x %x %x %x %x %x %x %x %x %x", &af, &bc, - &de, &hl, &af_, &bc_, &de_, &hl_, &ix, &iy, &sp, &pc, - &memptr ) != 13 ) { - fprintf( stderr, "%s: first registers line in `%s' corrupt\n", progname, - testsfile ); - return 1; - } - - AF = af; BC = bc; DE = de; HL = hl; - AF_ = af_; BC_ = bc_; DE_ = de_; HL_ = hl_; - IX = ix; IY = iy; SP = sp; PC = pc; - z80.memptr.w = memptr; - - if( fscanf( f, "%x %x %u %u %u %d %d", &i, &r, &iff1, &iff2, &im, - &z80.halted, &end_tstates2 ) != 7 ) { - fprintf( stderr, "%s: second registers line in `%s' corrupt\n", progname, - testsfile ); - return 1; - } - - I = i; R = R7 = r; IFF1 = iff1; IFF2 = iff2; IM = im; - *end_tstates = end_tstates2; - - while( 1 ) { - - if( fscanf( f, "%x", &address ) != 1 ) { - fprintf( stderr, "%s: no address found in `%s'\n", progname, testsfile ); - return 1; - } - - if( address >= 0x10000 ) break; - - while( 1 ) { - - unsigned byte; - - if( fscanf( f, "%x", &byte ) != 1 ) { - fprintf( stderr, "%s: no data byte found in `%s'\n", progname, - testsfile ); - return 1; - } - - if( byte >= 0x100 ) break; - - memory[ address++ ] = byte; - - } - } - - printf( "%s", test_name ); - - return 0; -} - -static void -dump_z80_state( void ) -{ - printf( "%04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x\n", - AF, BC, DE, HL, AF_, BC_, DE_, HL_, IX, IY, SP, PC, z80.memptr.w ); - printf( "%02x %02x %d %d %d %d %d\n", I, ( R7 & 0x80 ) | ( R & 0x7f ), - IFF1, IFF2, IM, z80.halted, tstates ); -} - -static void -dump_memory_state( void ) -{ - size_t i; - - for( i = 0; i < 0x10000; i++ ) { - - if( memory[ i ] == initial_memory[ i ] ) continue; - - printf( "%04x ", (unsigned)i ); - - while( i < 0x10000 && memory[ i ] != initial_memory[ i ] ) - printf( "%02x ", memory[ i++ ] ); - - printf( "-1\n" ); - } -} - -/* Error 'handing': dump core as these should never be called */ - -void -fuse_abort( void ) -{ - abort(); -} - -int -ui_error( ui_error_level severity GCC_UNUSED, const char *format, ... ) -{ - va_list ap; - - va_start( ap, format ); - vfprintf( stderr, format, ap ); - va_end( ap ); - - abort(); -} - -/* - * Stuff below here not interesting: dummy functions and variables to replace - * things used by Fuse, but not by the core test code - */ - -#include "debugger/debugger.h" -#include "machine.h" -#include "peripherals/scld.h" -#include "settings.h" - -libspectrum_byte *slt[256]; -size_t slt_length[256]; - -int -tape_load_trap( void ) -{ - /* Should never be called */ - abort(); -} - -int -tape_save_trap( void ) -{ - /* Should never be called */ - abort(); -} - -scld scld_last_dec; - -size_t rzx_instruction_count; -int rzx_playback; -int rzx_instructions_offset; - -enum debugger_mode_t debugger_mode; - -libspectrum_byte **ROM = NULL; -memory_page memory_map[8]; -memory_page *memory_map_home[MEMORY_PAGES_IN_64K]; -memory_page memory_map_rom[SPECTRUM_ROM_PAGES * MEMORY_PAGES_IN_16K]; -int memory_contended[8] = { 1 }; -libspectrum_byte spectrum_contention[ 80000 ] = { 0 }; -int profile_active = 0; - -void -profile_map( libspectrum_word pc GCC_UNUSED ) -{ - abort(); -} - -int -debugger_check( debugger_breakpoint_type type GCC_UNUSED, libspectrum_dword value GCC_UNUSED ) -{ - abort(); -} - -void debugger_system_variable_register( - const char *type, const char *detail, - debugger_get_system_variable_fn_t get, - debugger_set_system_variable_fn_t set ) -{ -} - -int -debugger_trap( void ) -{ - abort(); -} - -int -slt_trap( libspectrum_word address GCC_UNUSED, libspectrum_byte level GCC_UNUSED ) -{ - return 0; -} - -int beta_available = 0; -int beta_active = 0; -int if1_available = 0; - -void -beta_page( void ) -{ - abort(); -} - -void -beta_unpage( void ) -{ - abort(); -} - -int spectrum_frame_event = 0; - -int -event_register( event_fn_t fn GCC_UNUSED, const char *string GCC_UNUSED ) -{ - return 0; -} - -int opus_available = 0; -int opus_active = 0; - -void -opus_page( void ) -{ - abort(); -} - -void -opus_unpage( void ) -{ - abort(); -} - -int plusd_available = 0; -int plusd_active = 0; - -void -plusd_page( void ) -{ - abort(); -} - -int disciple_available = 0; -int disciple_active = 0; - -void -disciple_page( void ) -{ - abort(); -} - -int didaktik80_available = 0; -int didaktik80_active = 0; -int didaktik80_snap = 0; - -void -didaktik80_page( void ) -{ - abort(); -} - -void -didaktik80_unpage( void ) -{ - abort(); -} - -int usource_available = 0; -int usource_active = 0; - -void -usource_toggle( void ) -{ - abort(); -} - -void -if1_page( void ) -{ - abort(); -} - -void -if1_unpage( void ) -{ - abort(); -} - -int multiface_activated = 0; - -void -multiface_setic8( void ) -{ - abort(); -} - -void -divide_set_automap( int state GCC_UNUSED ) -{ - abort(); -} - -void -divmmc_set_automap( int state GCC_UNUSED ) -{ - abort(); -} - -int spectranet_available = 0; - -void -spectranet_page( int via_io GCC_UNUSED ) -{ - abort(); -} - -void -spectranet_nmi( void ) -{ - abort(); -} - -void -spectranet_unpage( void ) -{ - abort(); -} - -void -spectranet_retn( void ) -{ -} - -int -spectranet_nmi_flipflop( void ) -{ - return 0; -} - -void -startup_manager_register( startup_manager_module module, - startup_manager_module *dependencies, size_t dependency_count, - startup_manager_init_fn init_fn, void *init_context, - startup_manager_end_fn end_fn ) -{ -} - -int svg_capture_active = 0; /* SVG capture enabled? */ - -void -svg_capture( void ) -{ - abort(); -} - -int -rzx_frame( void ) -{ - abort(); -} - -void -writeport_internal( libspectrum_word port GCC_UNUSED, libspectrum_byte b GCC_UNUSED ) -{ - abort(); -} - -void -event_add_with_data( libspectrum_dword event_time GCC_UNUSED, - int type GCC_UNUSED, void *user_data GCC_UNUSED ) -{ - /* Do nothing */ -} - -int -module_register( module_info_t *module GCC_UNUSED ) -{ - return 0; -} - -void -z80_debugger_variables_init( void ) -{ -} - -fuse_machine_info *machine_current; -static fuse_machine_info dummy_machine; - -settings_info settings_current; - -libspectrum_word beta_pc_mask; -libspectrum_word beta_pc_value; - -int spectranet_programmable_trap_active; -libspectrum_word spectranet_programmable_trap; - -/* Initialise the dummy variables such that we're running on a clean a - machine as possible */ -static int -init_dummies( void ) -{ - size_t i; - - for( i = 0; i < 8; i++ ) { - memory_map[i].page = &memory[ i * MEMORY_PAGE_SIZE ]; - } - - debugger_mode = DEBUGGER_MODE_INACTIVE; - dummy_machine.capabilities = 0; - dummy_machine.ram.current_rom = 0; - machine_current = &dummy_machine; - rzx_playback = 0; - scld_last_dec.name.intdisable = 0; - settings_current.slt_traps = 0; - settings_current.divide_enabled = 0; - settings_current.divmmc_enabled = 0; - settings_current.z80_is_cmos = 0; - beta_pc_mask = 0xfe00; - beta_pc_value = 0x3c00; - spectranet_programmable_trap_active = 0; - spectranet_programmable_trap = 0x0000; - - return 0; -} diff --git a/fuse/z80/z80_checks.h b/fuse/z80/z80_checks.h index 3d3d82e..b9449dd 100644 --- a/fuse/z80/z80_checks.h +++ b/fuse/z80/z80_checks.h @@ -1,4 +1,3 @@ -SETUP_CHECK( profile, profile_active ) SETUP_CHECK( rzx, rzx_playback ) SETUP_CHECK( debugger, debugger_mode != DEBUGGER_MODE_INACTIVE ) SETUP_CHECK( beta, beta_available ) diff --git a/fuse/z80/z80_ops.c b/fuse/z80/z80_ops.c index c5ec439..9c2f961 100755 --- a/fuse/z80/z80_ops.c +++ b/fuse/z80/z80_ops.c @@ -46,7 +46,6 @@ #include "peripherals/spectranet.h" #include "peripherals/ula.h" #include "peripherals/usource.h" -#include "profile.h" #include "rzx.h" #include "settings.h" #include "slt.h" @@ -141,13 +140,6 @@ z80_do_opcodes( void ) while( tstates < event_next_event ) { - /* Profiler */ - CHECK( profile, profile_active ) - - profile_map( PC ); - - END_CHECK - /* If we're due an end of frame from RZX playback, generate one */ CHECK( rzx, rzx_playback ) diff --git a/libspectrum/make-perl.c b/libspectrum/make-perl.c deleted file mode 100644 index e539ca2..0000000 --- a/libspectrum/make-perl.c +++ /dev/null @@ -1,375 +0,0 @@ -/* make-perl.c: Generate a perl script to create the libspectrum_* typedefs - Copyright (c) 2002-2003,2015 Philip Kendall, Darren Salt - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - E-mail: philip-fuse@shadowmagic.org.uk - -*/ - -#include "config.h" - -#include - -int main(void) -{ - /* - * Define the integer types - */ - - printf( "if( /LIBSPECTRUM_DEFINE_TYPES/ ) {\n\n $_ = << \"CODE\";\n" ); - -#ifdef HAVE_STDINT_H - - printf( "#include \n\n" ); - - printf( "typedef uint8_t libspectrum_byte;\n" ); - printf( "typedef int8_t libspectrum_signed_byte;\n" ); - - printf( "typedef uint16_t libspectrum_word;\n" ); - printf( "typedef int16_t libspectrum_signed_word;\n" ); - - printf( "typedef uint32_t libspectrum_dword;\n" ); - printf( "typedef int32_t libspectrum_signed_dword;\n" ); - - printf( "typedef uint64_t libspectrum_qword;\n" ); - printf( "typedef int64_t libspectrum_signed_qword;\n" ); - -#else /* #ifdef HAVE_STDINT_H */ - - if( sizeof( char ) == 1 ) { - printf( "typedef unsigned char libspectrum_byte;\n" ); - printf( "typedef signed char libspectrum_signed_byte;\n" ); - } else if( sizeof( short ) == 1 ) { - printf( "typedef unsigned short libspectrum_byte;\n" ); - printf( "typedef signed short libspectrum_signed_byte;\n" ); - } else { - fprintf( stderr, "No plausible 8 bit types found\n" ); - return 1; - } - - if( sizeof( short ) == 2 ) { - printf( "typedef unsigned short libspectrum_word;\n" ); - printf( "typedef signed short libspectrum_signed_word;\n" ); - } else if( sizeof( int ) == 2 ) { - printf( "typedef unsigned int libspectrum_word;\n" ); - printf( "typedef signed int libspectrum_signed_word;\n" ); - } else { - fprintf( stderr, "No plausible 16 bit types found\n" ); - return 1; - } - - if( sizeof( int ) == 4 ) { - printf( "typedef unsigned int libspectrum_dword;\n" ); - printf( "typedef signed int libspectrum_signed_dword;\n" ); - } else if( sizeof( long ) == 4 ) { - printf( "typedef unsigned long libspectrum_dword;\n" ); - printf( "typedef signed long libspectrum_signed_dword;\n" ); - } else { - fprintf( stderr, "No plausible 32 bit types found\n" ); - return 1; - } - - if( sizeof( long ) == 8 ) { - printf( "typedef unsigned long libspectrum_qword;\n" ); - printf( "typedef signed long libspectrum_signed_qword;\n" ); -#if defined(_MSC_VER) && _MSC_VER <= 1200 - } else { - printf( "typedef unsigned __int64 libspectrum_qword;\n" ); - printf( "typedef signed __int64 libspectrum_signed_qword;\n" ); -#else - } else if( sizeof( long long ) == 8 ) { - printf( "typedef unsigned long long libspectrum_qword;\n" ); - printf( "typedef signed long long libspectrum_signed_qword;\n" ); - } else { - fprintf( stderr, "No plausible 64 bit types found\n" ); - return 1; -#endif - } - -#endif /* #ifdef HAVE_STDINT_H */ - - printf( "CODE\n}\n\n" ); - - /* - * Get glib or our replacement for it - */ - - printf( "if( /LIBSPECTRUM_GLIB_REPLACEMENT/ ) {\n\n" ); - -#ifdef HAVE_LIB_GLIB /* #ifdef HAVE_LIB_GLIB */ - - printf( " $_ = \"#define LIBSPECTRUM_HAS_GLIB_REPLACEMENT 0\\n\"\n" ); - -#else /* #ifdef HAVE_LIB_GLIB */ - - printf( " $_ = << \"CODE\";\n" -"#define LIBSPECTRUM_HAS_GLIB_REPLACEMENT 1\n" -"\n" -"#ifndef FALSE\n" -"#define FALSE (0)\n" -"#endif\n" -"\n" -"#ifndef TRUE\n" -"#define TRUE (!FALSE)\n" -"#endif\n" -"\n" -"typedef char gchar;\n" -"typedef int gint;\n" -"typedef long glong;\n" -"typedef gint gboolean;\n" -"typedef unsigned int guint;\n" -"typedef unsigned long gulong;\n" -"typedef const void * gconstpointer;\n" -"typedef void * gpointer;\n" -"\n" -"typedef struct _GSList GSList;\n" -"\n" -"struct _GSList {\n" -" gpointer data;\n" -" GSList *next;\n" -"};\n" -"\n" -"typedef void (*GFunc) (gpointer data,\n" -" gpointer user_data);\n" -"\n" -"typedef gint (*GCompareFunc) (gconstpointer a,\n" -" gconstpointer b);\n" -"\n" -"typedef void (*GDestroyNotify) (gpointer data);\n" -"\n" -"typedef void (*GFreeFunc) (gpointer data);\n" -"\n" -"\n" -"LIBSPECTRUM_API\n" -"GSList *g_slist_insert_sorted (GSList *list,\n" -" gpointer data,\n" -" GCompareFunc func);\n" -"\n" -"LIBSPECTRUM_API\n" -"GSList *g_slist_insert (GSList *list,\n" -" gpointer data,\n" -" gint position);\n" -"\n" -"LIBSPECTRUM_API\n" -"GSList *g_slist_append (GSList *list,\n" -" gpointer data);\n" -"\n" -"LIBSPECTRUM_API\n" -"GSList *g_slist_prepend (GSList *list,\n" -" gpointer data);\n" -"\n" -"LIBSPECTRUM_API\n" -"GSList *g_slist_remove (GSList *list,\n" -" gconstpointer data);\n" -"\n" -"LIBSPECTRUM_API\n" -"GSList *g_slist_last (GSList *list);\n" -"\n" -"LIBSPECTRUM_API\n" -"GSList *g_slist_reverse (GSList *list);\n" -"\n" -"LIBSPECTRUM_API\n" -"GSList *g_slist_delete_link (GSList *list,\n" -" GSList *link);\n" -"\n" -"LIBSPECTRUM_API\n" -"guint g_slist_length (GSList *list);\n" -"\n" -"LIBSPECTRUM_API\n" -"void g_slist_foreach (GSList *list,\n" -" GFunc func,\n" -" gpointer user_data);\n" -"\n" -"LIBSPECTRUM_API\n" -"void g_slist_free (GSList *list);\n" -"\n" -"LIBSPECTRUM_API\n" -"GSList *g_slist_nth (GSList *list,\n" -" guint n);\n" -"\n" -"LIBSPECTRUM_API\n" -"GSList *g_slist_find_custom (GSList *list,\n" -" gconstpointer data,\n" -" GCompareFunc func );\n" -"\n" -"LIBSPECTRUM_API\n" -"gint g_slist_position (GSList *list,\n" -" GSList *llink);\n" -"\n" -"typedef struct _GHashTable GHashTable;\n" -"\n" -"typedef guint (*GHashFunc) (gconstpointer key);\n" -"\n" -"typedef void (*GHFunc) (gpointer key,\n" -" gpointer value,\n" -" gpointer user_data);\n" -"\n" -"typedef gboolean (*GHRFunc) (gpointer key,\n" -" gpointer value,\n" -" gpointer user_data);\n" -"\n" -"LIBSPECTRUM_API\n" -"gint g_int_equal (gconstpointer v,\n" -" gconstpointer v2);\n" -"LIBSPECTRUM_API\n" -"guint g_int_hash (gconstpointer v);\n" -"\n" -"LIBSPECTRUM_API\n" -"gint g_str_equal (gconstpointer v,\n" -" gconstpointer v2);\n" -"LIBSPECTRUM_API\n" -"guint g_str_hash (gconstpointer v);\n" -"\n" -"LIBSPECTRUM_API\n" -"GHashTable *g_hash_table_new (GHashFunc hash_func,\n" -" GCompareFunc key_compare_func);\n" -"\n" -"LIBSPECTRUM_API\n" -"GHashTable *g_hash_table_new_full (GHashFunc hash_func,\n" -" GCompareFunc key_equal_func,\n" -" GDestroyNotify key_destroy_func,\n" -" GDestroyNotify value_destroy_func);\n" -"\n" -"LIBSPECTRUM_API\n" -"void g_hash_table_destroy (GHashTable *hash_table);\n" -"\n" -"LIBSPECTRUM_API\n" -"void g_hash_table_insert (GHashTable *hash_table,\n" -" gpointer key,\n" -" gpointer value);\n" -"\n" -"LIBSPECTRUM_API\n" -"gpointer g_hash_table_lookup (GHashTable *hash_table,\n" -" gconstpointer key);\n" -"\n" -"LIBSPECTRUM_API\n" -"void g_hash_table_foreach (GHashTable *hash_table,\n" -" GHFunc func,\n" -" gpointer user_data);\n" -"\n" -"LIBSPECTRUM_API\n" -"guint g_hash_table_foreach_remove (GHashTable *hash_table,\n" -" GHRFunc func,\n" -" gpointer user_data);\n" -"\n" -"LIBSPECTRUM_API\n" -"guint g_hash_table_size (GHashTable *hash_table);\n" -"\n" -"typedef struct _GArray GArray;\n" -"\n" -"struct _GArray {\n" -" /* Public */\n" -" gchar *data;\n" -" guint len;\n" -"\n" -" /* Private */\n" -" guint element_size;\n" -" guint allocated;\n" -"};\n" -"\n" -"LIBSPECTRUM_API GArray* g_array_new( gboolean zero_terminated, gboolean clear,\n" -" guint element_size );\n" -"LIBSPECTRUM_API GArray* g_array_sized_new( gboolean zero_terminated, gboolean clear,\n" -" guint element_size, guint reserved_size );\n" -"#define g_array_append_val(a,v) g_array_append_vals( a, &(v), 1 );\n" -"LIBSPECTRUM_API GArray* g_array_append_vals( GArray *array, gconstpointer data, guint len );\n" -"#define g_array_index(a,t,i) (*(((t*)a->data)+i))\n" -"LIBSPECTRUM_API GArray* g_array_set_size( GArray *array, guint length );\n" -"LIBSPECTRUM_API GArray* g_array_remove_index_fast( GArray *array, guint index );\n" -"LIBSPECTRUM_API gchar* g_array_free( GArray *array, gboolean free_segment );\n" -"\n" ); - if( sizeof( void* ) == sizeof( int ) ) { - printf( "#define GINT_TO_POINTER(i) ((gpointer) (i))\n" ); - printf( "#define GPOINTER_TO_INT(p) ((gint) (p))\n" ); - printf( "#define GPOINTER_TO_UINT(p) ((guint) (p))\n" ); - } else if( sizeof( void* ) == sizeof( long ) ) { - printf( "#define GINT_TO_POINTER(i) ((gpointer) (glong)(i))\n" ); - printf( "#define GPOINTER_TO_INT(p) ((gint) (glong)(p))\n" ); - printf( "#define GPOINTER_TO_UINT(p) ((guint) (gulong)(p))\n" ); - } else { - fprintf( stderr, "No plausible int to pointer cast found\n" ); - return 1; - } - printf( "CODE\n" ); -#endif /* #ifdef HAVE_LIB_GLIB */ - - printf( "}\n\n" ); - - /* - * If we have libgcrypt, include the header file and store the signature - * parameters - */ - - printf( "if( /LIBSPECTRUM_INCLUDE_GCRYPT/ ) {\n\n" ); - -#ifdef HAVE_GCRYPT_H - - printf( " $_ = \"#include \\n\";\n\n" ); - -#else - - printf( " $_ = '';\n\n" ); - -#endif - - printf( "}\n\n" ); - - printf( "if( /LIBSPECTRUM_SIGNATURE_PARAMETERS/ ) {\n\n" ); - -#ifdef HAVE_GCRYPT_H - - printf( " $_ = \" /* The DSA signature parameters 'r' and 's' */\\n gcry_mpi_t r, s;\\n\";\n\n" ); - -#else - - printf( " $_ = \"/* Signature parameters not stored as libgcrypt is not present */\n\";\n\n" ); - -#endif - - printf( "}\n\n" ); - - printf( "if( /LIBSPECTRUM_CAPABILITIES/ ) {\n\n $_ = << \"CODE\";\n" ); - -#ifdef HAVE_ZLIB_H - - printf( "\n/* we support snapshots etc. requiring zlib (e.g. compressed szx) */\n" ); - printf( "#define LIBSPECTRUM_SUPPORTS_ZLIB_COMPRESSION (1)\n\n" ); - printf( "/* zlib (de)compression routines */\n\n" ); - printf( "LIBSPECTRUM_API libspectrum_error\n" ); - printf( "libspectrum_zlib_inflate( const libspectrum_byte *gzptr, size_t gzlength,\n" ); - printf( " libspectrum_byte **outptr, size_t *outlength );\n\n" ); - printf( "LIBSPECTRUM_API libspectrum_error\n" ); - printf( "libspectrum_zlib_compress( const libspectrum_byte *data, size_t length,\n" ); - printf( " libspectrum_byte **gzptr, size_t *gzlength );\n\n" ); - -#endif /* #ifdef HAVE_ZLIB_H */ - -#ifdef HAVE_LIBBZ2 - printf( "\n/* we support files compressed with bz2 */\n" ); - printf( "#define LIBSPECTRUM_SUPPORTS_BZ2_COMPRESSION (1)\n\n" ); -#endif /* #ifdef HAVE_LIBBZ2 */ - -#ifdef HAVE_LIB_AUDIOFILE - printf( "\n/* we support wav files */\n" ); - printf( "#define LIBSPECTRUM_SUPPORTS_AUDIOFILE (1)\n\n" ); -#endif /* #ifdef HAVE_LIB_AUDIOFILE */ - - printf( "CODE\n}\n\n" ); - - return 0; -} diff --git a/libspectrum/myglib/glock.c b/libspectrum/myglib/glock.c deleted file mode 100644 index b3a6078..0000000 --- a/libspectrum/myglib/glock.c +++ /dev/null @@ -1,47 +0,0 @@ -/* glock.c: Routines for locking critical sections - Copyright (c) 2016 BogDan Vatra - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Author contact information: - - BogDan Vatra -*/ - -#include "config.h" - -#include - -#include "internals.h" - -void -atomic_lock( atomic_char *lock_ptr ) -{ - char locked = ATOMIC_VAR_INIT( 1 ); - char unlocked; - do { - unlocked = ATOMIC_VAR_INIT( 0 ); - } while( !atomic_compare_exchange_strong( lock_ptr, &unlocked, locked ) ); -} - -void -atomic_unlock( atomic_char *lock_ptr ) -{ - char locked; - char unlocked = ATOMIC_VAR_INIT( 0 ); - do { - locked = ATOMIC_VAR_INIT( 1 ); - } while( !atomic_compare_exchange_strong( lock_ptr, &locked, unlocked ) ); -} diff --git a/libspectrum/test/Makefile.am b/libspectrum/test/Makefile.am deleted file mode 100644 index fa9b9be..0000000 --- a/libspectrum/test/Makefile.am +++ /dev/null @@ -1,96 +0,0 @@ -## Process this file with automake to produce Makefile.in -## Copyright (c) 2007,2015 Philip Kendall - -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -## -## Author contact information: -## -## E-mail: philip-fuse@shadowmagic.org.uk - -check_PROGRAMS = test/test - -TESTS = $(check_PROGRAMS) - -test_test_SOURCES = \ - test/edges.c \ - test/szx.c \ - test/test.c \ - test/test_edges.c - -test_test_CFLAGS = -DSRCDIR='"$(srcdir)"' - -noinst_DATA += test/complete-tzx.tzx - -noinst_HEADERS += test/test.h - -test/complete-tzx.tzx: test/complete-tzx.pl - $(AM_V_GEN)$(PERL) $< > $@.tmp && mv $@.tmp $@ - -test_test_LDADD = libspectrum.la - -EXTRA_DIST += \ - test/Makefile.am \ - test/complete-tzx.pl \ - test/empty-drb.tzx \ - test/empty.csw \ - test/empty.szx \ - test/empty.z80 \ - test/invalid-archiveinfo.tzx \ - test/invalid-custominfo.tzx \ - test/invalid-gdb.tzx \ - test/invalid-hardwareinfo.tzx \ - test/invalid-warajevo-blockoffset.tap \ - test/invalid.gz \ - test/invalid.szx \ - test/invalid.tzx \ - test/jump.tzx \ - test/loop.tzx \ - test/loop2.tzx \ - test/loopend.tzx \ - test/no-pilot-gdb.tzx \ - test/plus3.z80 \ - test/random.szx \ - test/raw-data-block.tzx \ - test/sp-2000.sna.gz \ - test/sp-ffff.sna.gz \ - test/standard-tap.tap \ - test/szx-chunks/AMXM.szx \ - test/szx-chunks/ATRP.szx \ - test/szx-chunks/ATRP-uncompressed.szx.gz \ - test/szx-chunks/AY.szx \ - test/szx-chunks/CFRP.szx \ - test/szx-chunks/CFRP-uncompressed.szx.gz \ - test/szx-chunks/COVX.szx \ - test/szx-chunks/DRUM.szx \ - test/szx-chunks/JOY.szx \ - test/szx-chunks/KEYB.szx \ - test/szx-chunks/RAMP.szx \ - test/szx-chunks/RAMP-uncompressed.szx.gz \ - test/szx-chunks/SCLD.szx \ - test/szx-chunks/SIDE.szx \ - test/szx-chunks/SPCR.szx \ - test/szx-chunks/Z80R.szx \ - test/szx-chunks/ZMMC.szx \ - test/szx-chunks/ZXAT.szx \ - test/szx-chunks/ZXCF.szx \ - test/szx-chunks/ZXPR.szx \ - test/trailing-pause-block.tzx \ - test/turbo-zeropilot.tzx \ - test/writeprotected.mdr \ - test/zero-tail.pzx - -CLEANFILES += \ - test/.libs/test \ - test/complete-tzx.tzx diff --git a/libspectrum/test/complete-tzx.pl b/libspectrum/test/complete-tzx.pl deleted file mode 100755 index 29f497c..0000000 --- a/libspectrum/test/complete-tzx.pl +++ /dev/null @@ -1,283 +0,0 @@ -#!/usr/bin/perl - -use warnings; -use strict; - -sub write_byte { - - my( $b ) = @_; - - printf "%c", $b; -} - -sub write_word { - - my( $w ) = @_; - - write_byte( $w % 0x100 ); - write_byte( $w / 0x100 ); -} - -sub write_three { - - my( $three ) = @_; - - write_byte( $three % 0x100 ); - write_word( $three / 0x100 ); - -} - -sub write_dword { - - my( $dw ) = @_; - - write_word( $dw % 0x10000 ); - write_word( $dw / 0x10000 ); -} - -sub write_header { - - print "ZXTape!\x1a"; # Signature - write_byte( 1 ); # Major version number - write_byte( 20 ); # Minor version number - -} - -sub write_standard_speed_data_block { - - my( $data, $pause ) = @_; - - write_byte( 0x10 ); - write_word( $pause ); - write_word( length $data ); - print $data; - -} - -sub write_turbo_speed_data_block { - - my( $pilot_length, $pilot_count, $sync1_length, $sync2_length, - $zero_length, $one_length, $data, $bits_in_last_byte, $pause ) = @_; - - write_byte( 0x11 ); - write_word( $pilot_length ); - write_word( $sync1_length ); - write_word( $sync2_length ); - write_word( $zero_length ); - write_word( $one_length ); - write_word( $pilot_count ); - write_byte( $bits_in_last_byte ); - write_word( $pause ); - write_three( length $data ); - print $data; - -} - -sub write_pure_tone_block { - - my( $length, $count ) = @_; - - write_byte( 0x12 ); - write_word( $length ); - write_word( $count ); - -} - -sub write_pulse_sequence_block { - - my( @data ) = @_; - - write_byte( 0x13 ); - write_byte( scalar @data ); - write_word( $_ ) foreach @data; - -} - -sub write_pure_data_block { - - my( $zero_length, $one_length, $data, $bits_in_last_byte, $pause ) = @_; - - write_byte( 0x14 ); - write_word( $zero_length ); - write_word( $one_length ); - write_byte( $bits_in_last_byte ); - write_word( $pause ); - write_three( length $data ); - print $data; - -} - -sub write_pause_block { - - my( $pause ) = @_; - - write_byte( 0x20 ); - write_word( $pause ); - -} - -sub write_group_start_block { - - my( $name ) = @_; - - write_byte( 0x21 ); - write_byte( length $name ); - print $name; - -} - -sub write_group_end_block { - - my( $name ) = @_; - - write_byte( 0x22 ); - -} - -sub write_jump_block { - - my( $offset ) = @_; - - write_byte( 0x23 ); - write_word( $offset ); - -} - -sub write_loop_start_block { - - my( $iterations ) = @_; - - write_byte( 0x24 ); - write_word( $iterations ); - -} - -sub write_loop_end_block { - - write_byte( 0x25 ); - -} - -sub write_stop_tape_if_in_48k_mode_block { - - write_byte( 0x2a ); - write_dword( 0 ); - -} - -sub write_text_description_block { - - my( $text ) = @_; - - write_byte( 0x30 ); - write_byte( length $text ); - print $text; - -} - -sub write_message_block { - - my( $text, $time ) = @_; - - write_byte( 0x31 ); - write_byte( $time ); - write_byte( length $text ); - print $text; - -} - -sub write_archive_info_block { - - my( @strings ) = @_; - - write_byte( 0x32 ); - - my $data; - - foreach my $string ( @strings ) { - $data .= chr( $string->{id} ); - $data .= chr( length $string->{text} ); - $data .= $string->{text}; - } - - write_word( length $data ); - write_byte( scalar @strings ); - print $data; - -} - -sub write_hardware_type_block { - - my( @info ) = @_; - - write_byte( 0x33 ); - write_byte( scalar @info ); - - foreach my $info ( @info ) { - write_byte( $info->{type} ); - write_byte( $info->{id} ); - write_byte( $info->{used} ); - } -} - -sub write_custom_info_block { - - my( $id, $data ) = @_; - - write_byte( 0x35 ); - - if( length $id < 16 ) { - $id .= ' ' x ( 16 - length $id ); - } elsif( length $id > 16 ) { - $id = substr( $id, 0, 16 ); - } - print $id; - write_dword( length $data ); - print $data; - -} - -write_header(); - -write_standard_speed_data_block( "\xaa", 2345 ); - -write_turbo_speed_data_block( 1000, 5, 123, 456, 789, 400, "\x00\xff\x55\xa0", - 4, 987 ); - -write_pure_tone_block( 535, 666 ); - -write_pulse_sequence_block( 772, 297, 692 ); - -write_pure_data_block( 552, 1639, "\xff\x00\xfc", 6, 554 ); - -write_pause_block( 618 ); - -write_group_start_block( "Group Start" ); - -write_group_end_block(); - -write_jump_block( 2 ); - -write_pure_tone_block( 303, 678 ); - -write_loop_start_block( 3 ); - -write_pure_tone_block( 837, 185 ); - -write_loop_end_block(); - -write_stop_tape_if_in_48k_mode_block(); - -write_text_description_block( "Comment here" ); - -write_message_block( "A message", 1 ); - -write_archive_info_block( { id => 0x00, text => "Full title" }, - { id => 0x03, text => "Year" } ); - -write_hardware_type_block( { type => 0x00, id => 0x01, used => 0x00 }, - { type => 0x02, id => 0x02, used => 0x03 } ); - -write_custom_info_block( "Complete TZX", "Arbitrary custom data" ); - -write_pure_tone_block( 820, 941 ); diff --git a/libspectrum/test/edges.c b/libspectrum/test/edges.c deleted file mode 100644 index 7e7e780..0000000 --- a/libspectrum/test/edges.c +++ /dev/null @@ -1,66 +0,0 @@ -#include "test.h" - -test_return_t -check_edges( const char *filename, test_edge_sequence_t *edges, - int flags_mask ) -{ - libspectrum_byte *buffer = NULL; - size_t filesize = 0; - libspectrum_tape *tape; - test_return_t r = TEST_FAIL; - test_edge_sequence_t *ptr = edges; - - if( read_file( &buffer, &filesize, filename ) ) return TEST_INCOMPLETE; - - tape = libspectrum_tape_alloc(); - - if( libspectrum_tape_read( tape, buffer, filesize, LIBSPECTRUM_ID_UNKNOWN, - filename ) != LIBSPECTRUM_ERROR_NONE ) { - libspectrum_tape_free( tape ); - libspectrum_free( buffer ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); - - while( 1 ) { - - libspectrum_dword tstates; - int flags; - libspectrum_error e; - - e = libspectrum_tape_get_next_edge( &tstates, &flags, tape ); - if( e ) { - libspectrum_tape_free( tape ); - return TEST_INCOMPLETE; - } - - flags &= flags_mask; - - if( tstates != ptr->length || flags != ptr->flags ) { - fprintf( stderr, "%s: expected %u tstates and flags %d, got %u tstates and flags %d\n", - progname, ptr->length, ptr->flags, tstates, flags ); - break; - } - - if( tstates != ptr->length ) { - fprintf( stderr, "%s: expected %u tstates, got %u tstates\n", progname, - ptr->length, tstates ); - break; - } - - if( --ptr->count == 0 ) { - ptr++; - if( ptr->length == -1 ) { - r = TEST_PASS; - break; - } - } - } - - if( libspectrum_tape_free( tape ) ) return TEST_INCOMPLETE; - - return r; -} - - diff --git a/libspectrum/test/empty-drb.tzx b/libspectrum/test/empty-drb.tzx deleted file mode 100644 index 88ba5eca1d6503409f308d038fd2fd7f5244dacb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 19 Ucma!w2uUnRRg_{B5oLe^04X2>q5uE@ diff --git a/libspectrum/test/empty.csw b/libspectrum/test/empty.csw deleted file mode 100644 index d113ab6c177f6fadbeffce5f9f52324a4fd5b5b8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 52 pcmZ?H&n+lQEiO(?Q3x(9O)N@P2v00am11IWS;GJZOb`m01ORwG31|QS diff --git a/libspectrum/test/empty.szx b/libspectrum/test/empty.szx deleted file mode 100644 index 2cdb0cc56c284aaf0f1a050a56b9cc9b57d3f99b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 348 zcma!w2o7OnW@K;<3JHp0U|=ZDODssv&np8mu>vjzMuwcsq~e0q%mSYf;%N8bQFAcv8Gwc^&>gN8r@c$gH7XB_=^ zQ!JT(0+JzM=KgEU4pj{9AYEEuT}&`t42Kqc_0Q#zUx22iVLPJ((0GIn1|oF;03w+? A%K!iX diff --git a/libspectrum/test/empty.z80 b/libspectrum/test/empty.z80 deleted file mode 100644 index 6ebdcfc60318cd433695d359f0d85e15bceedbb6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 877 zcmZQzfPw}X1DQ5sFcAXr`H%%c?E4H%=t9VR7Dkr0Z~rrlZ0x|m!pJ(Zg8-BS92nRb LIYxuQ4w#hyR_ZH$ diff --git a/libspectrum/test/invalid-archiveinfo.tzx b/libspectrum/test/invalid-archiveinfo.tzx deleted file mode 100644 index 742929a312d3b89ed90943ab0b82f860456a6bfd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 27 icma!w2uUnRRg_{BG2&xjV&D!*EiO?gE-A{)O9ud2@&_>h diff --git a/libspectrum/test/invalid-custominfo.tzx b/libspectrum/test/invalid-custominfo.tzx deleted file mode 100644 index 68380b7b57c4e0011c4a6a93533c54cb8f82ff9b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 31 hcma!w2uUnRRg_{BF*P(YHZe6bx3DyTuoxK_7yxtp1_b~B diff --git a/libspectrum/test/invalid-gdb.tzx b/libspectrum/test/invalid-gdb.tzx deleted file mode 100644 index d4729faff91f21f406d50a7860ec990f5be302bd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 40 kcma!w2uUnRRg_{Bk(6XW0S-(|4C~m|u`z@*hchz(0Cvv>9{>OV diff --git a/libspectrum/test/invalid-hardwareinfo.tzx b/libspectrum/test/invalid-hardwareinfo.tzx deleted file mode 100644 index 7ab3625..0000000 --- a/libspectrum/test/invalid-hardwareinfo.tzx +++ /dev/null @@ -1 +0,0 @@ -ZXTape!3 \ No newline at end of file diff --git a/libspectrum/test/invalid-warajevo-blockoffset.tap b/libspectrum/test/invalid-warajevo-blockoffset.tap deleted file mode 100644 index 776bef52a92b105cc9656872d32393d2e5321dd8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12 QcmZQzVEE4f1pk2m0228G`~Uy| diff --git a/libspectrum/test/invalid.gz b/libspectrum/test/invalid.gz deleted file mode 100644 index 93575e81cca69922b43c2d35247903281bb476e7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 26 acmb2|=HPJKIo*wkIW@PSq>_P|0R{k9QUuNb diff --git a/libspectrum/test/invalid.szx b/libspectrum/test/invalid.szx deleted file mode 100644 index dfae0874e3562be7a7d0fcae01f4999f2b679eac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 Ycma!w2o7OnW@K;<3JGFh`2U{^03&1sq5uE@ diff --git a/libspectrum/test/invalid.tzx b/libspectrum/test/invalid.tzx deleted file mode 100644 index b4383c3..0000000 --- a/libspectrum/test/invalid.tzx +++ /dev/null @@ -1 +0,0 @@ -ZXTape! ÿ \ No newline at end of file diff --git a/libspectrum/test/jump.tzx b/libspectrum/test/jump.tzx deleted file mode 100644 index e2f0fffd441d8e94610bcba516b8a4f66b0b55aa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23 acma!w2uUnRRg_{BQD$Ng(q~-81SSAI)&zzC diff --git a/libspectrum/test/loop.tzx b/libspectrum/test/loop.tzx deleted file mode 100644 index 42d38cdefd10acf9527a918b41f1675275e86dd1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14 Vcma!w2uUnRRg_{BQDI_G1ppjf0@wfm diff --git a/libspectrum/test/loop2.tzx b/libspectrum/test/loop2.tzx deleted file mode 100644 index bb96ede320c653506ad46a6c192d96ba9fbedcbf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 19 acma!w2uUnRRg_{BQDI^ba%JAhpb7vj*aPbT diff --git a/libspectrum/test/loopend.tzx b/libspectrum/test/loopend.tzx deleted file mode 100644 index 949428d..0000000 --- a/libspectrum/test/loopend.tzx +++ /dev/null @@ -1 +0,0 @@ -ZXTape!% \ No newline at end of file diff --git a/libspectrum/test/no-pilot-gdb.tzx b/libspectrum/test/no-pilot-gdb.tzx deleted file mode 100644 index b295f8b09ca9274d10025f6f684d9224a81a9912..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 47 tcma!w2uUnRRg_{B(Pm^|U|^J#0+KKw0Aw&RF_C?=&oHvF0|N^q>&OlQP!e!p OU}NMM4F)@4UIGAtNGvb_ diff --git a/libspectrum/test/random.szx b/libspectrum/test/random.szx deleted file mode 100644 index 986e8b527280a2197fd188facddadc051beb7a9b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 49402 zcmV)UK(N1BSW{F11pxpN6R zAb2=7Up6!#G%hhTE-)=KEn#hBHZ)o|Fj6G|003M7006mMs1QT|OBV(Je-HowI$TEo z|NlQI000340000j0yqFuP(xA(00007000L70000=Pgwv400000000082unp-LInT- z0000000>e+O;7_s000001x3^Sz5?VXDFD|{;lL2|XDF%hB|A1LAMCrMcRZUWXKT-V zU2}|JN7wgKuy5{QOcO;SY{&SNJA9qN_+O%iY6qy+^=AEx=*pBdRBI>P6%%{U;6<-3 z4maGAd5M@Ihw^vG2L;jhg?boC1;Nj%vO8FJpKie(leUsUhVU0gOcYMw3PP~5hXtSW zx&HK%T3S|OSX*srnQ8tUVi>?<_51zhbypgXbe|ArvGBtC3iOi#fEqD_M+XZWHxD zM1qHmVLu5m1$B*s-=#G-M4UZoNvw!M*Rq zz5GeL3)&C-rLep{Dbu;rx0QkeEGUm7z^(Itgq$L0rAn^#z%vlv4mEu+Nb3lCcYoqu zT0b_;6#i*MMwed^suUp3@Zrbonu~-_OKqJD^xM36_gg@jlKh@6BP$SiZ&5n@-2&v1 zjH9@}wdV!Z1-NiQIAtY&eg|l^eOjuT1(2$C@QxlrKb6u9=hTARM;!iq!d@oEJGN=i zBW~$q6E%MruhNGw=Q}9|d0_)RYf3V@x3z0A&pU1)NnG_`CR>-*&{IRR0XvQf3PM6< z;w53q3*0s;EnJ`Qc8v5sVUNIIVJN312)d&=G!p&%-`h6~Ye!F}x$e|`m()sjyxks9 z`~Ee3f;De-09tZ{h93XnVSL`xl`4XKWug@^|8prg0?>KN4yFS zpn(LAe$n@Wi^&GH=;Q0p(GMb!@$h_LlwHdNR(zsAxVOpU#0;ODMzEn-YeehH(n*Lk zgTO8|C0-q{eh<$v0t>9>292nF?&8IT`$3)#1B75wsGP+|bsD1_MIi*~;^kg|jr#O~ z=RlIkZ*%Ird|1d2`g{u0I>SW4OpOk13Ar3CVQ@c zh(z%r5XOoKFp0~YxuFIstroWrORkpXu0@gFWJ`{v+(z4&{bRKQR+jlITl)|tLKh0O zM5$PEs-Jt#lMnY*bD|QsJc^?g)N|G2<#puK@bDJfIbYsG<2!;vtk)ZK$-3iiQfL0r z4O)i?R3|oGFQNH>*37&1T*U~}?g$)%5U7X6cbwvp>aM9q2OH+->S=yde7gkeP7F2l z<(hQPzJMJ^VD4;`YSTEY?G}t(VbJ-#t>~+gm|lRSZNuQ7bVj;N?TMX>A|4 zAl>No0kr$ME{|&y=+y4&MqIKxhAM)!e`s0iAtm}y+x>xvCOD0t&3%C(=fI-yh3++< zKv`%@3yM(5Hc<6h4kU;1V!g(P`F{;9Oq90{GB4gz?}mdti-7HkUtKnd{2AS#JwJ+T zSf1hnc;Di;lFN7ktYRJ`#UW!WE=$gduaKfvbXRkh6D8o#!Z>^_67boDKyHBbx5Xk8 zU#=lQ`>`Jivav#Ig=!Fvf#8~Q2huOA)trQobJ5({2U>w3Tu0M8~TkY z^E05XL_2rGF=dUf)TH&Fki`p@vc_@DPLu#n3TLu;P~Jcw^0HF2b}M}7nn9ryc56H? z#s$!uaG)P_g>nxwaVYF)^J`XSX=K7?_GA_4Y0e37oHYnA#xTLo@E11QEfhD&_na{l zWr8K(zAQ_Ti3JvM01i8dv|I7Oi3_LPL|w-XLy0m&oKL%U?In*T7h)i8KU>b&Bt5e< z2^eHF*upL)C~3B-ejlw)SLK7V-Ew>G(uu;4Za5y9*>89wvZg6ho>yo+S zC8PrwtI%EJ#@r*3Nt#cf89nzipsnR^P`jtI?~zEJWU0ucecw5RK@L*m-3-XGK}pdhn(>(T;?TJ9 zW-&QcYG#!bPHUB$-Q^QZZP$}a*L~sEEfy^|6Q$J1pon9U{ZGe>_P8;e9gS5vs73A| z3);~yFuBqQ6x2A^G#mM`Ujo)8+fLT^4JpL6fO@#W<}>@6YzGQsF1bU_K$aPRZOB>xXV}++>EFlf@N^HyLpcCettnnLO|1XIukHNr>6;l zISQ80W~-77nta1+=YF!z)=NcxSpT^w4ZtoI$Er#&6~)Z3r_*8h662kMcJ6ufb4jTi z!RezN+%nLW(Er9?owufG)Rv&EJTT(cTqiHBcwz~{nFKu-L_64$kJommC3qpp zc%>K1LF&UhRDDOGSvf7|qnx#>vtoq`RfDJKVj4q*gnM zw96;;dKoqUTZWFS0wKU1asiiFHAHyLYd71BjxpHo{T*Ya0cuEM$Ebt_%VC zB;AQcAjh9Y&uGAatXU9t@#i!+xOS<@>dIUIVBdm}?v?=2d6y*?@3t6$xOs}B6H7}v z5Ol)xHq(vc^bqvM+iNl$9;hK#z*{ilV9*h_;PGZDkE0Ee)-zF9dIpcDL~%jWnSmKq zuD^o`&})?_6M+!ln|Rm9hx;Dmsj5XXhkvy*tHC%#998J7e+G3eJQ~AU*d?aO>y#F# zz!c*M(md6GQ4UxSvJA@_g1Wz;FS5X$)3D$DeSk;<-XbbF;wZ4W;ohu2)yE%_Ps{z- zs@@yKf~Yzt_zQ31M-C+}y}|7)CiE9<9ccHyrh$&u+>70ftI`qggR|lrd%D@5RFn(4 zGy1$mM6|$Eq1@a*v=gE?qt1{&CB){Uq-h`$Se1!{^gh4qK!&H9Suj54&S)Y3b2%$P z8ja9S0%<(OVk(52f;VwSiW$D1LQBbD04SN}6fg^SkoF|T4nGLSB8+668Uf3h@Ih~Rc&h@h@7e7C zsU2&}fubw(+&;d1`vJUxH^8Pvs1Tjo$bLeH>Z#YT^ zK>`~ay>4iTRq@8Kopo`Hvb>rbtDdfp0|3AxfKmO)qa4QV5CtJnv2!NLa(cv63p zT&V87JGny&0}*AxADsG}{~Hvtifbi{$6eBbHoy6gD`CuHF01aH^hdrb&<4t|sLOM{k+XhXd0%Z`RikoIDc~cj?^)?2$ zJW*w3NT_|g_^d$R5Zy?9{}6|*bBg-}$^XE$J2{6%zW_At?JRpBIQ|?O6h$}xY-AgF zjr@HS*Ty4e{8XkAoLq}Cqv<{N*@p-NK1dHh*#a;dgZGyKbEzxG8|_frW;Z!p9GkBJ zJKP;7E9n4VEOLfRcVS-$r6XqO-Jb3=jo}jD0`y(+b29>IaI@g`Uq;BxUJD^cw87|- zKy24w^siuM2;+mh)71U;V#bB&oLyQGjLh*UQgt#z!xW!jw8PZv+6xp~SAl^P%Si)3 zp;I37T{4ribYqw`A6Mvk+Y3&ZFob0CMPXmhuie6X1z*{6Yu}4gfwi`(pAL0Acx}wb(uB|Z;lWZv=CKG|-(KvU4S`5heLVN+- z!u(U4t$+>%DixABS?S{uwk@CeES+|>u^Z!j4<16GI)RlQc?t4IV?3(CuGM|59z)ZJr}a?wR$A0oTob(aW+yB_NQ?``DM+e z-)d~?7D0)ySs7D`O7c&hdrELc_eo*UKhD!89ul@o&UuYYO@nzt1l{qX5p-7bzzdf& zES^R$WuIZhWK~5FtzNae#z02hb7UmG{4p}7l^SQJ7cEkmcJ?FWI9%7N=d2^>0s7S! z<|oW%Q2bAkF_B=tFAUDcieeKg?v&s0qPWomF2Yvz!vvIbj)J){v#>EV`8pf>-p}E$ zB}eA`L(5a`zTkehpduz;luqYNk{l`q&p8unFw_64(mh%WHlg+m6{{zUDJL48X*uJt zx1xUDoE6`&dQ$=^6iI7VaJ7>_Me8^$FI8))TFz3{iz-9~pPAg&!X%E$$-V^rcR`{GUc^ahNK6k z4MJX+ZYZb3aRiu+1yLUYn(5PLF|< zf+`FdtwHCE(Sd}Vlr}yY`E_4Gp?|8+Jtmj@$aPY>z0w;dPfoG4!NTVuTAO za%eroK>CF-WF}!khFPt9mElCJpInOL%*I$SExikT6dfo-P+FHhlwTQL<-AGgx8&M6 zXr$I!ll@Y&>Lis>AplmhPPjjEyC?en-jrT!{``j(mV2p5<;l6i2eA7!Z{Ry)CCb-H zHbu!$gzL?shgvMDd}+FzQ)}&W)BgsVmIfvrx@W@{Uy9jt9)z~7@MVG67Fq!@xh*Za zca}|$bIZ%OEMI3zZ(RJ4*s)eRLxW&3K}C&tkuSplU^x2kL?C*GRw3_s@b>)oou_tX zUs?UNu~RP3oKph%GdU~QOlxdj<2$qv1I}3~$x;q@uJ8vpi`rqs=7;9JkYXo5MH*@+ zdefUv5d=m~Yo0Ur`I|z5E%!{oXc!Seb0`vY?GPoDfK7FTW65MOU5xbBF?)M9C6vTg z7NNhk>aMpe!!g?KF%{{<INz>VmnQ2M#vZLwhJGzgB{+8J@l!gjUfw&aNzX)uP9?dy$voZ zv&R>8P_iIl{lF2|d+h~SVt3*+W=;iDbkJ9GdHgFDIJiF!pcTW^nk`~!0Z3^CP!!=| zkI`X~vY|*$miOobofNi^ukf(Trd;Nv)D4bM9PXh{yKI(WM@s7W1LZvSB!55A{EG`X z+3=Y5!REo1<~pG`I2jb48J%hBN(e9Ddx&vv@>8wbl)hYmjy1rdTmOhowATXZ6pyegDQ6UMH*;d(y#*Q5O&+LTHaH!kf4p zm)%V{(M)CZDz*g;i&`z?XLAHt8~(A>D{@(<%;_wzlM1L}vBNpJT=V+lD_!*JO$e~o z&8$MNLH*d!?uoD#SRDOz%n(}KkHV)-@+99fe+rstAF2IXm8Z@@BNvGeaB!?xh&gvq zR03uC=us;W=pIi9uo^M(zSkPx0Ig{ZjDcVV5w_U79MX{wkO-nme3jb}lN1!HNjM|H zo1PSAcNysR7GjF7#JJlTw;Ask1R- z!k64p+n)>Xejhdy=j_|Az})hFWf^M|h={Qx zNjxr_1RM^y$BiNqf|x`&nzoXGqHcKfPUwr3+D>Es9E~=Fk@Pi2H=UT9n^-GsaUy`~ z)~%$*r=CRW->t>2IPpB-p-A#T-2FuwaT}pW^WD!s!R4v6$E~&DcB<44SJC43gS`C` z7dA@?iB8Z0SpYoC4gF)vNWaG}x5s8!6wQ=;4tXFN_onk1ge^Hr@r;_QL$mt`_P;aT zv~vyteg^Lm;in!ND^9nnwW2^T?ih$h{-nMSjEDaUD~mtk1;>$#gFUoJ=|W?ggJj6g ze89doP{Ohi?OpIOqCom~JH_A`o^ZRlQxsAW(D!5$p~Wvp50+9g4p~RioYY7%GoS3c zJhP5$cv!tKd_43HBYn2CymZg~6Y6K$wrGfcr}Gt5#nWZC!IC^jneJt_0kk{=17JidJY~+1-IqvG>UbqCi0cSje_l~II z6aWUkvIa&2qTHBDB{8<^Pak$xIGjfge6##d&;u9^<*|Lis&(1WLFCMZ^~t)ojuG{L z9tf{e#`y@aA6%u9Fqd4#-epi4WEiY&>+D|)y%hPWPa&)Q1tIZF)xcwvf_<8KthrvO zzx-JLz*Puf*$Rx3-bCr^(h2^ormkVdKXLGVwWq_AU+v1*y(S+Iodati$O*QL{B2uP zqchDg^iUt2#VVTF-1&%0q`kMfwduTy8C1QP0M&peK*U;heDw9B1u#MQ21tdZ*%O94 zG6I16026~G`k;V{Pw~M)c!MHzqQe*0Ivazjy}?sYli#jbngQKK0oM4QE@L4YONcXe zBLjpXzQ@NRde@q_!Ad@|2fH*xp?)< zhyF{Af;>KxUTXzK^?=!74z6ei6Q?*TbCdt)_CR>50=;T`LY&$IA&8jFV9?;}wa#2E z3qZ+w#m``lC2eT}_!kT!5&h*3sD;62vUHwJH^2!uH&5DP)TisE=X*+cbg>M-9#d+W z(q?rN)Mr%8Bt_BhGiFgob?p3v5Yes482vQQlh)L*bs{hON?9yv=#1}&_&*w$MGFNZ z>!_BMYfZ|Z+P&LIm}s-g0be=iB`C`K`NA!zR?++K&t+ly3L^wA&T=VbXfb(C* zGXLDT4kp3!>0sV_eo-23(!w-M{~psNGaw$CS{1a0Z0p0&zrUXJOP@A$Z++$I9x76q z%)@JDWC!R?Dno%z`CDL&$N^`|ym`l-G7_+C?jVT~c#pc;1&Dgvw`u?k%2=VjgHz5g zycolvG)&H|#!MK_*QLXo@&T_NQNL$UD>|P4K0y60_ji|@lP>pmzcHQ%QDk1>e_<(b ztlhHcZ@(4ms{&e;f|TF&MGlRaCd!kE*aHlv3Vng%Euwf}EPyAMAvMC5Tl5Z#xs)p=v~bRF*H<6zdQBI32_mvhtT?ZgUPlc)V)X84##zrU<1IFJQX2_KGxrG zT}_wazWG>pHSqNrl-_R}QJ@@A=XU&pJhnR6T=F`8VbqvxTBB%g!{3`?Nd|r+4a2jG zYg5MB`*Y6-Wji!7ehL*PCb|5db?+}M5_N0TF7{~#u!K8Jyz9O7Z41`xO#NU5mc~c& z_l?@vv9_^QX6Ikhz9sCZkxt|=j+A@3qpX924MrMoJYeC=t-+fNigQLk-v%v z9brBS&7+7qq|vMtA1R~Ok6s^-m@I_H2oo2*KUxT$<)U5l9)CTJy)-pDY@tl5NP`em;EpoEl@}dBboqP*6A>(SY(xy0L@} zhfD~KEMl>|5Cbivmf8h@+PeK-?2Y)Ut{L{|z5eL*I0mQuCY5pNGr%xPg&NC#PMxA8rW0|5RcJcXE@g7j z#dD*r8l z5HRcRQhDx&^O=VDScZsn$AwR}*es&S8O}=Lo?=otgl(7y+We2qrS}E~4zX3byt8nX zFM6qWDW@w4`hVXVXw`S!Dz#kYMg7ETLxPh8MU?PP$7eoH;nb(L3LPz9T2>pXx^jgY z64V|Enr8OI?i!q30+Vd`RyH`BEWo1Vk3or}t|^b=Iz$b#UI6eE8ktP4pqh=}h zW4%-Gbyg|`CWcvi0GjUoO=e@BxN6M#g=3=pt~e;gS&~t0e{iTX?IOLP z`AIDID>j)?{_m5w(|P1Q($|=yLTT`cG12Bf<-Ov>xUg?YT#5aM-RJcG$+qM~xv--? z#RZXp+huK)VOKMTMs!QQ1`ANSoK@~f->C)C) zavu}|Yt(`;o2}MEKY(}yxcp8XpR{(EKLehT|9Cs&suCbB=pXZRn3K@|;lfZGC3*1>j0&AJa#;_tZ*K7aGZ9;5<(IPiqnx|0g4{R&795;v_tthQK z(kHInZ_$cF0d&QZoJ|g-tVK=$$F*MAqb6B|O+hT15NFG=I{qukMw@sVbKbO~sD$JL zRi&1#r9F5Mm1aPe@mn&v`NGDogHw^jZQv4w2LtvYy4g`xxz<#C<{-wF>s!}coUYgN z>htg<*Rl*pkiC@sFst?vuZ6?$h*mz-GKqjjb6&;ci#xMxtN>_@Q1|j`>4S?V=SE1I z@7{cq_^z;`Wz~@zM3w&oVK0d>ffPuRBdZcBmTH6c<9CGOG6qV$ zm*S&?))0}?l>Oz5a@h%5N;vIrC^cvsu~aXHL0p=Dejgeu<|^xSLRs~08y7TzOiO1b zmdtv}o4LAHK5+uTJKnZcrfPMV`9eM+3a~b6{5Cwi(>zP{0HSC6Z-D+m9%9I!4-rU{>1A*!)NHV@K9R{KPxR!$o7VgLrBJ~SqRA(5FIm${z zcU2V|LSI4*)}&9#xO&9y;BnCL;Z!nl086x zz)!s<8opyk&04W)a+mwik(p}x-@LsoP2E_LhC49s)wafJIg@C6&I&g4%xlt6+$WLk z8Vb>{J^?{PtC@Ocw5MUBUGr%tylYUE6jS300n_7B-0#5I}OOJ zaApT{2|c}#5v*vWtRBD|HG9GfiM9T(WoGQ5)X46Y1~;bYoL#H;az?QmC}iBdEJgJc z+hM9{B{+R&bm+h9wO!X7(oSE}$t&j9h&C)o`r6QO9G4;rW{Qb(Ku&}7HihPF*+D2h zXq?Y=uu!=9=B=2QTX7K_dQ>!&*!w7@ZT{~KGYLO3|Loir<6f^AF59@sJboTy;z-DY zitG1eIUxI3aBuh?dn4d5I9XnilGe5_>3Nx1!B-MouhQ)yzEPcAivUaCB!4gtv*{um2zM(X2ZCXlvpnFF*12X@OVW9A?~INx^WzF(c_#=P9J7V=_`JT=CL(Xv zUI|jU|2PgAgq9jlDBGfyDMak7*lXRM@8OX9To45?moH$QnU0fJE${K$Rq$-2^buvp zh<07=)u>7DClt~2(b=*VSch4$Ooed_{1ln7oY{tPUVi+m#)*mIr@;_C_D&xF{O5wO z=fNKUrrQI20%@Y<#1}-V|#J@-1!a_k6_+voJQy3tY#mGDtwMK&ydhwpu*6 zyjpxwPDSb~{cxLD=PopPQl#w{XB>wwONhF#*^pB2TGhLYr8jg!<6LxGF zT?=-g<4S zSt?#-^8ileq%zb~zL!`F&Sb`0K$Lh>?!4Y$wF$0i;ZF9QQlJ9? z6D0Vz{!!*V+Z>1>oMzGy3nn&=PVXgW^`DUk<8DGX4MGB#@SPZwicAnBlYzb@9{H<6 zRWmty?wyBTDfNyT=+gX7Z?Fsl`{l;?N^x>L)`y44Fl4$4toZZlUyRjoQ-oPBp6f0bEQb?bX4e&y zE7Hef>QHH+7K6+AQnzFqdiW~}E#-7V7TwWKV1WaoE(J~+-(!r% z4xGjBRQ9~MzsS}~<^Fm!U!iF!zFQSdsh~A_jtUp_6q^Qgju5ZGe+t@|*A$dp5B$X2 zPt!v|PSD|Hf&7*1uE#`(7d*;}P;187&t>6VYH~PWl?}rI#+Dr&PO}(*qXOEjdh{)> zdj9XG*y(ZcDNEy7{-9!gq$DtAUaGhw9zG$H(m$Kk`265*yOq}Ye<|x>`@VZEy3#&W z)5M!PPC^47awl^q066Om3Ex2ZzPBWT6l~)B z((_hDGjlxzkZcHE#=Nc^R}*4V4TOdpuJfrl3wIA4B}4@ z|7oZSLNZPeh)%Iy(u{!9(mZ-%DHP0AVM+5^*G2L5yBGyI=sp2gdwGO2)8C}MtHohE zQGlz=X0YEHlkuoEXf!;!S23QFlJ6$~%mWYM@XmKUaLAAIlY$rr5XM$UDiO(%zWj10 z)fV7W$1G1!q{VDhE&~@x-|+S^I?$If)yOh+k!HnVAPO6rML3hXat&PsDqNn*;Yt({ zhba$nNvbHI`_29hR-f6f-kU5XN6gNy@4g2U0tI@>^?{ln?ECNHHOv&itS2+gviDLK z-F*cG_B{94w;``h(jeWT;qZh%m6MY44u-k2LosMU4$#3?c0|vu6B%u!-)P3zzVu+T z)m%8(3|L5;;9{G~vkOTgLXL7=iz>u^We#z73N{*XmwX2J6sw)&mBr*!;d(>TOx|6I z+jh!!e;rqJCgZt!jG9yGmsS;e#0LJpO^?zy&@76QeNcVKI!KDJX zqnaASFM4|1dv%1g(BF5cv8s>;1D;le=?({En^Y@u#bQfe!eFB;4(qFC+FL<&GJn8` zk2FjFQt(wv=)&~5TyCiKg#mjQRRt-oE!L2~wB^#VQeMsa} zmqES5O#QmBf8$HK`Kx1n0|EP9c03O}-I9{Et5;wY>%Vt&xq+Pl{G6j*Rl!bY)o#FDX&ntiP$msB_i0n7tX@lyPGAPRY0+i{k?Yu{*ag=b1+CXphA7&Jm2`wXyvQyqi%OOHfePzjvsu+_1AQI_1VxB5T)M_Ssth49( zQUi_e1kCwstiNYQ2EK8@2G=u8)n|l)f;gR9!{cC31`ehe&`$v6VQF!%+w(7v#7Q_T z(Igp5G`iSI5S1ivDPx9ik8EH`!`xeWozF{Y780VlMHEZk{7*ivqHZBkvyig1bKIs< zrG^`)f}%TXqNZuV<)uVbN z!uUcp92`lj)g)asx)VPRYc}|16}c+abQ?|x7_{g;v(gK9ypj#vks!0-;aH>JEO6_~ zgt~-sBM)o8x2^137u>{J?`L7Kp)+XQ88(?lsT5v|W&{z{D|VQ6b&+UKArqTRTY%A! zS>fm1psgtX5_bAaHdejI@egw?t)*8-*Vx_U$595!6yM|ypw;qb_7jNXYT_kp6Jah< z1qA9CV6$2_dWfP_m02w?TkdL-aF$tI`8}b0Dvygv#ZCQVaDOBjlWZU>!|2N4;=DVX z`>`U+uA)5{x^75~d^fbtrAkQqGNZzI2zgJIn&wTWEa;z?55k7sHHpn&Qknu#vV!S+ z#bzWe3YH7-4X!q5FTh>hT{GJY_9NLQx@=fnD`Q&7+sZ7Oz%sB`iFlGHhrUGhKB{9> zoKbfc-UUsy*dIesJnNB!gB#T3t6v81nk0pmyp1Vy#Sn#)uomF`v|UJPDk$d@m`1mN z#va|C`~|@|f#p>>8(en-Z(%FUzG0veKvatY_AzdyPQVIDjhxiW_@bP9E_!Bkyf<1q z+SeO35TGsS2qwgbYpT@tJBgz0WpVk8PeiLOR^R;DY1fgMJae;HWmNCI10=(+pDB%S z4Asg~oj>A4NQcfQ7#qF;TS(V_MDw(~3$_eKiKa0BfVM!oI^`S$Nt z`bnFiP%YSPSXK%P+v!4TBO&+os54+zaa~iL5@^Liu>7Uv{xV~Z8l_nF01QR%q`$Dic3gUE)7HIJ28OHSYpC6c8*6gcJ=keIcjkKI4F7rYNcm&;SwQe z*m}QeW6D%6k%xJ5>jg=j0&iTaaYd{GE$w0yBNc0xHztUeLijm7(ZJ{8YYusoGcP=6 zQetvBtQx&uUj{Guz%3d!|RscEp_(0{+ydKiDU&olf<=%A^cdLL0l_xI(;&oCUtks+sVqH@gv>&?J`VF7 z_ea?nj~dK^zGUYV^H```4Gq^S+zL&c@BQf842<9H(Jr{cbs4}6v9i!X8h zOF!zhJ%vV$9!yay2NC{mAuq*2<^_Gc)n46w0JSr_kWSU{u;4&@>cuVHrpg0`o?wi}*B<);t^$`mM=eI!N3wN9j?>=n8X#Ebj-ZGqS!j z*ctsz*Yb`E@Y>3@6&Ao$IFEW@Eux{?poZOC2^>nxyie;rP@=Q?cCe56kj^LDJOnwj z^f;f3Mzm|_m+YHl#K$*QwV#kU@juM4$QNi+f44&j4Zo-&BSs!VgWAlxw*Ran{X<>k zZi(1sscinh*1_>J84{Bu#r97C71QIQ@Afi@8DIX2lD>Z^WJd01>+pg^VeGf`wtPDu zB~w_s82Qy^8Q$XmRsWkM?NIDm#9}etKjsTTq@=pWOV^JPQ6(yGjjm?SJZ0}Sb}%O5 zh!4zX(c_v1ED>QXzte{Lf{RglhLDBZF6-s4MbYe*xu?`3N9NA=ja_6gXBto2JR#tX zhdTFx`i%uXnwv~@OF%B30z}qTOnIzOJH)+J{$r|-(_WEiu&KbJA)wKy9<$kI>SSa5 zvB!$JqA{Zk^$dd!YgO?h9>}-@7+PL&h*^CjibKVy0{w(>cUz4T=OA!Wk%<~pixodg zgcN(BPeeo&h&RsQE@|cX%F^v3ap!_$CiL8A2|~zE#xqAn+zLF*_P2R<{)oBvy&d`` zyPs@97U~BB+`ciC22!LJYC~9w^YcQj1&iZkWRVJ_M!FI(t9g{`k)detPp|TKILOrE zp-eSmRS-6SESL-PT$K+GB8KvqbvVWVs(sbd)8M=a%koTA77?z3?JK$4JXFzv1)W6@ zp2#)VuA+^(Vs0?)*;eqCigs3$0E`N*rJk@NTPng>*`bo$N823}T0;>9RwTVijnctJ z6K{}?weL@_DMd8+8TUO^4h!MBynSFHl^asZ7K{FxU*h$%aEhOgPM`ZE%lOQt+^+OV zChxc#=fTgLO@`;E+;_rf6s=JH^>K3~0+~F#{?UQRS=SR+PvZgQg-sE|D^&bX%wX}e zHa!h#8CiN6uo?MfGD~Ud47YOHjHV1}1J&Fi1S*C475J@wVBnx>g-v*IoKucutbaY(gzR zM|vf*lp?}{Q=gAjVS8?XT9H?h(N376H6qb)v->t%#OwULN74Y?yqYBIe)b__7d@Ds zF&xJet^3n#J+twcch)Ys_N_pwo^jP-}baMhaI-nO|3y(~4b+$cy}<+obw_(W_Z zBdL&&w?f4sr@Av*77e{g)lN#rGIX4A@ZXM{*D+a&O*Vp3<6sAfftW=#a|;~U_)6P7 zG2aamiZf}Aumi*ucG6|=1W2M*!j03UjUyNSaW7*K{2cMu(~77KRL3|!baqH3-m5Q9 z6f04L#Bwax+#$dT`o>HK!8&=buRK+WoE=RvQ!A|kFHf!_JSJ_t!PmX&yCZ^{;=&l6XE^`R=tPsP1^b5Ba>lKWF)qWWWVQ@r@cplwOKP+P>D4ac{dGsNf|W zDlvYy0|-j^2Ce}}+}>qv5$oFnX(cfAzk@yTJ_uwyS$f!wHGLSuJwhL~Z#aP=57Ppw zJap;94VuuX4A^05B?{Bfhh?n=n}BLF->2+it)jjAyme*%mL_Ir*5codI7>}m%W7qF z#&YSJp`0rdlNxmRLea3xU188vMBnPxoj16WrxWE%qid*_dA5D~JY_2(<N`F2LHWcKXdU-T0&3Etf|+M+GOxgy*o0ZFUhgN=V+J2 z=Pi7|jv-M{pVhUwt0lG&GCLp?xdl52$5X)gEdmCoeo`{?wr98{GDXV{H2V9EoA#7P z7)JeoVD{!p8-O3Lx*cR-iKOa=*DsMC0x^!ARLP(Ig=e|Dwahz>shm7hEXc_Q9l^OT zM+W1z>C%KAr s)F*6%+O?luCYX5 zF>`NjA3w~R2b}Dks*-W4ck(zq0zASTKluozM$g4B{ct3R$Mxk}NtuK#ZIf%0ewnS` zd`1b1jliLO=;Wyu7D-aOZL+ngTG54G5t-pXVB?pOjLoXWxAnN80(cJmf5xC5xwD)Z zjTvT$d^df{$%@qqZ7@w@BfS?+NwM|kecw8K;}dvwv;q^tf(9(2L|8Uz6^MGNv&UpP z&ZAmnZF4^fYgl_89QZ+h`z1y8w0M7y2f!OKhtlaW88Aj)F8flzN=9uJaR@ zt0PuOMd4HRI*gOr0g}SdjdRvO>2d-oC3%S4CXJvV#sRdqY{s}|K&!jn{j@Dk&M(-M zih@5>bD5WPE30Dj(x3%@Na63gtjEa)#w+t?y_|UrSmHeiDBa5G;NS6qZo^@&JtkFe z&q7oJ%5MSz+~sZC?;yH2esJ{5tBU;_VPq2RNG-#4Vh*!UhzVEv=D=n%**)6DAN=i8Tcyt%3lGI8aC`p^1B;$ul%r3au)(-aszCP`_}?Buir=Tq-j zn2Vbw;)9hn1*iZk2GJ%VxsHi*j#I>VjfHt<{gq7MLs1jodfJ^Bum^P9Ur$eA3^`l3 zLYf-pDl+P@!L%*!rzn9RD zQyBf`P#*Sx=1uLouVgC=hLc8bG)RYV+)DJ*T(2_MJJ zG{ZjFrVLp*U$TT(XHEX6b3tY7uTB>hHOSU6`?dfPsMRlOR?ZnD*t4M!y`E8phUyor z)zd=gh90UFDY5#3L~0DqRtzfcsB1v;J3qwrb&{+`UU(kty?u-Onv$OLRNfY3Ng7}c z*Hg5t{d-6WSm=5-*}bP?eB^T5sp3?qfK5v-dlp8M$4%1DY1vQfs&teGVPZzdu17(y zLij4%jSCq%tniB^zYvh+IG^WumZacj=0~b-u(K>WdP{qbCn?6*QGg`PU4V`)aW0b5 z+KmfMpB(QKM9ABkGj1Mnc2my8q=RLU1$%4#p46%UfxN5|AfpcNLZ;eV84~_c6Qeqn zWY!oo$keXrrqjKIW!_3vzQPM&Ns{Zfa1RN^)c-8b&vyaZZp?=cg9Ba9SVpA6=1q@bUC;Vo?;A8Y@_wS3oA304YnORgYK9K+}K+(VDZAG=>&oe;N zU2W99SfRTLaH!ot1`d_3ca|S4P>!x3y|HJlcwdLDeaZu~g1DDxm0BG(-8j5wrz1KX z*h^)?_On}vewVX zjvMnxqsq1P7Vr02Agr#V>ryCINpRh#MjF6cqM%6lOJ1=uC1Mr=I^oPo8?xKHwaw#4 z8M2=*&hoQFe1LqZ?zL^F!F{DWLqV3lQ(g5YpT5k9A8fG|<|@lA+IFBF79q!ft{zXY zHbr?3yU+gZ8NpKIwVtT|LI7p-PZ2BO*WO=tUVY1QxRgj~$o&7mG-xN_LqPriR`p1Z zV(4Lccin`Puox^?6+$XG2FUv)hr{jordk(Bc<-Jc_~?0`D=W=k<8F6aa?YSouyAd- zsDWKmfy#`#VbBGXzwGpuL1kfHYjM0<9SwWd!WLCSnAkd@)Id*Fmf<^y1uYt`Yf2q^ zbUrF?{r}F56`{M<3UlsWepo{XN*z&J`;PFJQ=uOz40n)j!AVtUd%}a-8~aTA;v~Fg z$C^$y(8oBR3$o}Dt4c=Hv&PdGQdD%op1I=%e!M5X#FoRiYW4!K%nni=2GJ4c6l4u; zk>?CrkX}aI6N=JU(HQPBl_!iez0<0fe#5G9P;S?y02OZzPMiN{>?Ja@vxC#_OyOqS8n%n#$sU3N9>BT4P zX^fqUbJ7WYty=>=mBkur+^G=~xpsW8ZsDc|jB=z0h4^0&X*iMIoJSLYB zo{TlxB2=+OmpIt0*%H(w3mK#GTGs^?01d`vT33&bgjo~urKG|mT3lVuP7$5%RU+^F z>hM*=N~&rU!YFt>JdCZkFMww2CCr&%9<4mLB8C>@o7b(4W2-BPbxpv}cSP;p1q}2g z{@!6<3@IL7>o$KJ`m4|g51H1{KotZj*ah!j1|O-voXMx{aGE!6pC5W>O|5LN?Tuf3 zW-AC3^BVZJiC9EkGIy0jKv@N-Xb^utpJuv>d=t7*l+PVf!I%VrxplL#ccM1Kl8R>e zEOtdQ7cc|F%Z!+ySIJUqJ3QxwuT#;j06x%HkL~BGU-eD8-P)6}^+f3)dXy-ZAsG ze<15vE$RV%KO2{mtGb?H^fu++z3T>>vZo;*yF1hg_DOSL+pZQHU@7NS4;CMqrPf}a zaZU^gp@5~Yz7O8DKCx|Q!|4koYyK~;7=?&#!@_ohuOhrHcPNK8%#wL&kpY{?nY~p* z>tulnrPoT#U|TE-+>n3(MIykEpB0Cf5OWm+db!dlcQz6#`_F@ z(7vSNQ}y?G8E#y5ctx?b*sJ-Ooaa?xOuzwSNV6rNIxaVuZt?5P++WE-`mFboWTjvj zRaFCRfH@OLL!L0i@Mq@-stU-Nz@N@oX~3-um=^(?qf2?s43|6!v2Kf80@7ZReMm?~;#o+^(4kRDhV5 zU{R9v{9KARs9nrxHS*JQmuE}%^eSWYHxQ@OHIA%q zr(LXYkEUjv5Q}GfPS>vaP22ZyqN6G!2SnY;u1;;kO*R?YkL;?be62NQZ6s5nYzP9m zVKd<Zam69kgdaBwM&c-sISxl&!Ew;CZ?(BbCUli`7m9uA3O{@Fz{G@-ORp`I_CS}hgZ~)Gm@>)ib{2W%RE+=a( zHbLTu3~D_`-Os}=trI|~f}9p&2V~Ux7=!?@$;;K6PLANzYuwN3jOJ;H=~;Jm8RReh z^>W?`qm+}l_r7kt5D{9=M~3YU2vU38*^`E#9<+mDop@fN2#OK`r!1^rRX1%Uv=C~62!|RjgXAtNHu~vE zgl=~TfkxjpKS4nO$M`XT#teb|yELzh*+*a7$NhbtLAOjkCl((2ZZ0HGeb-+14yJri zMU&lX+M*_(U7Hy|G3!hN)w;x}WWkMNm55xnBd_S{e(*~OZ#dKM9hHaHV+Q0)@yZ(C z#N~Q@G)M;NI?+4o|I=bHu*b%r*tGu_hZrK_aAs}tW3H)lbP>mPh67#eD;r6y@%$p? zW1$f{h!(CM%Fe0TPyxN{n~J{|t}0+#`&MG4@PlY~!Q>F z`hj&-zum;7UYbdJ&TLZ)2l5dQN2yvpS_n zneXfcMaP|634nc!Ml7Jr znQIfk9mw%)IDlzWZp+&&V9WN?){qX_smrNTP8&hE19L=d2&c45!hoYAz1O}}o3CpO zxR^~+{DK_c_Gc)mtN&XTrU_OGm!AT)(ypbzJ2W^P{7 zW3H9R^9E~6kHjab$W(5du($b!hp838R@_#uEk{cMeI`MGZvv|}{}+3$&V-LC?(&3< z(uNE$4gW+Ld_6Tl{B6FR!f|$n_3hY;noH}lD1eL|^mnxq~;%h{RA;q9*s=^ljNIE48#8H_3<|KM|Gt`d#4wR3K%+GM0gjF zAy?KxnC)`V7?DnI*Z5I|@uOnw1>RkCAoA`bH}VAfe8oM@Q;|yhf{-r~7foC4VscB< zA7RP3Ca?zWA6}tZTO+UJ))NE(UNX~RRO$HU8Ro*ddLhJYXpNSg$Jl^=7{z&XyH)l? zp$n*k=CX2YTvFGP8zvGLS_=^AN#qn@|B9`iFY>8fK}WimrbXIFRkxd8;|$=66{spp zVXUU!Nip)6gBBpu#m;7a1NVbaBsptH5G4xuVD-)T2wNr`zGX_{N;b}L4Q+od0lAug z*guTJo9BK9k5H^X4;VLC?1Y=I=sg6+PPkt3`FMLnIg?bYc~_n%U0t9hT9`<{QFBz@ z^YnfA2*V`Cn--q8rfjx0tXHc!kE***V!V@7(gVv8oH=EBZH()~*G!NN?*p8eQEVaE zgou3|eGmgp788dHa@kj-Jr)$XH1bhZjyh}zpL%slLI0BgYx<&C5-BPq+FY52hOIL( zH$mXKP#P$g6Nz=ucMIlC#;cal)}2i;j5jL~{V-fkwSBov7SCg421cg?@M+^Y<20d= z-&wvwKgn_ubf3c6o(w%^C1OpI`C;j9xgr=*CNX3Yy0fr7cQ8|vu^k3ptDd*F%Ngm_cZl*OEl_$6Ouflui z1nYHU;`xT@Dr@8Z5wREtJ@#vY&^1ieLA@pkdK#(045l&OyTUP47Y0ta#@oBhn5sjk zJUhbaKhjg2B1}e41uSq$sq?`9T2y>1?>_Lo8@z6&(&D2pGBoZ?tIRlVec3~L4zfA~xf^7vo zQs7MAb5H27eAzF=>Xom(Q0WbqoM3PXmv{|jSJ*OvrD- ze4)vH@4QuZ1}YX}h62n0QVN}|e`PHD5{~*6#iWEr<|qyp^H)ShZ_m>vICBs9-(NLy zI`Pi=z%kzF{XX&;p3sdG-*(a^s+1ySDQ~;-L zF}2M&8_6SfM$3yAztiT^K}Yw9%%ifNiATrzdh&CgCI!*Z?+CQY|2x^~FIptiY1t$# ze}Ln(S9!}q*fMawh)W2Q=58TKL-B$B-$V`4AnPZI(c-h-C?HV`bkpiTuJhV2$m@U` zFHN(N{E-6^Hy415KU{9LjJi4Q%+sH4zp~bF5eLS~EQN*2{9QoN=_O$$b;CeCZ{!Cn zN&wH;I`-xwP9y|jQH(#PYfS9BsJ(<3B5EApiuRC_H_b1`2rQ(z{ub?Zn8ee{2d zBXxe6r=r6fBuiyj=~IhDMi$T=?fB=ZA;|0e3F^Vdu2P{) z(&fmk6>qkpu8EKs;X007b9LaXG!H#}-v(7)A6ML|b1x@aNDdsi#gZv}hn44%=JKyg zkz$)=W^S*-IErx|!#Gi?)Q;7z#3-e|5e~XJqT*!$(rypC=;_{>7gO@$SC)ElAn=S| zqi1t-879XO^t7I;y5a44;nQ=(cgqYwjYcdfG0T%{2QKFifv40N$iMFsE0Zj>lcKEx zj%mp9q0N>O=iXaJ|JnloNE!8Oygbyc5xN#XR}){H3SqIoICAG^9E|MQF3FzBFyMKU zGQx+H_?!n}s&dZJe|_|IW208&$DfLD2wk#1;pXOh2 zbGi_hj*?9EFK1vaIpluRR2M)7dDT=D80|=`dXp4=PwXc&ndF+Mi^)Py2qdfm0Cgpb z_AoJNKFxqbNNhTawbE9^2-Tu6AJrV!^<>~?tM)S;<7KrBo-&n$znX9X_!NWbyLhY~p3I{X5S*GF;9Wx9XyNLD+i+qPqq4v7!CG;Cz$CA#mYo7S) zk<@1*YpFsy;h#-xexUVI@NLbqujFTD!2nOWS;&n<6qAz>pmD{e2qz-x#OZ^EB;)BWCY z^!lPkN!&`J6@lJwi*(`!ujOTp)pN0`T$1P2(qb2n(%frsL#E2t#-|EAFc{yw9~MJo zj%qx*cjRyZPwl=5z!an{PP4~InI$BNY0IExC->lK(D!;1{0*XV9h}Ca_CJJ{(o}=w zS>7!EBQURf`izITTdI_WJO<-zV!z;8D0rKYISfFR+2SDTF~(@cpVWXD)2{1z$K8xGJ^#AzR-73y?dy$=F}N{?b6jh|SGoNwVj zRc8FeuB;C{sg+``mk@zBmF=DVHU-_F9BFC%GCK4xLp2IsJ>RMN=fGFB1DSRnWONv| z4)QwALXjUyt_!_&N6hq!PbBXpX{wdSoYBl_w!T?ZyxXw{b0-H|QO)b7aelDi+5|!o zjZEOth0Ri_QW8?#GilnS*74(=c10&hgmjL7XC3y)o=sUywP_`-Z&Li9<{WXqXPvOr;aFW&>70CmqoRz8OZdVkTX6;`%=DB6|VwO}+}U z;E)g7NmpImkY+VX$q7oqi3#bC2iUQq2Smo|qZq-Dccj_hBrK?}eCz8yCWa$;mFKC{ zbfq$jrUP#AU}un17%Se$CXav7o}GKS1DRk4>?p zKq0O~{kgDuwb=6&J2Nm1pxe9bicW0Qg6j8vm)v{EA7*uwgLDf!IWnB1YHql+=cnMv zmV;3K-u*t3aQyybd-*n07qEgeywm&6>z%WyoJa6t_iVNDj*-W#=k9-)!atiwOzHZkMPR|a^>GQy`L==Ho_qUxBtQz3HG-uB2MxF;> zXUCNmxEVVOQ0OEh%IXf38&gK1Y6TTa!TK2Ob_U^QzUSZDF z5wW>JI&N{?uAuN+)G?7)^Y;nVa&JYK^u0B{Pe*wE->8H5|5o~&g8?kk{b&zb7 zpA;QbzEuocM&zGG7g!<%H{tInx!d*1B9m43erI|qE(#WRzW(jMWT20az=6^wf zyP=R^GbYft&QXNv$o`2>P^?FN^ZHBC{0Dv3oLJ)ZWNko?0tjALPfXb|0aI_5RDx7p z)rA?^?>5LJTTXcptScz1ICht;2EzweC>`Ctc0Sj6=qaZa+;j$%p-0n@_TJvs8*o{` zR;0TE2m&di4RGl5)q+3jo{s!T_p|gUm8a}VLvYMmjOW7^nPuP5hj|_ze_BgDvv{9f zN6v+`1^I}U$DDhVQynMgCSD|#pSDdJijpl#KVm%-Kgdcv{g4g*y<&9=R9vLUgx-gY zZ5JFC6>$sQ8~(nq=6~`fa{vE7SR*GfgQS)Dw2&+&n%@z_211>zrLFKbfsRF}AjK>S zW5xJ$=VB8#w8O>1O&{o(-0 zj%Knt$d}sF9!$N_Z^n?qXc$eGZ^O>rwI74-FYU}%Qfj#)5Nsb}ysSk%ea{=zuKr8l zv8@SdGhW`0F9DyO2ak6?LxEI#BXI|O99F|l1>rPA#-)k;ra>?uZ`!*n#!`FU9SvW1 zCcuG*2TG#s8ii{uT8At z4*pWPI#Ij*3=y`8EFf zLgWjl@=Rl*g@ct+9ohZ@)%09&oZ_bVw&{a-nBT0FZta%fW6#JKX3Z*uk#@ma2O7wC zdOYi5a>dwfyLtEvGfjXR{Zojjt;oAnQE;qKB$}?Yk%^OpCAM7sD1iDZGvhkLBRO?v zK4*id&PmO7R|Dbz3>z&%An5FFS@Z%zx>Q*s(Hlew5))e-QqWx-hmxV}v*c*We!5Dz z;e2~S4=F(lxIM@pm^HM@Hw1>Azt{1ae!^Jl9ZB?7PpkQQ^P48mHAE7jPWrP(I<7R% zDN?c7IHR2?HPMIKu=ztps`%cs{F*l$&_4z`yv9Bh6Hcd$;2k~*XTG!A;AF%%W}&wPbT z%+TojnscGSD-m|26_dOuegn!07=$4a1P|JkPog`7Vl4b~i5tPVjMV|O=_cw_heq(y z2vnBMr8a<7x^L&Lvc#2Vn4>-g{?YywBhjD$$|p_t00L#wb$gO;;4>as*B+-&X(~)$ z6#y3iNLZ<9)nKvSP;uB2D)g$1D#*XWRb>L(++L)y9MW;a6 zsL}G9t+*Y|;uRy3v&+`HPTg_P^?LggGy&7-)iRFqHT+sz0*Yq>%za3fnJ7J-@?xeUX`szceldDvm@b$6n8v{KLjY|Yrc@Z}xs7pLa&Ib(E zw%4m6W-{oJwf``&h)5^0ze4Glm%dfnkYFj3*WOkAeaQr!Aj07;sTi`KpH{>a9YK;E zo#TX}8|oBv4A1x)01H)-HX-&9jGnZdc>@@n?pn~BPbaF?POhx;iw}U8Em^8~Mdh8( zgp)GSt@v7Z)wul(e3`AnJ`t3iE5LrKNWK&80vgMv6^!xNiC)v8%m$QTMVddtKWm`q z6VCsAb;P5?{f*8Ic&;JL{D5L`n&v6mF^aeTZf8@H*4-MY>!lwN3d#EUENp>c6z0~^ zZ-g)eGX>+-lot_S<%Q*`gwoX|s~k6sXpcU6!#cX{oM`9V*7?YgrpfEeFO^4vV#@hZ z=@tOVzdS;YT{7JdDL0r;DWM}%Ni5disqNwdx^~;~0>-gGUx;+CflquFyMh)&Xa}ZT zq-liSCF>?7Oz2JCJ9w;Kw(w%PzMZGU3@~-MFbk)`)dS8*zQ=Zz8vWgzAyKw_LM$#- zAhjonxX+_twbVuxo=OtvgUwkq9}O9_z>H%U)rNICFrc7*u274VwEPtPRiwdioT^7< z(>J9{`oGl)?|Ux?At@V60ybChmc zD1WpB-^p;el%M(D1Jx1~HbKhB{)Dv|GFO_U42KkZ6(McH6ETE>hMTB5`s;!$#XDA` zw>1C)Xt9D?sesL__0gYqz@Pm6kkqF@nWM(U+m}l1a}^$7&~Z!f zd^*8PIQG^wPo?}pU_pA?X@pDTYxs%JoVY_H{V|`l3xJ$-#jjoEV+1uVx=>rg`#JrU zqY9}OOucxYC58L-n`Mrst)UnjJb>g)NS_YRszT!Z0JS1(8iA>7kg!@ZgG;E7#9A_O z1dLW!F~ZY@f8_f0;G9dVZRmRECn9n#!Ps$rh2#A+b`!gz$=9W<_nuGpullSQt#<3f z{L9fLTxkdp#1_z*7-RZF`Qhumj&;0^mDKlb^ApjBusEq~prCna3s=_VuxojeHVVJ$ z526j8GJ)?G;6G1lduefA8{&I4n)e?>X2@K4YKx~9LzU|}z*)h5x;~uGz}ja?R3@D4 zvbE*U7p2bS0465dH?crFJSY@@s4{=BYcJHS)E4t`nWv0{(yFnGju~CqhL5iMT-GM{ z*_6--D%CW+gD2Ky2<^L`jy;B}R=_rc^(`PP#^|56)JuJCMb&F{CsJ@^b8)R|96A>J z$%6XKe9e^+NDH))R&R$ckSAzNtPfA1^N@Ku>KY}IwD=_9d0%25I8zye@*(YiJGg=P zJbxl$P2qzDg>fw>-laM^Qo_nAzM8JmL34hiDTK-I%X^4OH@u zz|x{*cC{*;cB1zeyxt)8>gq#N$en?y-f!#p#t~^O>BM7RqKS9;5%|BcCBBtk1M_a& zW_<R_L_K8-a&Ogzgp)S7QY{h+4)^4|>}x zk>GT$n?csydB+)V5AM{zOB^P20I_y9qw0wZ&tu>`n7} zT;dGThhm|sJE8`8h{F`Yo*WwiU_?Ba8;0*Ls^>Fx=B@oHDMyiupNeIq1yclKw{+_c z$iOTmF-j3ZJKX_f)bu`IFRUWy;7P|s-1&6`F7AYXUe_MegZ>J?4!Gr6ow%=w8idfFI4{UtdE& zn;N&l$+ErseGN^+(_fwPcR}t);*xIB^}*GyDj%m}qBvfz@(MyDHTjJ`ccA1c&_LEl zjK_9bt=_fohA9Wv$@E%Z5vXvxmj=96yQO^XTB1^i@O53L6TJ_gzC7n>M@+esV+_}V zuF`2wx<|Ydg0Pt!T;CA>ScX25X{T2@caJ$dXoC|iZp(=dCo2+koKYDVQsdaHsyOC_ zQ3XVW5$O5@pdTOme0*$f?NDAM>)c{>j`L+$>bAng$hlZ?RK0@ww>lWU>6w2y z^2v(q$LG~R=@Yc7mp(_{+^|3w`#a{L#(^XAXln!^^^QAHf3j6=Yur6JWStBkb|&X z?9JsACH%0?LUHW7>74xwtgg>y2m-cYsmySflsP=#_hrH)R>UJL7C7kQ{`fYGsD&Iu zLDr;l$&355>|VXe)bVf+U>1MrG&Ueqfb%c;UX8Dt9lMoHE1NkL8@8vhDL2y^5+Q_I zb57qs2!aDV>!J)3w)r_}+vaQf@oVCaNf~^C`x51KAMwint5m<(X^}Q1v?MFieE5gE>f-c? zZ4Fwrp6Zx(lGbmy4OY5rGx6y3Ceu}v>Kj9Ab=||#?A(?9U^D|F*|J~bCBJu2FD>K6 z1aZsw;TE_!8?s2 zj8b~doKBZe4QoLm*#3bL{+l#J1q;)kFp{x6Ng8zAytw<)u;qY{SJ^ONQgDOuC6#)% zc;YbVd_xQQ(9<;e_G%t>+0UlbZK^L}(0uuyR&)3=>2ScsZ&!^V#YB(qIYHic>dI~y z4ZM=nqZezX4sw%C3lsiC!t989g%_bgeaB*k0D}^jJHa$UH4|mZz>c1ioRDc)Uh02C zgS>^#2wP|+r!{z*y|Z(A-k~lZBvIpk&N!a#DI2!LHz9pNI9i&yE62J%woz&}rgiSc z`xB*l*J2!)?Sf8;Wg>PYW%;van_Vg0e(7JR`-T!=sBSXypfm!W7uZSso;2Px z?&_!x86oztqw=-S0eTX18}PB0`?;{48eyd=@SW@x+{ z8!@bCr{mZTBsKnS)OP8YZglLL26T+$j?8}Z+n(Fp;LlsDX!fw>wWjGZo?fPCyFUUSI$2y2Jy|_^D+pr@@0lZd#y{d6AaC`- z6T(QX&(Uqm-oV*U8zY_A`C1H7J(kgC8mU&NEV0gk)L9@F_IDjwGm0Dy^0KG*<6vAQW2 z@)opzBBEBtLX`cVi}JuyES?0Y;SuqFJ!zrSC|1H@jVmLiOSN~ zzNWok0aAffek?DBs{nNEV=E6{bbSjVC)>($7Nw1V@LBP24i>ERp=!Nm*J6aIqfp&o z75Y<_9#a-__Zp%Vc2t{a9ohPr{>(j{c|hGQVtSw!T);OmwmS&0VL%EI%(a254b*FF zPI<*6auUjPJhjSjhWyB2s3)1=9R#krl*=I$IA*0P4A90;v#CKEPgka#8<*l|PXMuuzc5GHwSu7c zoRtJ!4AgPcm-Heo({OzeMfs>|(6-3))!;K;Fx&K^L7wEIDcQf&5zB^I*j*lGJ=?~U z2yj2!Fy40Upp442T^^hNOMxvqRh6WZ;{|co;d=&#r5IzXKc@voY`skggyEwn4#KE6kdI9 zmcY4+Eng9gMf=#Y#CJR?19g&p2t*(o^=yNHm7<{7T?Qta=Ck6oRoD%?WvFl*U-8(8s01I#JWOg&J=-M+M-&?f^dBaw1w)lQysT$ zvWh1+iZlJy2p2&X{uu-)@oH>w}AfY66ML@qSvtmGX;tpWR>$q4=aCtM22o{em` zn3i`l6Yv4Y2oVg8V4$iu$C??@jk#jH9GN!m+%9>zs%1ekl^!h~X7x_b0t~oYO{gMi z>qJQ%<~WUis=Sg{L@Jn63%zlK`xm+eqY;NW z3j|i}7#bivIs3-`CeczEHu`VJar^u<7o{0uY}m{{jbesAS4PVgI*Rt9(GjqU>e130*X(9?hFN7YUb)=<5xixJJA6a1}6pu z&Xra1IsXO)MBqw4J4`aw2xwKo)Gg|vo{#$u@l!{1Uc(3mVu7tsWsc`C5)jp8hT)wDHLiQSum*l*D?OeQh8^njY~^uS&(Eo>lPA*pbS0BZiefCY`0qs~_8aH%-l6M^`Bh{n!Yt&W(#|8>gn%5`D&WODqr8Fnruc?1| ze^G;ChdRM)mRG*k#tyHq=;QD(l(Kzavd^kjKz2XX#K12;M8+WDJwNm>=)VnU!;(A9 zpuv3iDrlWT0E-)RIK~m+b1@f7m$dGp2SWJpw0up3rM(K&R~yO^e~i#g1~RXg0Ox<1*?Ea}!~# zl~fb|&E(VBgSQl!51?Ar^OG-_pKBfYEY6Q~yw;Gh8RG8UO%43&pA?{|?UIZ?K|zmI=U|EuyJYUtvuL2vnDJ$mG6NA?0tlTnaw zN&jg0NPH`(FPF2%Y&0ChiVeZ1n(!Q)uw93F zt7Z`P0!D$fes5cNWXB%qK_HP;JIsWBlobmc$9wIFs=a#5^#lGvq``yHdL@Q4%Q0iQ zY`noE&tmz#ZmrpR@C2i=v&|K$v0AoLfh)9V0rZY5np8c5C|6)7`iStIuruzSGM(AT zkA{=6AEBE;mfna4Z}GBeR1a>Ux+{s$AJ|D(4?UlUsxdqZ_mM}fYhQ%^RY2o7_m#v& z!9SBB-~Qxu35eiZl+Z$=V89w%7M_k?1t4jX4Ds@<#d)67Y_q{%HZOy<>hj$@Ch!ll3L#S=t|e;TLwbbC_++(bIkA)AX5E?0k5j(e63QO5AqKUvpR zP3mV%4L~ek)g#|>5^YR$GG>x+%^ED4;>RPj*Mfdmq9Db3XQQ)5SPJy+(v2Ys3IEu@ zE*+pt6Ku%EHaaGS@w!38?>;?^w7pmwEcz0xTI_#xH}My#BzV3r*QMv}SI8tV9Lk!F^3Cs%|~h(4x$4 zh)vpQ8B;(A)2kZXyfU=7-AiceRUthJ>05ILb9W!Reh4^PsRUwNEdzk;FL1cVo?>A< zx9|vG%7>KO145tNIo^ioz=}~x;8BQq0+98OIE)~GChYjGDH`=UMMuR9XtU_lr0pde zDJ83LBZ|0Fi%^1?F(|5}h~BjC#j#HzmYchDH)i3z)|NmcY^tQUQ|Bf`;%c!E{?Cu| zDZzAbieiK`DW1^UeW{$T;k1W`urPA%N$pmajWrqIZd8>Nl;ot=;SEO!v4{6-;BVX$j_ zN>oHtqu#fj!Op4c>CKZ8k*X59yb2H&mw7X!QK-ds0FbDYQs^R4fACd+^pz#|c=X2V zuT7UejHCo^BSl!sDK4AYp$wXJQ~Ib?xxPiRKUbZbPjZ#Pt_VW5FP&rOl@Nyr)oRs- zqEz<~G+DP_SsmxZ(rI6?v(W!Dm-|#DrwiH(ggP&)nm0*&9~zf}1rxS5*MZCzR`uzJ zX`xV1@>USbe};Z!mMURZx2Sw}Bu^U8cVD(=EBF09&jnvj@CihRAKQ77)L zXWTkASn7Jh1aI_liHFOrNr!%ZO;HU3vOg_u9(J7OQy=Zr_GL#y8DgpstgL7VEY00> z4F{r|b>1T6H`??XsKOV67GY+`cFAQ-c8NW&EA}2RDuV4VwRuIC<*XOpk1%u#nQxY5 zr`@>Dy;HOr{M%c8ux2Cs;eLu%<9DQSX^IU&pS>q1A(Y+PdwpNvyAkdwLDC}nrOifh zi07ny?8Ei^{-@A{FAjlSr?I!{VDUeMl;LUli0j@4&Op^F&Z%p%n3=yoI_=fK_D7Jk zM<(khGIJI&bk1e4STbwE1|DSc#`fM3%(A^2ncGtQM-f3ExGlxlx8r&%QjPy5+aCSl za((OoMn1r#vj zK?iabH2#QuLd{U4$h{XUhy#Du)!mnR0%{TFE6Bl@6vMIBu75$cU4Z04+Y8hs zPw&n+EXTqe84Lb&!E;-RRlB+%u7GA;btyopZPx9j;dx&yjJ!r0S7WzG1><#Uk=;K( zSPBL30^G~fkxf?t@bTrsr62rTw+FyFH>c-ZWK*cI?94uV;mtu5-=Jz+C8&jIjJgXn zudok5%**b2{+hnp*zR!0)JGbq8902}rEV%1c2pRd(RM9(kFq}>8_)dz8@&Wm-ElsC zvygH`Hq!>jMtUmPSg5>V8X3KdReCY83WHjaJ z{=?Nn<)U|3ozo@frV@386?62sBlqui;J9B%`-|A7Ak1fKVrCaIi+i@}$66q7I{Nan zS%S7%>=#707_y|MaA?W7E@gttE{3wi9iW90H%?+JgmMoIyfCylrr7aD5eEXaapo6k ztY08kNRYOhxR*t6-`^xp43tixhs*a6815cL;Q0mf@1ANq5h zj%>}nw-P1{M0xYjq7vp%-C(;PUvGf&SHPxG+%zvh?dBf#K zhx<+f?%c;VHMO*Cn84rx((P=rf>P}+b5Yeo?;C_y;trHMyPwvCh6r8Zm)=4 zO>#SAs;p#Vfz-N`k~-6adWJ$$K*LVU%(gD=pP9{0{nV!U2uS%p(PG^GQ^cQVRo%;un!pI-RK|q5Om&-P zd}ot{)$z;eV2Px6n{j$e`y63fnb|8MZ)w)UmUf7f|MKQKtiZRkk){fs>!o@JSxQ0U z#v{-)KtE75hHGz;j!CHt{bz^95Esw8NSp#3(T^(2?eIMY0S?0AH`?*X={QO#nF-$O zw0F70hmCg7!mG{XUyy`A<)r&Al46(li|Je6R$pMNO22SbIH&3%DG)7DbUBM_OOo-N zCG4L=y5mCguF?SFj^2(Mpg&$VNRFfG?5ta7_B^F(pW?~X672}J&Ow=gGR_15da8#r zz+2W&pu2WDB;x4_+P<+Xoyu1E8=*1E5-3jJy4m!=Mf2NI&_^A9T7ktL@zwBVQBRPZ zjnx6dhNJ`;xGNPUvc6FXuHAwo~R?SA9l&JVn!`nf>QQ{TcF?;k{z~m z_A;|+8j5ZgNi$=Fg}Sz6%jXDn%1RabgAWViQB3w>6SO|Ka+tVu6*BO!pLX>JaW-8Cgf9^(T(IkKx_bwD6tJYX-6!u)`Wqv z5I|ZFlEW@}=7Y)OaU8t`yeO$AAxl1eDF4eEnEY+e`wH@Np{CG)2A-s%vFED5IuO=> z6abL5rynld=(M#hGiyAq(rt`swh6#YB6SG!#ZY{ln04YGm5Y)Dcd8o}p5P2dqow$? zXm;|r-U||k7~@h*B2+K$?D@|-j62ZM=Sb035QNE`MwmPVK`F z&%;05v&p=6KB_itKt;H@ZJg{awRFhYHrXOyOKhm6hbGlCExInLj8fLafJ;` zur~Jhf4GvLgan!Y6P*v^ftPZ%BYM6*$ux5|XamAtFzx9L61fSnx-9%smOkh-#@CWAd=A4un9m~&7dJ5|VK4-Tue&7YO< zGP#To3&T=Trx;q3cyYUTsPG(b_bGM~cU!^Z5+{0Wjp3r{yJl~FmNJs&(K zj=dr#C>+M?{RASx{p~D;NR;OHRt)Hc{4^s5a@EgkA8>1<;0SS+kD&)-TOmq&=VW}(| zw#6$#ZvdcwwAKrZC3;52vOAh$Iusge&r+G?V{?XsW)H)s5mPekcoDCxn?V_)XBG-s zN|rzz3X=FMJ!3Wv=3w?S_BoehFyOg;d zQ&o(abW*Y9T95?^tar0o6Pj%cq?e%d9f&x{if~XWnBuY@ux1B9WSq2khwN>+eWj2yxLrEL%pS#e`sly8{Fd-_MSw@(t9o(twTA_2! z$$$QGXdL#<{}#M2eks&Z&^<=LnDC7VA6WYgKLw)x(k0AkmZMbF^=bM%UF{z(XspUl z4a^ABuS#_&@R^@%S98>yJ^Qvy0tF%tqhsr16hN+g)k|Por~z%Vm|on9-y8@m?7zDR z5h~*o_{Y+k%GW_9p}A;82D}K+9y?Sv_NeAsyJGST6*rIO=>NnTk?RWvegdOaYGVd5 zsW3ZvWdYQF959@?j9xmU7%8A*;nNiX*uu7%)y&Zrpc;-DWJ;y8%sf<>WWHvd30A?i zHZT2L(o{B;0hrj7D7ox;Hi!43Ki^w68!9LN29p_+Ed9F=B~+*3PEFm*A*9kI#$gih zVImihzt2UsQ$jp~)U{|dQY)h^>b^6|l#*v!679(&4Q^#?KV`G&{3Uh0yE2|^(LR}e z1nPrhMckM^U+33hhU^x9O`tn1;)cOhOGcDwqx}Gv($tl5B##a54WgvqKF|P3Xx|a2 zS`sW>ywX+Yv^~;%gvxqNeV6iGs*x+J-ZuSELghtU&~V0xQfJ`xiv*zDVbKGIAlVRUom5`vMDfIFK^ODvi5(eL3Qhj0T4+S}BE8I*78)~2 zI674hblz@5$)CwVAt=3_&&8BMuObd{kii4&&kdIm?i*?ZnuINgfS2v)AH~0MD*i?P zpIZOe2RNe^xv8mvsYHt`0cW^MC@ln1OO=ufb=G(TWZCpGo`oLZ%Gd zdil!`8@~v&FPi%`zz)K`{g&UWunHd1(4dhCdm4#uI4CaAfU)sW!_UqZOllMe+#o^M zJIzT;C&2-cHH1}kd-WA~svp7B2Hg0#|HIf|isa82{Gkg#>{GJL_ZZFz`>pQ& z@^e{+yz9oOf8mA#sG$P~okMLQM#9#${h~>f~z6g#d6 zryE%;F3_~lpZ6(Uf~l{2RPGo!*7WCLLVu}~s}Fj+nbUTz?ID#A9S&NY%$flzw2o}1 zPw-hzZ46eOx+h|N^%7pKyfT*zN3dz~-$*)_2-HVT=Ptg{Df?!n!r<=JfEH#RD?Ue1f<^T)l6&-0IaP?}-=WFarVecGOof3IvOzi>-#;y^u|tuO`E)^B_WD=L z9QHk?3;R1Cmg{vJJ9w{`jd@m3)tacE)`1Vfe$}w3wj(&dsl$MQTKD-%&KVu7MQ9$; zB#>Tg1P#(nIeVVNa?XicTsa=p^3Sfc3wF2xz&%>JVPRPhC}}hSvpm`9QTN^o4_)UG ztu`1x7Fp}kCl`i3g;CWT6c`w0b3#byS2|8m+u6#?YE$p(_dZ9GXmS7mQdcsL6`9XJ zUeA3e8yK5YXgXXdZm0sybaQmTMD-FPX&s6H;~*XG-HY$aV4pnEiG>~s*KLPpoXpTe zPSpy4TnQ&15aH_@{$?8nk$t8Ev#2m3Lw8_Px#nT?34cRhIA^3HilY1zm{H}aY< z?z}zb#{Eol({Qzx+0beJw=_B)+?bOOjlt-Upo#Q{R`|X>eCB4u}EcCiTgCgusH|(Gv zKn$05d>T;V2+iK`|5!=1<%VdWfl{`wVD)6%azBv3-tI@j5$8J%0Jugr4LI(?Nng2R zODoHn%AK7)3jG2Bn#JL%Y6l7^BN9w(P{d+zi0y(RWeS;+l+2Uf!Kc}jX@aVaUaOV7 zOo%~UmL#bhxh;uLH(3schFBY7*nx^EvGv8T;~h9$4sWZ_#Y z!tir8FXMAYBk1M4-|21U8wQ%M(9+01$VAoQaO#qHieR}KimyUCdH=2xo5|4@|L%r0JY=*a$ z#+l~VSF(}%iZCqJ#ZIq~r6peIn`?aQx$}rxrgKU3#4x{?m=Q4#M3e9sTycvb;5AHD zL&=s+H?@!_Z@nJ8gdWLqEf+>Xp?Xnkb6FH z{7U829wIb!(K|p<6NOFMtF{rri-x%k)L)2=?vMhEt4?1QPW6N^v2{8tYVl51CXfi5 z(Kc)mLc7je7n;WNTNGX6jp=bUr-q#3UDFIB6n7*2b7gr-N0beTIIe^KK9F}-&c zt&{RO9N=|mk8z^e&;QFpq}Im3!G=#MVx3Tm6+q!XsSjOQx-+Oom=*hCVXPwQ7fhzi zwO)EPq?oKcpXyG2&l6I==je@7clH#DuSIh)RIU2Vo(w6Q4Nhvad+W@!Xnw?P!JllF zOhgARGCCcUycd$9fw{X$Z{Pux+c1&2iRo#`?)5keRQ82`Q$ov*ni6lEZFsejF9mTi zibIPpV?mRF6}z%Nk0m$aNejUdf>Xj|z}*P!11e;WexMj|K&5cwmHg^t=EA_)^(aqPheL-y%WbMv4;0JPwU2F%Xk^%@&wSJl!aEdP>rUFlwJ*kg@ueXw1p52HTeV-Vhq9590d z{{t!YsgWv7fV(#tfv^9=SK?ZU@a~$I0t=p+FY9Now9{T^q}Ap-igmiBy%yARx0otv zRaYAqf&J}+;DO_N&isFNI>Y4rDPPu|-(UDdnv6<&&n8{l(yUY#_WW35_#5+oV{nZc zGuuC>PA%!eg7S}9r}RX`I%-7(*?W)LVSPS6L6{xLJby(<%im+B=kqY<3?%Bv6z;&A zfAaVQE#(TP`2eZGiK1}@-vRuNXr38k0!Q%QJrfWC0ucjK3Zy^x-b1zIj~B=KcqM`f zf{8^1xwrW9lS!oTPwtkGe5CoYnP$>djLOmnTk|k*EA?FEz=Mdl0baaJ zXq`oD0Ls@IMK|^S@D>e;s1EQCjmLz(NGd^1fP}$Lh{z~8REVM~IZz=&i3eaQ%(Zu? zC}MW|wf_Dk0y?t+EDFf0dCz6W@0}k7lLuBo95Z6G=O7UVLG88<)WNMfq=*Ac+$9qE zLZ?Q%m-K`YE%he*B~ugr9{829y28wK)&r^KKTgY_ug8I>6a7+61xj$Qa}vvh80ViQ$PVUOS)CDSdO zyrCo~J0GdB0n@R51b}i4%}&{j zKX6Ew#WQjm%oEIQ%u0o*u77ZsZkqM?w@-8rz8_t9AHF2$kbRc;E!~`z!bnF3F91uZ z!P`!_?mgJuS)pySr>;s_U{tLAi^ppsi>E8Kd-SQ`sFR-9iy*W03 znud72pclo6w`^VSwh5<62&skDQ~qc|#b+H66%8a9tUR!HZNQEmW@7l+Ky<*<9Orv| zpnW*&UCb7l+8Elfx?^B2vN+WLhr4%PVylHjWo25+nz#$-$|)tfH>Ni|UGg#LgSLg9 z_F|3iGy4tCyPkJR4i!trp{tEnTW76C?64&yPSX!09I%1MHtdos7VLhOCKm6<#%-`R zuGsOAbFtRn)N_)2^R32cWX}}3T*jE1bJJJyr;Flhbhbr4=Br$EF*&spN%>q-B0Vtw z0f#G1t=6-CKINd-aXkFPt~8ziOy-{=G?{#W%y~;5qI%;dVbS@JLb=(H`I#;bg1ho3 zsIV9YQ3%_rMhXOKCUPSE(4Wg9z-ElMZE@Yha^E_wQ_yCQ{UD;Ak^MeM|$hirUN&wjdR)B&6X7$VW3c#qm zLCnoan`|ktDmppYFe7+8rkhGju$=-BeO(Q`2b(SWyDvAk(<$C5AthGdrdzvE)|bOf zcu)S5>RxQt0~E3JjdGPlsnBMn&za##E|xUxZeebd-OORCY^X8uAXYjbO(o>jCuw@Z zQFFS3vAE@m!(p8=@H=fEXfhAS4Tl&3hYY+#@7LyGMxpIe#a2eg{4mURLWXlb3Lk84 zN+G!kPBX#8DA^@^!f&mUjw9|(7|L%KIp|D6c15o5dO(&Lxc9;?4q67+EC={odZdB{ zFNJ-xzbH+_x#Es}0Oa5)5!@Mc@bp@o`AQYZZc?Fd`x}DKwup7{Y$NbuogT`Mi)M9$ zQi^;tL(Bq)qvSfJjXW&sk$I3u#318#6-SKt@xsX~65o2#ev00(i{BZPEKNsQ7BvuW z18mtEo~m88AZDZNjxMY?LHu|$>1LM5?U{-=i!X`1l!6g6qRXcW{#TC1hg?if-$OAK z=Zp0EGJNR`d=NVRco3(Lkl`+oxH6egqRKCL-B<^yv@fxX-tb57DyGcRt4WTQ^7g3L z@$dnJc5AJWn)W2#dl{==0W}B{XiVqVNs@T8f(*APJvCS7A~>RI|8tids5xf8A?2n! z0HLF>quqc;w=jPsWJ^VP3(8c*eG0DMq3@1Nl1V*bR7m_%i~Pl6sx1H*0ZUnU+CKl_ zm3>p=Bp*US6n|5Gyfa49I zWxr3IcLxBYpMhwhqce_{h>NRQR=>JOs=mbYiZZ-f?v3) z++J)}n!SG^C^FaO<;6 z*H!3a3iD0nic?5oU(q2!F=LyH5()j0vgchY!H*U}y4|!$R+b@-_sd?(LD{u$Dk5Ek zl<5G{$qqL8MZGlF{YgH|F4@_9pPN++0mU670Snb;v4rnAQbiD>aa8i zSN?f0jni+m5O)^7;7ei_;=<}=(-0sb8q&zoRw5tfsJh92tP9tMpH1F7-o1n7>@Ui+ znf2NOBi5B-K?Xw)!|&WP-OFB9YF#ORQ+l*PRWbJdw-`re%KkB-OEXUhsQY3pMe|%)sa@zWvXb2v*hb<^6Jpwc zV2$1pWSFN{-MfKN3xR3g-A<4Tg%g~HtOZOF3Qlo9MFLzuc_IqNk?BMkDp{$mk(Qyf z|9vib*Ru2=V7xs^TQP`n?ce?oapbRHQU0KCwfX-=saD(?e_RbBRj3071OzowHe}0Z zCKBx7N|T8HayA0qXNzwqyU8vcDqK-@*W$aTMY^u+g)EVO_ZoP%*epWQMOZ|ozHPb9 z-5(g+^ia#bt3@`;1J(q>XPdAKBfMisr4#0%N5%#{0^2`9SxnVbQ-t+Y9I`Bs9`fau$-VQGwRLF9Uyqwe3eSdBIjb`9x&AvQ-<#+X zMzts&@}9h{a~VZAGP+aPQjGu8EXnOP)Ll@_39fE>hJEQj$a$1m7Ixe)kK|*$+nki) ziP@a&sp|EdM{9QD<@CnxgF354!dVrvtnjbPz-{O+H}%mB3lqzyH{gw4Arc}z5>%DW z%G3zo%o|f37oe@|DO@$v)A$Cng@sAKu=M(<@{(ce1D2Smx>rM}kN(sRFb~S%C*TD# zU!W-JW}-9Cnp@Hct+YV!8YGTH{EU{Y$OUx`k*{ZsrNlc|`Y0)DK6%{Ccd}2XKM!$k z@h%K3*9}t+ZFeYpwnwe)I)F%X(;_0vFyL-+^NWBY*2}3;#jr+A@iZqFcCJ9Fq-{#f z9#yOLGu2^=Q1At>(|7|nyu;CWZ3OUNm;^CHP?I2I`hCD8`HV%;Au@B_uD>*Kz z${AUN>EJr=VSSYCL&#uaf@%oKM1@lO&;~#Hzp1XBsNhDRsf2~reVm$mVoCHv|E21~7w{4ray&bU9u z+LwK83dULQVs3`XM~l7YSqIr~WK3S(N6I$u6JGjMI8fO@JSt2c$V$CyT5|mQfyH*zY3=J1R8VA7)JBS;TbqM(W`kz( zIU}l8wmpNQu}s7mB;>B7sv9JuLD*rzrNK$47Z2MPkrEZE~#=6~W!k>q6_DPbm}osOoi7C%$sF& z?iNHQ2QGNsM<7^pOLx%5Ml5_C!j$JK(f^m_qOKDfo2{KEqT^Pi^hvm8mvLrWuDmn; zoo~?>Tm^lTQqVz4Mq@m$VLbNPJ&M%NnO?yKsG|{cv_Oi1Y0SVmqome#qH^sZ^{_qKQCbTKfSmE{`P(qh0&N5tJR;Lf8*^ zU#XAJ-eqMx)Vp6|jSPsqHu43+V4}xQ9kY3UDxQdalPDF5d|^UXp_Ay;Wei`CH5(o5 zB5?W_1$_g&R~fVoI;e(aox2Hgw}YHWds8-ivwnP&S@lt*+-u0xi z8$|~hwgPG#kK$T;P-n2qtTi|4i7-);j{EbBzq*+V=#%M2f!(&)0{fR})~>U`U|%82 z6}iJ36yD5U-$Im};$AmiIsq4EE5w<<$>63%Z2i=S$C8uqVx*pNKoSMzM2DY|AHM?S z#pYu*Sa2d=@>Jryo}k#|x0-BsYi)m!_RB+;i7Q18-0#68l#rg^>~Arg7AH_Xk@sZA zC7#_S7zdfZDJHM1K)OQ~qrBLs4#yx|tl+bT)JI;N8t%k%M6e}t07e0dxRzdFB{J18 zA7o~TA~orE`X?f7PBfr41Ox#@kk`-2x~+`m5!&XGA;;GHa#nf~OOqh4+rNCdqYFQx z;t$qV*5joxcpQ=bbKywUReV_$H#X3HHKsgX+u;%&ArnsbLZ${SDNE9W!XH9lHhsQP zfU**lK6I!Bo6ct=i39!JIrzU%YAjpc~?nJT?A+g)E}8517BTrx^b^&*?j$ z!ARb|H3-CVBw`Jrb{$y8TfFfj+WAqDuQF%r1$JV&CADkD=9Qmk%(t(?WIki>8tJHd z+D$=t^EY2Nps6WAR@XYK3|S~$Ch=Pow<!;d?O7MgWQ#fJ6xim7Y&XvI{H`&Bh#J~Neh^nX8O-| zzFQWPcCMM7uVB7rBcbpI(d!6x9gM38 zb5-73ogF+hJnwwMnn5Y zyei?$v61m5-iIzE%&GOOqj|z;49kQi_C`uLS1urvEm7!z3Q;{^KQt*}HzH)T3SKwX+nBGwg0Iz*rp0Ots zm`mJc@Tk4PSF0q~g_8B(>T>f$Lco*8-TjL9pn%~`FLOLmme64A^7agTa)6oASfjpX zd2(qH??QP$pHy9vz9|!yed7r%36tpJxCkF1^O`I@7RV~qvj)0{i_;EvC0mTBdaGxIZj#S&aII{XQ1h&D6QQ7cEp>wyPQ#`@pj^&B9(Wx070A4* z1@0~rXZ~a<+v#YAJyyk?k2ApFk~nD*FpCdPs%P&qtt5W{1g)LNMI6<;xH&USfG+=! zQRF$*bvJFfw%eHNatk(d(hqqXEYEFz6g_IihjH*y6BLW(b$ zf?4#JOz@hahs&dIBXuVSB>^mQ{USB{x)xeaO)iLmTs2t;7+5z8*wJ)S!{dVEM&#TU z1f-9T(G=UH3>y^1>`<8Ssf~aUW2Tw0#O`%cb_06dqo(nLVkXtA{(=oDkL^8tJ9n~&9Y#hk)kCcYbbp3jqhq*DM zpa6Z<$|-RrJRSYtn%#w_RsC>~8^d)7NvLjL+-}mI2`~0MgIZ~I)xgMWkMB80;f{lb zjl?xa`@p<8^Zk%n*cxh_*lM(4 z|I?hmJ`chg%(@1LyKhd&%v4JOEd^;Q3K+qSQ7d6u$uoO)=ffI|s-;s}>)L`)z#tcef&4WFSM<6=?wwoLf zl^%1^XBkH>Jt4Upb~7gI7NrKNQKeCf7suv&K;P!}0X?xUMXC z#Q3`AsOlvh-!PBWK^I|qCF@1?_~y7r|0L>Dkzi0MjLz9*Tee}yaQ-O3H+EOT_5N_j z3guHOO`#LAp8J7$`8NEW;RJ3uyvcB0rrWiSs3AhIAodhSz&z z;J?fI^$~ssw)?0+@J6P*+Tfssp6bWA@=H1(o?Wk=inC};iFX>BlK$%L>LZhAn320x zWa?$-pyG4u3ngsXMAVEr){dh7-FFJZT9rRsR0D#9ttJReF|!9D!bbZyrZ(4a@ix!q zl2(9j%0``YG9@TqC9XtIM$&3K)a?HEnsTdej6|0yR)tlap+RtV81`Bc0ia^TBmtKE zs^Qr49mchRh4+eF99L0MKHSrfQ}F?8g7Tg16mR?# zS@vgYBl~LJJMN-ltT<9Bfp^LrSa_<673crXA2Rh&9AQY?m zpAi?$g8{_@@n^aC?HBTdkTx^i$*oC1r?rJ$Y3Nsqi?{;A#u@!ISlo+wJ>x!4$JaDz zC1l*J+hY$b4Y6fSbQbZWNKR3DrYYVy9+p-606w(w4rYYFj*nr^|L_8$mDq_M&aR*w2As!R9uOji=V%y^8Jag za2ib|jX~i7=M{!QdhJETfLT18xT7Ynd1@Nef4fCt_j35hJ#-aR!5|k=LEZg^2#>50 zIb*yg$@VviB1rbZ_W1)We+HkJL8kyLn?^zQ_Z3@L6|%DwcmDkxS*~bbFjrBQ=4fA% zEaZ<_(IJXJS%zUTV7U(FO5?Vi9cv%rvz(_R z#j-YC`km04E|>~~Ko{@InfcITsTZHeF=IpN-ed{@NlbL9u@69jS@e}R-V1MbtdMBtPuqkslVQyoWQn))TAg>8O;lW7j}dBLeLrt=ty`<5 zJFEoI0}8_A=y7RmInJct^$ONMwJW%EUwD9}_1_4TwW`w}lJv2VQ~u`^jm*}u453q5 zYplwUd60@MhGm?V9BOo*=;ug@k+k04!NqMI&ItV`LzfY11~s7f`^*ap z99Ji*1aPs9$Fh7~WBS8OxkTAa%{^JAGZ&2+YQ-!55Fin2gKj`I>cg1i0_hHJ;_Pao zTK|8*ZPuwP#nsEQ$mf$wm6-GR2L!L8t$oO$cD=<^S&WRF!4VI>ze_wMSJnAWv%L%1 zixfeXkIeh)9Ix9n$N(fnNV_#S(%F>taoU#|$S5&1+cv;iKvC_jkA2cD_Lj0`QUMl& zlzo7cec!wdUNLBJwK+t!C4hfyX=6gsy2Wb6pZP2^4@l^FqlwvV48j}d9x_0OlxXED z`g2eeoxB=JJu$|eh#QcHiU^%2NEm^I=bpB--2of1<@w$FQT|`OO4t&bgAm5c=K9lJ zEhU6ObEp8n*mjb2SDwwu1Xpb`SfhFsxUGOYrv0r87C+6_qtQP;s<(e|UvPqNXOJsS zKIhY{di+8~H#Ws}tC|_Aa6nB2rh<8t^ zE*`Yhc*pl9TZJjJC4rYHK^rI-sDIn?bVT?@aZ_^V&5**Yef&ImcKdyEkL;n5B&i&K zqRhSvOGuuC5Z&XazoF7p#=uf2FAi`hly_30&J+!93X_TeN20(KNUy|$g*pk{F``lpwcI; zsq<_W#v-k*J2HuNr&23|>L0kjsEry143*J(#H_xY+liec;N>bfi` zLfAx=3<;lMY7cX0^3?A8Ptd-h%5}BFr|>zyeB2eOe=rP>XhN`)M-1e)yTJF^uPfL^ zWc5A{#mz}oBP>fX(BbJUXfheeFgD-=lv?W+AK1LLZvgFuNbriPE4^nJJu**v)|&D# zNH>!q!>*XD{!W{^jBzZfzyfx6%bKTR0fk8285*KWt@zQsIt8y1mzVv({m^@=>m@) z$?BpOZN0sEJA+0)JES(fr=uV_6WIk>hpV7A>rZiU0BbnBs|)!Rn^nvnQA-u1{gt@w zIqV&+v>h=@AGmS@7fRy<{582L8)`Nq29ieaa;WN9Pdl95@9`2}o8PESrNO=+2|Vy{ zY?Bdb9ca#O0UfO&`AR_0izgg6kwiaR%zl;D-Bk5Y%KC!leOTwj)-oUWmVtTynPQ<3 ze$hiLBBVlVbzP)j-6Vj#E4F@a+Lp;fF{>*NJeM$jLT-ks7U*&~sihfgSbCfg|=^m|>ciPCBPMg>_K80c7b0TITp( z*9KZ%#l?`dzOfr_1P9O8^s0^P9&%pG=4?7uxl|@;E}YZXA?&25T7`ez!I~d3->Z+lkv{_eO$=*yarimjgKk6ry=R ziU*_$w5Zyqo5QnjFhEM#4_VcXiZl2fOyEcK$DI5ze* zSHB2-WPu5~LuGBBXQD)~GSKnn-;~clG4!s=F4^g8KIp*X+l(anD`kw7Sbrx_)9$A% z=STYtG&ckRx7wAT|H4ksDlM?E`G8oT4Xi+plD?5KK}l}-w$0Zkv8O<`*&krSmfV&e zN7z?rOuAxTj4-L~3hF~u@`e0^OnF|%*Wq5TiwmTVam;3Bq`rDH2L%Frw)c)!-MvD! z?tF^m-9<;JnZB!tH2FkgJh`VXzXZ%o_Q9pI6r8RhTLvFk z1}N!}M$~#{1sOlfeWx4*yqxx$fUFG?miZTO@vzFm)t%ZRr?ZRtU?Qs9C3O=c;X4Jc zNrJc!gtCj>=WWs1!8+{|*Csbb=?9}MP|qN8gJ;>cgH_>YP*qesc5jpp_h(~B>G8%r z3l6ob7aH>P9&7wM{~VZ!=^=02{mh00NT-M1aH@ANIL%*|xM)Ph<`y4_VRTG;m(woboShpY~<4Z7H-G8*Z;?#aWW z&sBH%>kS74f{p{FZLeioisGw(v&7dcinS{tH}~Hxt2|`tBYKek`6KCNMhjTDb}&-H z0#=T}E@=Vx>he}(A^FX+aSja)=-2(Vfgm>~RU_98e48NT4x?%C?zESPUotTa!gOzs zcmF?dxWw%3{d=Ou*)!bFJ2)#Lyw@p9qX7DB@PWMU&f63mWQ#sKXe$nHTfplq(mTnj zzWqg~%z8(UW@0-ykqJ60;%Ikr&shHV(4MZm10X!u@_==>9Ox6i)R}HZ! z>zGI@V+WFj;cl&x<_Z~zycoDdR7v4exZUAcm-0}K?Q9jI>!Z-WY*OCw!`Ef*t?3zp zE;5N8|2=x0D+<}&X2m|fI(f@gII4sg!7~Z65(%Iknpr-4g72P}d%g5s;OIim9Iw3e z4Id)BNOhn!r0+L3yDLmibNUz#c_jpAU*zg6YW6PSbfdnb*?V3B#I>tAALM4>f{5>f z{B=kta!Xflq#zSY}BG?ZkQnnxHkO*!lxS_|o72#_6V0zQps1(9NoWZ(Sxh!~i<~=1mF0uNA|`ZSqU%D{;C>-IpWJ1%n7mdL_TNha-yb%M**wAp3rlmra(#lrDi%NB$q7wl1Z?CFSP@)q*g zbt6s+>@Bkwj+$6`I+hBAs)NB~iyNJ?uTM?}9Uv8){!2UTVbf77F`Cl>ggyEIgw8{u zQmB@`enH8R%t_xi6)V#fO-=QqiVLENM_q9VlP+FNUV zJNXPHB@y~cw{-sdqJ6_m!2$$b&W)wWn{?K|C5VTP4h*RFT35%}-@9jo-DSo<{YYd(9+Hy)Jk!^<}t|Up-IaH77jGWQxPLCb#d%N8< z9p8xx`cOTDj@t^OOb$0G(0911%(L{0So^v%HIQuN`}(jp_YriKMv1W<2V~mDjDgEA zi+aq1h1$>J%%yqpmuEA<1~(^Vy)xxl;9lV~Py$fko(Ja5kov*g!o@L6)nx;7N?0Hv z!p}BuaiNETc)cOip}HD*xYwn`LNExN`+9Qjdp@Q0O5)ty-;sw`7B~!qjyTv zXvHq58dfo+L*+yHe~kI$gRh%&fhE)aD(~vHH1DQCl^1y`6FKFDHoCiXDu*|1$XT$& zdL|D+he8k_+WQHYgYjH!SFceQDOMh>z=!m*a0^WP>~COscccfn@o4cS>2-8V;9YKD z2%mAjT)P1dZ1(pi&UVLjgJ^n}UVhJt)e?9-dwVh*Q#B$-H~hFTcSqBux{QLq{R3u` zw&vn1a2{%GnzNahqe|L(0XG21|9E8b9FqImrGLjDq11?-JWuhy%xNe55iqwtN901` b;8<6a3Xt*#=@a1q%ywE>P*MT_00031D-Pbu diff --git a/libspectrum/test/raw-data-block.tzx b/libspectrum/test/raw-data-block.tzx deleted file mode 100644 index 06e465cc6863dd7d0042772ebc3434df9a144297..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 22 dcma!w2uUnRRg_{B5anWEU|?ZpVEFK10{}M81wQ}) diff --git a/libspectrum/test/sp-2000.sna.gz b/libspectrum/test/sp-2000.sna.gz deleted file mode 100644 index 27b8107d7f127d2a9c36c9f74211e4cc155dfb03..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 99 zcmb2|=HQTf;^)r9TwI`QWME*RSDcr~@b;h~BLf4+fd#G`>%F)o4lu8{&B8z$(AROk Lw&=L@0R{#D{Sy$y diff --git a/libspectrum/test/sp-ffff.sna.gz b/libspectrum/test/sp-ffff.sna.gz deleted file mode 100644 index 0437755caccef48b23b7d4af8053f73a702f79d4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 99 zcmb2|=HSqO;^)r9TwI`=1_XM=d5H{f4;nHuFz_%b{GMLM%CmvlW0@HPY2d>l#v8{9 Kf~5~IFaQAhoDppR diff --git a/libspectrum/test/standard-tap.tap b/libspectrum/test/standard-tap.tap deleted file mode 100644 index f3e85ef31351a7b2121a4406b709eba4f998bebe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 37 mcmWe;U|U|?VZVjutjE)D{n diff --git a/libspectrum/test/szx-chunks/ATRP-uncompressed.szx.gz b/libspectrum/test/szx-chunks/ATRP-uncompressed.szx.gz deleted file mode 100644 index ca4728538775098795a5b3be5d28d140171b609e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 89 zcmb2|=HL)9-4e;f>=+Uhpj(=koS$1zlv-Sznxa=+Rl)G~;6Yvn0RaXB@r~lr9Nz_g h^C$84Z~OkHM=bTptgYe_6U`=?@kD i*LUPwoH=8g?cRCim&{Hz22}8XpZ`JKYGYvs1_l645*!8q diff --git a/libspectrum/test/szx-chunks/CFRP.szx b/libspectrum/test/szx-chunks/CFRP.szx deleted file mode 100644 index 656812040971f5e972323bd1ab3dda345007bf2b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 58 zcma!w2o7OnWn^%63kuL;U|?WmV5qqD_Mjn6)^bOErU|?WmV5qqD_Mjn8Uba7<>0stF(0)_wp diff --git a/libspectrum/test/szx-chunks/SPCR.szx b/libspectrum/test/szx-chunks/SPCR.szx deleted file mode 100644 index fa454a6284545048c2c2c4259c78878d17ab2fb7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 24 dcma!w2o7OnWn~Bsa1P>NU|?X%*Z2jb7yvp#1ULWy diff --git a/libspectrum/test/szx-chunks/Z80R.szx b/libspectrum/test/szx-chunks/Z80R.szx deleted file mode 100644 index 89e30e6b6b38888afa039ac5a969fb1e76f8f5ca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 53 zcma!w2o7OnWn_r5FbGm*U|^6x!p8iBErgLh^Um`Nhfm*G+$}7V`$O)8WD6q$lLk-$ I2P^X(0F^fnjsO4v diff --git a/libspectrum/test/szx-chunks/ZMMC.szx b/libspectrum/test/szx-chunks/ZMMC.szx deleted file mode 100644 index b605622da4138ad42465b9819a87bec056b30748..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16 Vcma!w2o7OnWn_r*^>t -#include -#include -#include -#include - -#include "internals.h" -#include "test.h" - -typedef struct szx_chunk_t { - libspectrum_byte *data; - size_t length; -} szx_chunk_t; - -static szx_chunk_t* -find_szx_chunk( libspectrum_byte *in_buffer, size_t in_buffer_length, - const char *search ) -{ - libspectrum_byte *data; - size_t data_remaining; - libspectrum_byte id[5] = {0}; - libspectrum_byte length_buffer[4]; - libspectrum_dword length; - - data = in_buffer; - data_remaining = in_buffer_length; - - if( data_remaining < 8 ) { - fprintf( stderr, "SZX file is less than 8 bytes long\n" ); - return NULL; - } - - /* Skip header */ - data += 8; data_remaining -= 8; - - while( data_remaining > 0 ) { - if( data_remaining < 8 ) { - fprintf( stderr, "Chunk is less than 8 bytes long\n" ); - return NULL; - } - - memcpy( id, data, 4 ); - data += 4; data_remaining -= 4; - - memcpy( length_buffer, data, 4 ); - data += 4; data_remaining -= 4; - - length = length_buffer[0] + (length_buffer[1] << 8) + - (length_buffer[2] << 16) + (length_buffer[3] << 24); - - if( data_remaining < length ) { - fprintf( stderr, "Not enough data for chunk\n" ); - return NULL; - } - - if( !memcmp( id, search, 4 ) ) { - szx_chunk_t *chunk = libspectrum_malloc( sizeof(*chunk) ); - libspectrum_byte *chunk_data = libspectrum_malloc( length ); - memcpy( chunk_data, data, length ); - chunk->data = chunk_data; - chunk->length = length; - return chunk; - } - - data += length; data_remaining -= length; - } - - return NULL; -} - -static test_return_t -szx_write_block_test_with_flags( const char *id, libspectrum_machine machine, - int flags, void (*setter)( libspectrum_snap* ), - libspectrum_byte *expected, size_t expected_length, size_t total_length ) -{ - libspectrum_snap *snap; - libspectrum_byte *buffer; size_t length; - int out_flags; - szx_chunk_t *chunk; - size_t i; - test_return_t r = TEST_INCOMPLETE; - - snap = libspectrum_snap_alloc(); - - libspectrum_snap_set_machine( snap, machine ); - - setter( snap ); - - length = 0; - buffer = NULL; - libspectrum_snap_write( &buffer, &length, &out_flags, snap, - LIBSPECTRUM_ID_SNAPSHOT_SZX, NULL, flags ); - libspectrum_snap_free( snap ); - - chunk = find_szx_chunk( buffer, length, id ); - if( !chunk ) { - fprintf( stderr, "Chunk not found\n" ); - libspectrum_free( buffer ); - return TEST_FAIL; - } - - libspectrum_free( buffer ); - - if( chunk->length == total_length ) { - if( memcmp( chunk->data, expected, expected_length ) ) { - fprintf( stderr, "Chunk has wrong initial data\n" ); - r = TEST_FAIL; - } else { - r = TEST_PASS; - for( i = expected_length; i < total_length; i++ ) { - if( chunk->data[i] ) { - r = TEST_FAIL; - break; - } - } - } - } else { - fprintf( stderr, "Chunk has wrong length\n" ); - r = TEST_FAIL; - } - - libspectrum_free( chunk->data ); - libspectrum_free( chunk ); - - return r; -} - -static test_return_t -szx_write_block_test( const char *id, libspectrum_machine machine, - void (*setter)( libspectrum_snap* ), - libspectrum_byte *expected, size_t expected_length ) -{ - return szx_write_block_test_with_flags( id, machine, 0, setter, - expected, expected_length, expected_length ); -} - -static test_return_t -szx_write_uncompressed_block_test( const char *id, libspectrum_machine machine, - void (*setter)( libspectrum_snap* ), - libspectrum_byte *expected, size_t expected_length, size_t total_length ) -{ - return szx_write_block_test_with_flags( id, machine, - LIBSPECTRUM_FLAG_SNAPSHOT_NO_COMPRESSION, setter, - expected, expected_length, total_length ); -} - -static void -z80r_setter( libspectrum_snap *snap ) -{ - libspectrum_snap_set_a( snap, 0xc4 ); - libspectrum_snap_set_f( snap, 0x1f ); - libspectrum_snap_set_bc( snap, 0x0306 ); - libspectrum_snap_set_de( snap, 0x06e4 ); - libspectrum_snap_set_hl( snap, 0x0154 ); - - libspectrum_snap_set_a_( snap, 0x69 ); - libspectrum_snap_set_f_( snap, 0x07 ); - libspectrum_snap_set_bc_( snap, 0xe7dc ); - libspectrum_snap_set_de_( snap, 0xc3d0 ); - libspectrum_snap_set_hl_( snap, 0xdccb ); - - libspectrum_snap_set_ix( snap, 0x8ba3 ); - libspectrum_snap_set_iy( snap, 0x1c13 ); - libspectrum_snap_set_sp( snap, 0xf86d ); - libspectrum_snap_set_pc( snap, 0xc81e ); - - libspectrum_snap_set_i( snap, 0x19 ); - libspectrum_snap_set_r( snap, 0x84 ); - libspectrum_snap_set_iff1( snap, 1 ); - libspectrum_snap_set_iff2( snap, 0 ); - libspectrum_snap_set_im( snap, 2 ); - - libspectrum_snap_set_tstates( snap, 40 ); - - libspectrum_snap_set_last_instruction_ei( snap, 1 ); - libspectrum_snap_set_halted( snap, 0 ); - libspectrum_snap_set_last_instruction_set_f( snap, 1 ); - - libspectrum_snap_set_memptr( snap, 0xdc03 ); -} - -static libspectrum_byte -test_31_expected[] = { - 0x1f, 0xc4, 0x06, 0x03, 0xe4, 0x06, 0x54, 0x01, /* AF, BC, DE, HL */ - 0x07, 0x69, 0xdc, 0xe7, 0xd0, 0xc3, 0xcb, 0xdc, /* AF', BC', DE', HL' */ - 0xa3, 0x8b, 0x13, 0x1c, 0x6d, 0xf8, 0x1e, 0xc8, /* IX, IY, SP, PC */ - 0x19, 0x84, 0x01, 0x00, 0x02, /* I, R, IFF1, IFF2, IM */ - 0x28, 0x00, 0x00, 0x00, 0x08, /* tstates, tstates until /INT goes high */ - 0x05, /* flags */ - 0x03, 0xdc /* MEMPTR */ -}; - -test_return_t -test_31( void ) -{ - return szx_write_block_test( "Z80R", LIBSPECTRUM_MACHINE_48, z80r_setter, - test_31_expected, ARRAY_SIZE(test_31_expected) ); -} - -static void -spcr_setter( libspectrum_snap *snap ) -{ - libspectrum_snap_set_out_ula( snap, 0xfa ); - libspectrum_snap_set_out_128_memoryport( snap, 0x6f ); - libspectrum_snap_set_out_plus3_memoryport( snap, 0x28 ); -} - -static libspectrum_byte -test_32_expected[] = { - 0x02, 0x6f, 0x28, 0xfa, /* Border, 128, +3, ULA */ - 0x00, 0x00, 0x00, 0x00 /* Reserved */ -}; - -test_return_t -test_32( void ) -{ - return szx_write_block_test( "SPCR", LIBSPECTRUM_MACHINE_PLUS3, spcr_setter, - test_32_expected, ARRAY_SIZE(test_32_expected) ); -} - -static void -joy_setter( libspectrum_snap *snap ) -{ - libspectrum_snap_set_joystick_active_count( snap, 2 ); - libspectrum_snap_set_joystick_list( snap, 0, LIBSPECTRUM_JOYSTICK_KEMPSTON ); - libspectrum_snap_set_joystick_inputs( snap, 0, - LIBSPECTRUM_JOYSTICK_INPUT_JOYSTICK_1 ); - libspectrum_snap_set_joystick_list( snap, 1, LIBSPECTRUM_JOYSTICK_SINCLAIR_1 ); - libspectrum_snap_set_joystick_inputs( snap, 1, - LIBSPECTRUM_JOYSTICK_INPUT_JOYSTICK_2 ); -} - -static libspectrum_byte -test_33_expected[] = { - 0x01, 0x00, 0x00, 0x00, /* Flags */ - 0x00, 0x03 /* Joystick 1 = Kempston, Joystick 2 = Sinclair 1 */ -}; - -test_return_t -test_33( void ) -{ - return szx_write_block_test( "JOY\0", LIBSPECTRUM_MACHINE_48, joy_setter, - test_33_expected, ARRAY_SIZE(test_33_expected) ); -} - -static void -keyb_setter( libspectrum_snap *snap ) -{ - libspectrum_snap_set_issue2( snap, 1 ); - libspectrum_snap_set_joystick_active_count( snap, 1 ); - libspectrum_snap_set_joystick_list( snap, 0, LIBSPECTRUM_JOYSTICK_CURSOR ); - libspectrum_snap_set_joystick_inputs( snap, 0, - LIBSPECTRUM_JOYSTICK_INPUT_KEYBOARD ); -} - -static libspectrum_byte -test_34_expected[] = { - 0x01, 0x00, 0x00, 0x00, /* Flags */ - 0x02 /* Cursor joystick */ -}; - -test_return_t -test_34( void ) -{ - return szx_write_block_test( "KEYB", LIBSPECTRUM_MACHINE_48, keyb_setter, - test_34_expected, ARRAY_SIZE(test_34_expected) ); -} - -static void -zxpr_setter( libspectrum_snap *snap ) -{ - libspectrum_snap_set_zx_printer_active( snap, 1 ); -} - -static libspectrum_byte -test_35_expected[] = { - 0x01, 0x00 /* Flags */ -}; - -test_return_t -test_35( void ) -{ - return szx_write_block_test( "ZXPR", LIBSPECTRUM_MACHINE_48, zxpr_setter, - test_35_expected, ARRAY_SIZE(test_35_expected) ); -} - -static libspectrum_byte -ay_registers_data[] = { - 0x73, 0x03, 0xb1, 0x00, 0xbb, 0x0c, 0x19, 0x0f, - 0x1e, 0x07, 0x11, 0x71, 0x6c, 0x0a, 0x2b, 0x41 -}; - -static void -ay_setter( libspectrum_snap *snap ) -{ - size_t i; - - libspectrum_snap_set_fuller_box_active( snap, 1 ); - libspectrum_snap_set_melodik_active( snap, 0 ); - libspectrum_snap_set_out_ay_registerport( snap, 0x08 ); - - for( i = 0; i < 16; i++ ) { - libspectrum_snap_set_ay_registers( snap, i, ay_registers_data[i] ); - } -} - -static libspectrum_byte -test_36_expected[] = { - 0x01, /* Flags */ - 0x08, /* Register port */ - 0x73, 0x03, 0xb1, 0x00, 0xbb, 0x0c, 0x19, 0x0f, /* Registers 0x00 - 0x07 */ - 0x1e, 0x07, 0x11, 0x71, 0x6c, 0x0a, 0x2b, 0x41 /* Register 0x08 - 0x0f */ -}; - -test_return_t -test_36( void ) -{ - return szx_write_block_test( "AY\0\0", LIBSPECTRUM_MACHINE_48, ay_setter, - test_36_expected, ARRAY_SIZE(test_36_expected) ); -} - -static void -scld_setter( libspectrum_snap *snap ) -{ - libspectrum_snap_set_out_scld_hsr( snap, 0x49 ); - libspectrum_snap_set_out_scld_dec( snap, 0x9d ); -} - -static libspectrum_byte -test_37_expected[] = { - 0x49, 0x9d -}; - -test_return_t -test_37( void ) -{ - return szx_write_block_test( "SCLD", LIBSPECTRUM_MACHINE_TC2048, scld_setter, - test_37_expected, ARRAY_SIZE(test_37_expected) ); -} - -static void -zxat_setter( libspectrum_snap *snap ) -{ - libspectrum_snap_set_zxatasp_active( snap, 1 ); - - libspectrum_snap_set_zxatasp_upload( snap, 1 ); - libspectrum_snap_set_zxatasp_writeprotect( snap, 0 ); - libspectrum_snap_set_zxatasp_port_a( snap, 0xab ); - libspectrum_snap_set_zxatasp_port_b( snap, 0x8c ); - libspectrum_snap_set_zxatasp_port_c( snap, 0x82 ); - libspectrum_snap_set_zxatasp_control( snap, 0xd8 ); - libspectrum_snap_set_zxatasp_pages( snap, 0x18 ); - libspectrum_snap_set_zxatasp_current_page( snap, 0x11 ); -} - -static libspectrum_byte -test_38_expected[] = { - 0x01, 0x00, /* Flags */ - 0xab, 0x8c, 0x82, 0xd8, /* Ports */ - 0x18, 0x11 /* Page count and current page */ -}; - -test_return_t -test_38( void ) -{ - return szx_write_block_test( "ZXAT", LIBSPECTRUM_MACHINE_48, zxat_setter, - test_38_expected, ARRAY_SIZE(test_38_expected) ); -} - -static void -zxcf_setter( libspectrum_snap *snap ) -{ - libspectrum_snap_set_zxcf_active( snap, 1 ); - - libspectrum_snap_set_zxcf_upload( snap, 1 ); - libspectrum_snap_set_zxcf_memctl( snap, 0x37 ); - libspectrum_snap_set_zxcf_pages( snap, 0x55 ); -} - -static libspectrum_byte -test_39_expected[] = { - 0x01, 0x00, /* Flags */ - 0x37, /* Memory control */ - 0x55 /* Page count */ -}; - -test_return_t -test_39( void ) -{ - return szx_write_block_test( "ZXCF", LIBSPECTRUM_MACHINE_48, zxcf_setter, - test_39_expected, ARRAY_SIZE(test_39_expected) ); -} - -static void -amxm_setter( libspectrum_snap *snap ) -{ - libspectrum_snap_set_kempston_mouse_active( snap, 1 ); -} - -static libspectrum_byte -test_40_expected[] = { - 0x02, /* Kempston mouse */ - 0x00, 0x00, 0x00, /* AMX mouse CTRLA registers */ - 0x00, 0x00, 0x00 /* AMX mouse CTRLB registers */ -}; - -test_return_t -test_40( void ) -{ - return szx_write_block_test( "AMXM", LIBSPECTRUM_MACHINE_48, amxm_setter, - test_40_expected, ARRAY_SIZE(test_40_expected) ); -} - -static void -side_setter( libspectrum_snap *snap ) -{ - libspectrum_snap_set_simpleide_active( snap, 1 ); -} - -static libspectrum_byte -empty_chunk_expected[] = { /* Empty */ }; - -test_return_t -test_41( void ) -{ - return szx_write_block_test( "SIDE", LIBSPECTRUM_MACHINE_48, side_setter, - empty_chunk_expected, ARRAY_SIZE(empty_chunk_expected) ); -} - -static void -drum_setter( libspectrum_snap *snap ) -{ - libspectrum_snap_set_specdrum_active( snap, 1 ); - libspectrum_snap_set_specdrum_dac( snap, -0x3b ); -} - -static libspectrum_byte -test_42_expected[] = { - 0x45 /* DAC + 128 */ -}; - -test_return_t -test_42( void ) -{ - return szx_write_block_test( "DRUM", LIBSPECTRUM_MACHINE_48, drum_setter, - test_42_expected, ARRAY_SIZE(test_42_expected) ); -} - -static void -covx_setter( libspectrum_snap *snap ) -{ - libspectrum_snap_set_covox_active( snap, 1 ); - libspectrum_snap_set_covox_dac( snap, 0xc0 ); -} - -static libspectrum_byte -test_43_expected[] = { - 0xc0, /* DAC */ - 0x00, 0x00, 0x00 /* Reserved */ -}; - -test_return_t -test_43( void ) -{ - return szx_write_block_test( "COVX", LIBSPECTRUM_MACHINE_48, covx_setter, - test_43_expected, ARRAY_SIZE(test_43_expected) ); -} - -static void -zmmc_setter( libspectrum_snap *snap ) -{ - libspectrum_snap_set_zxmmc_active( snap, 1 ); -} - -test_return_t -test_57( void ) -{ - return szx_write_block_test( "ZMMC", LIBSPECTRUM_MACHINE_48, zmmc_setter, - empty_chunk_expected, ARRAY_SIZE(empty_chunk_expected) ); -} - -static void -ramp_setter( libspectrum_snap *snap ) -{ - libspectrum_byte *ram = libspectrum_malloc0_n( 1, 0x4000 ); - libspectrum_snap_set_pages( snap, 0, ram ); -} - -static libspectrum_byte -empty_ram_page_expected[] = { - 0x01, 0x00, /* Flags */ - 0x00, /* Page number */ - /* 16 Kb of zeros compressed */ - 0x78, 0xda, 0xed, 0xc1, 0x31, 0x01, 0x00, 0x00, - 0x00, 0xc2, 0xa0, 0xf5, 0x4f, 0x6d, 0x0c, 0x1f, - 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x80, 0xb7, 0x01, 0x40, 0x00, 0x00, 0x01 -}; - -test_return_t -test_59( void ) -{ - return szx_write_block_test( "RAMP", LIBSPECTRUM_MACHINE_48, ramp_setter, - empty_ram_page_expected, ARRAY_SIZE(empty_ram_page_expected) ); -} - -static void -atrp_setter( libspectrum_snap *snap ) -{ - libspectrum_byte *ram; - - libspectrum_snap_set_zxatasp_active( snap, 1 ); - libspectrum_snap_set_zxatasp_pages( snap, 1 ); - - ram = libspectrum_malloc0_n( 1, 0x4000 ); - libspectrum_snap_set_zxatasp_ram( snap, 0, ram ); -} - -test_return_t -test_61( void ) -{ - return szx_write_block_test( "ATRP", LIBSPECTRUM_MACHINE_48, atrp_setter, - empty_ram_page_expected, ARRAY_SIZE(empty_ram_page_expected) ); -} - -static void -cfrp_setter( libspectrum_snap *snap ) -{ - libspectrum_byte *ram; - - libspectrum_snap_set_zxcf_active( snap, 1 ); - libspectrum_snap_set_zxcf_pages( snap, 1 ); - - ram = libspectrum_malloc0_n( 1, 0x4000 ); - libspectrum_snap_set_zxcf_ram( snap, 0, ram ); -} - -test_return_t -test_62( void ) -{ - return szx_write_block_test( "CFRP", LIBSPECTRUM_MACHINE_48, cfrp_setter, - empty_ram_page_expected, ARRAY_SIZE(empty_ram_page_expected) ); -} - -static libspectrum_byte -empty_ram_page_start[] = { - 0x00, 0x00, /* Flags */ - 0x00, /* Page number */ - /* Followed by 16 Kb of uncompressed zeros */ -}; - -test_return_t -test_65( void ) -{ - return szx_write_uncompressed_block_test( "RAMP", LIBSPECTRUM_MACHINE_48, - ramp_setter, empty_ram_page_start, ARRAY_SIZE(empty_ram_page_start), - ARRAY_SIZE(empty_ram_page_start) + 0x4000 ); -} - -test_return_t -test_66( void ) -{ - return szx_write_uncompressed_block_test( "ATRP", LIBSPECTRUM_MACHINE_48, - atrp_setter, empty_ram_page_start, ARRAY_SIZE(empty_ram_page_start), - ARRAY_SIZE(empty_ram_page_start) + 0x4000 ); -} - -test_return_t -test_67( void ) -{ - return szx_write_uncompressed_block_test( "CFRP", LIBSPECTRUM_MACHINE_48, - cfrp_setter, empty_ram_page_start, ARRAY_SIZE(empty_ram_page_start), - ARRAY_SIZE(empty_ram_page_start) + 0x4000 ); -} - -static test_return_t -szx_read_block_test_with_template( const char *id, const char *template, - int (*check_fn)( libspectrum_snap* ) ) -{ - char filename[ 256 ]; - libspectrum_byte *buffer = NULL; - size_t filesize = 0; - libspectrum_snap *snap; - int failed = 0; - - snprintf( filename, 256, template, id ); - - if( read_file( &buffer, &filesize, filename ) ) return TEST_INCOMPLETE; - - snap = libspectrum_snap_alloc(); - - if( libspectrum_snap_read( snap, buffer, filesize, LIBSPECTRUM_ID_UNKNOWN, - filename ) != LIBSPECTRUM_ERROR_NONE ) { - fprintf( stderr, "%s: error reading `%s'\n", progname, filename ); - libspectrum_snap_free( snap ); - libspectrum_free( buffer ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); - - failed = check_fn( snap ); - - libspectrum_snap_free( snap ); - - return failed ? TEST_FAIL : TEST_PASS; -} - -static test_return_t -szx_read_block_test( const char *id, int (*check_fn)( libspectrum_snap* ) ) -{ - return szx_read_block_test_with_template( id, - STATIC_TEST_PATH( "szx-chunks/%s.szx" ), check_fn ); -} - -static test_return_t -szx_read_block_from_compressed_snap_test( const char *id, - int (*check_fn)( libspectrum_snap* ) ) -{ - return szx_read_block_test_with_template( id, - STATIC_TEST_PATH( "szx-chunks/%s-uncompressed.szx.gz" ), check_fn ); -} - -static int -test_44_check( libspectrum_snap *snap ) -{ - int failed = 0; - - if( libspectrum_snap_a( snap ) != 0xc4 ) failed = 1; - - if( libspectrum_snap_a( snap ) != 0xc4 ) failed = 1; - if( libspectrum_snap_f( snap ) != 0x1f ) failed = 1; - if( libspectrum_snap_bc( snap ) != 0x0306 ) failed = 1; - if( libspectrum_snap_de( snap ) != 0x06e4 ) failed = 1; - if( libspectrum_snap_hl( snap ) != 0x0154 ) failed = 1; - - if( libspectrum_snap_a_( snap ) != 0x69 ) failed = 1; - if( libspectrum_snap_f_( snap ) != 0x07 ) failed = 1; - if( libspectrum_snap_bc_( snap ) != 0xe7dc ) failed = 1; - if( libspectrum_snap_de_( snap ) != 0xc3d0 ) failed = 1; - if( libspectrum_snap_hl_( snap ) != 0xdccb ) failed = 1; - - if( libspectrum_snap_ix( snap ) != 0x8ba3 ) failed = 1; - if( libspectrum_snap_iy( snap ) != 0x1c13 ) failed = 1; - if( libspectrum_snap_sp( snap ) != 0xf86d ) failed = 1; - if( libspectrum_snap_pc( snap ) != 0xc81e ) failed = 1; - - if( libspectrum_snap_i( snap ) != 0x19 ) failed = 1; - if( libspectrum_snap_r( snap ) != 0x84 ) failed = 1; - if( libspectrum_snap_iff1( snap ) != 1 ) failed = 1; - if( libspectrum_snap_iff2( snap ) != 0 ) failed = 1; - if( libspectrum_snap_im( snap ) != 2 ) failed = 1; - - if( libspectrum_snap_tstates( snap ) != 40 ) failed = 1; - - if( libspectrum_snap_last_instruction_ei( snap ) != 1 ) failed = 1; - if( libspectrum_snap_halted( snap ) != 0 ) failed = 1; - if( libspectrum_snap_last_instruction_set_f( snap ) != 1 ) failed = 1; - - if( libspectrum_snap_memptr( snap ) != 0xdc03 ) failed = 1; - - return failed; -} - -test_return_t -test_44( void ) -{ - return szx_read_block_test( "Z80R", test_44_check ); -} - -static int -test_45_check( libspectrum_snap *snap ) -{ - int failed = 0; - - if( libspectrum_snap_out_ula( snap ) != 0xfa ) failed = 1; - if( libspectrum_snap_out_128_memoryport( snap ) != 0x6f ) failed = 1; - if( libspectrum_snap_out_plus3_memoryport( snap ) != 0x28 ) failed = 1; - - return failed; -} - -test_return_t -test_45( void ) -{ - return szx_read_block_test( "SPCR", test_45_check ); -} - -static int -test_46_check( libspectrum_snap *snap ) -{ - int failed = 0; - - if( libspectrum_snap_joystick_active_count( snap ) != 2 ) failed = 1; - if( libspectrum_snap_joystick_list( snap, 0 ) != LIBSPECTRUM_JOYSTICK_KEMPSTON ) failed = 1; - if( libspectrum_snap_joystick_inputs( snap, 0 ) != LIBSPECTRUM_JOYSTICK_INPUT_JOYSTICK_1 ) failed = 1; - if( libspectrum_snap_joystick_list( snap, 1 ) != LIBSPECTRUM_JOYSTICK_SINCLAIR_1 ) failed = 1; - if( libspectrum_snap_joystick_inputs( snap, 1 ) != LIBSPECTRUM_JOYSTICK_INPUT_JOYSTICK_2 ) failed = 1; - - return failed; -} - -test_return_t -test_46( void ) -{ - return szx_read_block_test( "JOY", test_46_check ); -} - -static int -test_47_check( libspectrum_snap *snap ) -{ - int failed = 0; - - if( libspectrum_snap_issue2( snap ) != 1 ) failed = 1; - if( libspectrum_snap_joystick_active_count( snap ) != 1 ) failed = 1; - if( libspectrum_snap_joystick_list( snap, 0 ) != LIBSPECTRUM_JOYSTICK_CURSOR ) failed = 1; - if( libspectrum_snap_joystick_inputs( snap, 0 ) != LIBSPECTRUM_JOYSTICK_INPUT_KEYBOARD ) failed = 1; - - return failed; -} - -test_return_t -test_47( void ) -{ - return szx_read_block_test( "KEYB", test_47_check ); -} - -static int -test_48_check( libspectrum_snap *snap ) -{ - return libspectrum_snap_zx_printer_active( snap ) != 1; -} - -test_return_t -test_48( void ) -{ - return szx_read_block_test( "ZXPR", test_48_check ); -} - -static int -test_49_check( libspectrum_snap *snap ) -{ - int failed = 0; - size_t i; - - if( libspectrum_snap_fuller_box_active( snap ) != 1 ) failed = 1; - if( libspectrum_snap_melodik_active( snap ) != 0 ) failed = 1; - if( libspectrum_snap_out_ay_registerport( snap ) != 0x08 ) failed = 1; - - for( i = 0; i < 16; i++ ) { - if( libspectrum_snap_ay_registers( snap, i ) != ay_registers_data[i] ) failed = 1; - } - - return failed; -} - -test_return_t -test_49( void ) -{ - return szx_read_block_test( "AY", test_49_check ); -} - -static int -test_50_check( libspectrum_snap *snap ) -{ - int failed = 0; - - if( libspectrum_snap_out_scld_hsr( snap ) != 0x49 ) failed = 1; - if( libspectrum_snap_out_scld_dec( snap ) != 0x9d ) failed = 1; - - return failed; -} - -test_return_t -test_50( void ) -{ - return szx_read_block_test( "SCLD", test_50_check ); -} - -static int -test_51_check( libspectrum_snap *snap ) -{ - int failed = 0; - - if( libspectrum_snap_zxatasp_active( snap ) != 1 ) failed = 1; - if( libspectrum_snap_zxatasp_upload( snap ) != 1 ) failed = 1; - if( libspectrum_snap_zxatasp_writeprotect( snap ) != 0 ) failed = 1; - if( libspectrum_snap_zxatasp_port_a( snap ) != 0xab ) failed = 1; - if( libspectrum_snap_zxatasp_port_b( snap ) != 0x8c ) failed = 1; - if( libspectrum_snap_zxatasp_port_c( snap ) != 0x82 ) failed = 1; - if( libspectrum_snap_zxatasp_control( snap ) != 0xd8 ) failed = 1; - if( libspectrum_snap_zxatasp_pages( snap ) != 0x18 ) failed = 1; - if( libspectrum_snap_zxatasp_current_page( snap ) != 0x11 ) failed = 1; - - return failed; -} - -test_return_t -test_51( void ) -{ - return szx_read_block_test( "ZXAT", test_51_check ); -} - -static int -test_52_check( libspectrum_snap *snap ) -{ - int failed = 0; - - if( libspectrum_snap_zxcf_active( snap ) != 1 ) failed = 1; - if( libspectrum_snap_zxcf_upload( snap ) != 1 ) failed = 1; - if( libspectrum_snap_zxcf_memctl( snap ) != 0x37 ) failed = 1; - if( libspectrum_snap_zxcf_pages( snap ) != 0x55 ) failed = 1; - - return failed; -} - -test_return_t -test_52( void ) -{ - return szx_read_block_test( "ZXCF", test_52_check ); -} - -static int -test_53_check( libspectrum_snap *snap ) -{ - return libspectrum_snap_kempston_mouse_active( snap ) != 1; -} - -test_return_t -test_53( void ) -{ - return szx_read_block_test( "AMXM", test_53_check ); -} - -static int -test_54_check( libspectrum_snap *snap ) -{ - return libspectrum_snap_simpleide_active( snap ) != 1; -} - -test_return_t -test_54( void ) -{ - return szx_read_block_test( "SIDE", test_54_check ); -} - -static int -test_55_check( libspectrum_snap *snap ) -{ - int failed = 0; - - if( libspectrum_snap_specdrum_active( snap ) != 1 ) failed = 1; - if( libspectrum_snap_specdrum_dac( snap ) != -0x3b ) failed = 1; - - return failed; -} - -test_return_t -test_55( void ) -{ - return szx_read_block_test( "DRUM", test_55_check ); -} - -static int -test_56_check( libspectrum_snap *snap ) -{ - int failed = 0; - - if( libspectrum_snap_covox_active( snap ) != 1 ) failed = 1; - if( libspectrum_snap_covox_dac( snap ) != 0xc0 ) failed = 1; - - return failed; -} - -test_return_t -test_56( void ) -{ - return szx_read_block_test( "COVX", test_56_check ); -} - -static int -test_58_check( libspectrum_snap *snap ) -{ - return libspectrum_snap_zxmmc_active( snap ) != 1; -} - -test_return_t -test_58( void ) -{ - return szx_read_block_test( "ZMMC", test_58_check ); -} - -static int -empty_ram_page_check( libspectrum_snap *snap, - libspectrum_byte* (*get_ram_page)( libspectrum_snap*, int ) ) -{ - int failed = 0; - size_t i; - - libspectrum_byte *page = get_ram_page( snap, 0 ); - if( page ) { - for( i = 0; i < 0x4000; i++ ) { - if( page[i] ) { - failed = 1; - break; - } - } - } else { - failed = 1; - } - - return failed; -} - -static int -ramp_check( libspectrum_snap *snap ) -{ - return empty_ram_page_check( snap, libspectrum_snap_pages ); -} - -test_return_t -test_60( void ) -{ - return szx_read_block_test( "RAMP", ramp_check ); -} - -static int -atrp_check( libspectrum_snap *snap ) -{ - return empty_ram_page_check( snap, libspectrum_snap_zxatasp_ram ); -} - -test_return_t -test_63( void ) -{ - return szx_read_block_test( "ATRP", atrp_check ); -} - -static int -cfrp_check( libspectrum_snap *snap ) -{ - return empty_ram_page_check( snap, libspectrum_snap_zxcf_ram ); -} - -test_return_t -test_64( void ) -{ - return szx_read_block_test( "CFRP", cfrp_check ); -} - -test_return_t -test_68( void ) -{ - return szx_read_block_from_compressed_snap_test( "RAMP", ramp_check ); -} - -test_return_t -test_69( void ) -{ - return szx_read_block_from_compressed_snap_test( "ATRP", atrp_check ); -} - -test_return_t -test_70( void ) -{ - return szx_read_block_from_compressed_snap_test( "CFRP", cfrp_check ); -} diff --git a/libspectrum/test/test.c b/libspectrum/test/test.c deleted file mode 100644 index 363e30c..0000000 --- a/libspectrum/test/test.c +++ /dev/null @@ -1,1073 +0,0 @@ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "internals.h" -#include "test.h" - -const char *progname; -static const char *LIBSPECTRUM_MIN_VERSION = "0.4.0"; - -typedef test_return_t (*test_fn)( void ); - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -int -read_file( libspectrum_byte **buffer, size_t *length, const char *filename ) -{ - int fd; - struct stat info; - ssize_t bytes; - - fd = open( filename, O_RDONLY | O_BINARY ); - if( fd == -1 ) { - fprintf( stderr, "%s: couldn't open `%s': %s\n", progname, filename, - strerror( errno ) ); - return errno; - } - - if( fstat( fd, &info ) ) { - fprintf( stderr, "%s: couldn't stat `%s': %s\n", progname, filename, - strerror( errno ) ); - return errno; - } - - *length = info.st_size; - *buffer = libspectrum_new( libspectrum_byte, *length ); - - bytes = read( fd, *buffer, *length ); - if( bytes == -1 ) { - fprintf( stderr, "%s: error reading from `%s': %s\n", progname, filename, - strerror( errno ) ); - return errno; - } else if( bytes < *length ) { - fprintf( stderr, "%s: read only %lu of %lu bytes from `%s'\n", progname, - (unsigned long)bytes, (unsigned long)*length, filename ); - return 1; - } - - if( close( fd ) ) { - fprintf( stderr, "%s: error closing `%s': %s\n", progname, filename, - strerror( errno ) ); - return errno; - } - - return 0; -} - -static test_return_t -load_tape( libspectrum_tape **tape, const char *filename, - libspectrum_error expected_result ) -{ - libspectrum_byte *buffer = NULL; - size_t filesize = 0; - - if( read_file( &buffer, &filesize, filename ) ) return TEST_INCOMPLETE; - - *tape = libspectrum_tape_alloc(); - - if( libspectrum_tape_read( *tape, buffer, filesize, LIBSPECTRUM_ID_UNKNOWN, - filename ) != expected_result ) { - fprintf( stderr, "%s: reading `%s' did not give expected result\n", - progname, filename ); - libspectrum_tape_free( *tape ); - libspectrum_free( buffer ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); - - return TEST_PASS; -} - -static test_return_t -read_tape( const char *filename, libspectrum_error expected_result ) -{ - libspectrum_tape *tape; - test_return_t r; - - r = load_tape( &tape, filename, expected_result ); - if( r != TEST_PASS ) return r; - - if( libspectrum_tape_free( tape ) ) return TEST_INCOMPLETE; - - return TEST_PASS; -} - -static test_return_t -read_snap( const char *filename, const char *filename_to_pass, - libspectrum_error expected_result ) -{ - libspectrum_byte *buffer = NULL; - size_t filesize = 0; - libspectrum_snap *snap; - - if( read_file( &buffer, &filesize, filename ) ) return TEST_INCOMPLETE; - - snap = libspectrum_snap_alloc(); - - if( libspectrum_snap_read( snap, buffer, filesize, LIBSPECTRUM_ID_UNKNOWN, - filename_to_pass ) != expected_result ) { - fprintf( stderr, "%s: reading `%s' did not give expected result\n", - progname, filename ); - libspectrum_snap_free( snap ); - libspectrum_free( buffer ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); - - libspectrum_snap_free( snap ); - - return TEST_PASS; -} - -static test_return_t -play_tape( const char *filename ) -{ - libspectrum_byte *buffer = NULL; - size_t filesize = 0; - libspectrum_tape *tape; - libspectrum_dword tstates; - int flags; - - if( read_file( &buffer, &filesize, filename ) ) return TEST_INCOMPLETE; - - tape = libspectrum_tape_alloc(); - - if( libspectrum_tape_read( tape, buffer, filesize, LIBSPECTRUM_ID_UNKNOWN, - filename ) ) { - libspectrum_tape_free( tape ); - libspectrum_free( buffer ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); - - do { - - if( libspectrum_tape_get_next_edge( &tstates, &flags, tape ) ) { - libspectrum_tape_free( tape ); - return TEST_INCOMPLETE; - } - - } while( !( flags & LIBSPECTRUM_TAPE_FLAGS_STOP ) ); - - if( libspectrum_tape_free( tape ) ) return TEST_INCOMPLETE; - - return TEST_PASS; -} - -/* Specific tests begin here */ - -/* Test for bugs #47 and #78: tape object incorrectly freed after reading - invalid tape */ -static test_return_t -test_1( void ) -{ - return read_tape( STATIC_TEST_PATH( "invalid.tzx" ), LIBSPECTRUM_ERROR_UNKNOWN ); -} - -/* Test for bugs #84: TZX turbo blocks with zero pilot pulses and #85: freeing - a turbo block with no data produces segfault */ -static test_return_t -test_2( void ) -{ - libspectrum_byte *buffer = NULL; - size_t filesize = 0; - libspectrum_tape *tape; - const char *filename = STATIC_TEST_PATH( "turbo-zeropilot.tzx" ); - libspectrum_dword tstates; - int flags; - - if( read_file( &buffer, &filesize, filename ) ) return TEST_INCOMPLETE; - - tape = libspectrum_tape_alloc(); - - if( libspectrum_tape_read( tape, buffer, filesize, LIBSPECTRUM_ID_UNKNOWN, - filename ) ) { - libspectrum_tape_free( tape ); - libspectrum_free( buffer ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); - - if( libspectrum_tape_get_next_edge( &tstates, &flags, tape ) ) { - libspectrum_tape_free( tape ); - return TEST_INCOMPLETE; - } - - if( flags ) { - fprintf( stderr, "%s: reading first edge of `%s' gave unexpected flags 0x%04x; expected 0x0000\n", - progname, filename, flags ); - libspectrum_tape_free( tape ); - return TEST_FAIL; - } - - if( tstates != 667 ) { - fprintf( stderr, "%s: first edge of `%s' was %u tstates; expected 667\n", - progname, filename, tstates ); - libspectrum_tape_free( tape ); - return TEST_FAIL; - } - - if( libspectrum_tape_free( tape ) ) return TEST_INCOMPLETE; - - return TEST_PASS; -} - -/* Test for bug #88: writing empty .tap file causes crash */ -static test_return_t -test_3( void ) -{ - libspectrum_tape *tape; - libspectrum_byte *buffer = (libspectrum_byte*)1; - size_t length = 0; - - tape = libspectrum_tape_alloc(); - - if( libspectrum_tape_write( &buffer, &length, tape, LIBSPECTRUM_ID_TAPE_TAP ) ) { - libspectrum_tape_free( tape ); - return TEST_INCOMPLETE; - } - - /* `buffer' should now have been set to NULL */ - if( buffer ) { - fprintf( stderr, "%s: `buffer' was not NULL after libspectrum_tape_write()\n", progname ); - libspectrum_tape_free( tape ); - return TEST_FAIL; - } - - if( libspectrum_tape_free( tape ) ) return TEST_INCOMPLETE; - - return TEST_PASS; -} - -/* Test for bug #102: invalid compressed file causes crash */ -static test_return_t -test_4( void ) -{ - const char *filename = STATIC_TEST_PATH( "invalid.gz" ); - return read_snap( filename, filename, LIBSPECTRUM_ERROR_UNKNOWN ); -} - -/* Further test for bug #102: invalid compressed file causes crash */ -static test_return_t -test_5( void ) -{ - return read_snap( STATIC_TEST_PATH( "invalid.gz" ), NULL, LIBSPECTRUM_ERROR_UNKNOWN ); -} - -/* Test for bug #103: pointer wraparound causes segfault */ -static test_return_t -test_6( void ) -{ - const char *filename = STATIC_TEST_PATH( "invalid.szx" ); - return read_snap( filename, filename, LIBSPECTRUM_ERROR_CORRUPT ); -} - -/* Test for bug #105: lack of sanity check in GDB code */ -static test_return_t -test_7( void ) -{ - return read_tape( STATIC_TEST_PATH( "invalid-gdb.tzx" ), LIBSPECTRUM_ERROR_CORRUPT ); -} - -/* Test for bug #106: empty DRB causes segfault */ -static test_return_t -test_8( void ) -{ - return read_tape( STATIC_TEST_PATH( "empty-drb.tzx" ), LIBSPECTRUM_ERROR_NONE ); -} - -/* Test for bug #107: problems with invalid archive info block */ -static test_return_t -test_9( void ) -{ - return read_tape( STATIC_TEST_PATH( "invalid-archiveinfo.tzx" ), LIBSPECTRUM_ERROR_CORRUPT ); -} - -/* Test for bug #108: invalid hardware info blocks can leak memory */ -static test_return_t -test_10( void ) -{ - return read_tape( STATIC_TEST_PATH( "invalid-hardwareinfo.tzx" ), LIBSPECTRUM_ERROR_CORRUPT ); -} - -/* Test for bug #111: invalid Warajevo tape block offset causes segfault */ -static test_return_t -test_11( void ) -{ - return read_tape( STATIC_TEST_PATH( "invalid-warajevo-blockoffset.tap" ), LIBSPECTRUM_ERROR_CORRUPT ); -} - -/* Test for bug #112: invalid custom info block causes memory leak */ -static test_return_t -test_12( void ) -{ - return read_tape( STATIC_TEST_PATH( "invalid-custominfo.tzx" ), LIBSPECTRUM_ERROR_CORRUPT ); -} - -/* Test for bug #113: loop end without a loop start block accesses uninitialised - memory */ -static test_return_t -test_13( void ) -{ - libspectrum_byte *buffer = NULL; - size_t filesize = 0; - libspectrum_tape *tape; - const char *filename = STATIC_TEST_PATH( "loopend.tzx" ); - libspectrum_dword tstates; - int flags; - - if( read_file( &buffer, &filesize, filename ) ) return TEST_INCOMPLETE; - - tape = libspectrum_tape_alloc(); - - if( libspectrum_tape_read( tape, buffer, filesize, LIBSPECTRUM_ID_UNKNOWN, - filename ) ) { - libspectrum_tape_free( tape ); - libspectrum_free( buffer ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); - - if( libspectrum_tape_get_next_edge( &tstates, &flags, tape ) ) { - libspectrum_tape_free( tape ); - return TEST_INCOMPLETE; - } - - if( libspectrum_tape_free( tape ) ) return TEST_INCOMPLETE; - - return TEST_PASS; -} - -/* Test for bug #113: TZX loop blocks broken */ -static test_return_t -test_14( void ) -{ - return play_tape( STATIC_TEST_PATH( "loop.tzx" ) ); -} - -/* Test for bug #118: TZX loop blocks still broken */ -static test_return_t -test_16( void ) -{ - return play_tape( STATIC_TEST_PATH( "loop2.tzx" ) ); -} - -/* Test for bug #119: TZX jump blocks broken */ -static test_return_t -test_17( void ) -{ - return play_tape( STATIC_TEST_PATH( "jump.tzx" ) ); -} - -/* Test for bug #121: crashes writing and reading empty CSW files */ -static test_return_t -test_18( void ) -{ - return play_tape( STATIC_TEST_PATH( "empty.csw" ) ); -} - -/* Test for bug #125: .tap writing code does not handle all block types */ -static test_return_t -test_19( void ) -{ - libspectrum_byte *buffer = NULL; - size_t length = 0; - libspectrum_tape *tape; - const char *filename = DYNAMIC_TEST_PATH( "complete-tzx.tzx" ); - test_return_t r; - - r = load_tape( &tape, filename, LIBSPECTRUM_ERROR_NONE ); - if( r ) return r; - - if( libspectrum_tape_write( &buffer, &length, tape, - LIBSPECTRUM_ID_TAPE_TAP ) ) { - fprintf( stderr, "%s: writing `%s' to a .tap file was not successful\n", - progname, filename ); - libspectrum_tape_free( tape ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); - - if( libspectrum_tape_free( tape ) ) return TEST_INCOMPLETE; - - return TEST_PASS; -} - -/* Tests for bug #129: SP not sanity checked when reading .sna files; - also tests bug #130: compressed snapshots cause segfault */ -static test_return_t -test_20( void ) -{ - const char *filename = STATIC_TEST_PATH( "sp-2000.sna.gz" ); - return read_snap( filename, filename, LIBSPECTRUM_ERROR_CORRUPT ); -} - -static test_return_t -test_21( void ) -{ - const char *filename = STATIC_TEST_PATH( "sp-ffff.sna.gz" ); - return read_snap( filename, filename, LIBSPECTRUM_ERROR_CORRUPT ); -} - -/* Tests for bug #152: .mdr code does not correctly handle write protect flag */ -static test_return_t -test_22( void ) -{ - libspectrum_byte *buffer = NULL; - size_t filesize = 0; - libspectrum_microdrive *mdr; - const char *filename = STATIC_TEST_PATH( "writeprotected.mdr" ); - test_return_t r; - - if( read_file( &buffer, &filesize, filename ) ) return TEST_INCOMPLETE; - - /* writeprotected.mdr deliberately includes an extra 0 on the end; - we want this in the buffer so we know what happens if we read off the - end of the file; however, we don't want it in the length */ - filesize--; - - mdr = libspectrum_microdrive_alloc(); - - if( libspectrum_microdrive_mdr_read( mdr, buffer, filesize ) ) { - libspectrum_microdrive_free( mdr ); - libspectrum_free( buffer ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); - - r = libspectrum_microdrive_write_protect( mdr ) ? TEST_PASS : TEST_FAIL; - - libspectrum_microdrive_free( mdr ); - - return r; -} - -static test_return_t -test_23( void ) -{ - libspectrum_byte *buffer = NULL; - size_t filesize = 0, length; - libspectrum_microdrive *mdr; - const char *filename = STATIC_TEST_PATH( "writeprotected.mdr" ); - test_return_t r; - - if( read_file( &buffer, &filesize, filename ) ) return TEST_INCOMPLETE; - - /* writeprotected.mdr deliberately includes an extra 0 on the end; - we want this in the buffer so we know what happens if we read off the - end of the file; however, we don't want it in the length */ - filesize--; - - mdr = libspectrum_microdrive_alloc(); - - if( libspectrum_microdrive_mdr_read( mdr, buffer, filesize ) ) { - libspectrum_microdrive_free( mdr ); - libspectrum_free( buffer ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); buffer = NULL; - - libspectrum_microdrive_mdr_write( mdr, &buffer, &length ); - - libspectrum_microdrive_free( mdr ); - - r = ( length == filesize && buffer[ length - 1 ] == 1 ) ? TEST_PASS : TEST_FAIL; - - libspectrum_free( buffer ); - - return r; -} - -static test_return_t -test_24( void ) -{ - const char *filename = DYNAMIC_TEST_PATH( "complete-tzx.tzx" ); - libspectrum_byte *buffer = NULL; - size_t filesize = 0; - libspectrum_tape *tape; - libspectrum_tape_iterator it; - libspectrum_tape_block *block; - libspectrum_dword expected_sizes[20] = { - 15216886, /* ROM */ - 3493371, /* Turbo */ - 356310, /* Pure tone */ - 1761, /* Pulses */ - 1993724, /* Pure data */ - 2163000, /* Pause */ - 0, /* Group start */ - 0, /* Group end */ - 0, /* Jump */ - 205434, /* Pure tone */ - 0, /* Loop start */ - 154845, /* Pure tone */ - 0, /* Loop end */ - 0, /* Stop tape if in 48K mode */ - 0, /* Comment */ - 0, /* Message */ - 0, /* Archive info */ - 0, /* Hardware */ - 0, /* Custom info */ - 771620, /* Pure tone */ - }; - libspectrum_dword *next_size = &expected_sizes[ 0 ]; - test_return_t r = TEST_PASS; - - if( read_file( &buffer, &filesize, filename ) ) return TEST_INCOMPLETE; - - tape = libspectrum_tape_alloc(); - - if( libspectrum_tape_read( tape, buffer, filesize, LIBSPECTRUM_ID_UNKNOWN, - filename ) ) { - libspectrum_tape_free( tape ); - libspectrum_free( buffer ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); - - block = libspectrum_tape_iterator_init( &it, tape ); - - while( block ) - { - libspectrum_dword actual_size = libspectrum_tape_block_length( block ); - - if( actual_size != *next_size ) - { - fprintf( stderr, "%s: block had length %lu, but expected %lu\n", progname, (unsigned long)actual_size, (unsigned long)*next_size ); - r = TEST_FAIL; - break; - } - - block = libspectrum_tape_iterator_next( &it ); - next_size++; - } - - if( libspectrum_tape_free( tape ) ) return TEST_INCOMPLETE; - - return r; -} - -static test_return_t -test_25( void ) -{ - const char *filename = STATIC_TEST_PATH( "empty.z80" ); - libspectrum_byte *buffer = NULL; - size_t filesize = 0, length = 0; - libspectrum_snap *snap; - int flags; - test_return_t r = TEST_INCOMPLETE; - - if( read_file( &buffer, &filesize, filename ) ) return TEST_INCOMPLETE; - - snap = libspectrum_snap_alloc(); - - if( libspectrum_snap_read( snap, buffer, filesize, LIBSPECTRUM_ID_UNKNOWN, - filename ) != LIBSPECTRUM_ERROR_NONE ) { - fprintf( stderr, "%s: reading `%s' failed\n", progname, filename ); - libspectrum_snap_free( snap ); - libspectrum_free( buffer ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); - buffer = NULL; - - if( libspectrum_snap_write( &buffer, &length, &flags, snap, - LIBSPECTRUM_ID_SNAPSHOT_SNA, NULL, 0 ) != - LIBSPECTRUM_ERROR_NONE ) { - fprintf( stderr, "%s: serialising to SNA failed\n", progname ); - libspectrum_snap_free( snap ); - return TEST_INCOMPLETE; - } - - libspectrum_snap_free( snap ); - snap = libspectrum_snap_alloc(); - - if( libspectrum_snap_read( snap, buffer, length, LIBSPECTRUM_ID_SNAPSHOT_SNA, - NULL ) != LIBSPECTRUM_ERROR_NONE ) { - fprintf( stderr, "%s: restoring from SNA failed\n", progname ); - libspectrum_snap_free( snap ); - libspectrum_free( buffer ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); - - if( libspectrum_snap_pc( snap ) != 0x1234 ) { - fprintf( stderr, "%s: PC is 0x%04x, not the expected 0x1234\n", progname, - libspectrum_snap_pc( snap ) ); - r = TEST_FAIL; - } else if( libspectrum_snap_sp( snap ) != 0x8000 ) { - fprintf( stderr, "%s: SP is 0x%04x, not the expected 0x8000\n", progname, - libspectrum_snap_sp( snap ) ); - r = TEST_FAIL; - } else { - r = TEST_PASS; - } - - libspectrum_snap_free( snap ); - - return r; -} - -/* Tests for bug #198: last out to 0x1ffd is not serialised into .z80 files */ -static test_return_t -test_26( void ) -{ - const char *filename = STATIC_TEST_PATH( "plus3.z80" ); - libspectrum_byte *buffer = NULL; - size_t filesize = 0, length = 0; - libspectrum_snap *snap; - int flags; - test_return_t r = TEST_INCOMPLETE; - - if( read_file( &buffer, &filesize, filename ) ) return TEST_INCOMPLETE; - - snap = libspectrum_snap_alloc(); - - if( libspectrum_snap_read( snap, buffer, filesize, LIBSPECTRUM_ID_UNKNOWN, - filename ) != LIBSPECTRUM_ERROR_NONE ) { - fprintf( stderr, "%s: reading `%s' failed\n", progname, filename ); - libspectrum_snap_free( snap ); - libspectrum_free( buffer ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); - buffer = NULL; - - if( libspectrum_snap_write( &buffer, &length, &flags, snap, - LIBSPECTRUM_ID_SNAPSHOT_Z80, NULL, 0 ) != - LIBSPECTRUM_ERROR_NONE ) { - fprintf( stderr, "%s: serialising to Z80 failed\n", progname ); - libspectrum_snap_free( snap ); - return TEST_INCOMPLETE; - } - - libspectrum_snap_free( snap ); - snap = libspectrum_snap_alloc(); - - if( libspectrum_snap_read( snap, buffer, length, LIBSPECTRUM_ID_SNAPSHOT_Z80, - NULL ) != LIBSPECTRUM_ERROR_NONE ) { - fprintf( stderr, "%s: restoring from Z80 failed\n", progname ); - libspectrum_snap_free( snap ); - libspectrum_free( buffer ); - return TEST_INCOMPLETE; - } - - if( libspectrum_snap_out_plus3_memoryport( snap ) == 0xaa ) { - r = TEST_PASS; - } else { - fprintf( stderr, - "%s: Last out to 0x1ffd is 0x%02x, not the expected 0xaa\n", - progname, libspectrum_snap_out_plus3_memoryport( snap ) ); - r = TEST_FAIL; - } - - libspectrum_snap_free( snap ); - - return r; -} - -/* Tests for bug #184: SZX files were written with A and F reversed */ -static test_return_t -test_27( void ) -{ - const char *filename = STATIC_TEST_PATH( "empty.szx" ); - libspectrum_byte *buffer = NULL; - size_t filesize = 0; - libspectrum_snap *snap; - test_return_t r = TEST_INCOMPLETE; - - if( read_file( &buffer, &filesize, filename ) ) return TEST_INCOMPLETE; - - snap = libspectrum_snap_alloc(); - - if( libspectrum_snap_read( snap, buffer, filesize, LIBSPECTRUM_ID_UNKNOWN, - filename ) != LIBSPECTRUM_ERROR_NONE ) { - fprintf( stderr, "%s: reading `%s' failed\n", progname, filename ); - libspectrum_snap_free( snap ); - libspectrum_free( buffer ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); - - if( libspectrum_snap_a( snap ) != 0x12 ) { - fprintf( stderr, "%s: A is 0x%02x, not the expected 0x12\n", progname, - libspectrum_snap_a( snap ) ); - r = TEST_FAIL; - } else if( libspectrum_snap_f( snap ) != 0x34 ) { - fprintf( stderr, "%s: F is 0x%02x, not the expected 0x34\n", progname, - libspectrum_snap_f( snap ) ); - r = TEST_FAIL; - } else if( libspectrum_snap_a_( snap ) != 0x56 ) { - fprintf( stderr, "%s: A' is 0x%02x, not the expected 0x56\n", progname, - libspectrum_snap_a_( snap ) ); - r = TEST_FAIL; - } else if( libspectrum_snap_f_( snap ) != 0x78 ) { - fprintf( stderr, "%s: F' is 0x%02x, not the expected 0x78\n", progname, - libspectrum_snap_f_( snap ) ); - r = TEST_FAIL; - } else { - r = TEST_PASS; - } - - return r; -} - -/* Test for bug #379: converting .tap file to .csw causes crash */ -static test_return_t -test_30( void ) -{ - libspectrum_byte *buffer = NULL; - size_t length = 0; - libspectrum_tape *tape; - const char *filename = DYNAMIC_TEST_PATH( "standard-tap.tap" ); - test_return_t r; - - r = load_tape( &tape, filename, LIBSPECTRUM_ERROR_NONE ); - if( r ) return r; - - if( libspectrum_tape_write( &buffer, &length, tape, - LIBSPECTRUM_ID_TAPE_CSW ) ) { - fprintf( stderr, "%s: writing `%s' to a .csw file was not successful\n", - progname, filename ); - libspectrum_tape_free( tape ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); - - if( libspectrum_tape_free( tape ) ) return TEST_INCOMPLETE; - - return TEST_PASS; -} - -static test_return_t -test_71( void ) -{ - const char *filename = STATIC_TEST_PATH( "random.szx" ); - libspectrum_byte *buffer = NULL; - size_t filesize = 0; - size_t rzx_length = 0; - libspectrum_snap *snap; - libspectrum_rzx *rzx; - test_return_t r = TEST_INCOMPLETE; - - if( read_file( &buffer, &filesize, filename ) ) return TEST_INCOMPLETE; - - snap = libspectrum_snap_alloc(); - - if( libspectrum_snap_read( snap, buffer, filesize, LIBSPECTRUM_ID_UNKNOWN, - filename ) != LIBSPECTRUM_ERROR_NONE ) { - fprintf( stderr, "%s: reading `%s' failed\n", progname, filename ); - libspectrum_snap_free( snap ); - libspectrum_free( buffer ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); - - rzx = libspectrum_rzx_alloc(); - - if( libspectrum_rzx_add_snap( rzx, snap, 0 ) != LIBSPECTRUM_ERROR_NONE ) { - fprintf( stderr, "%s: adding snap failed\n", progname ); - libspectrum_rzx_free( rzx ); - libspectrum_snap_free( snap ); - return TEST_INCOMPLETE; - } - - if( libspectrum_rzx_write( &buffer, &rzx_length, rzx, - LIBSPECTRUM_ID_SNAPSHOT_SZX, NULL, 1, NULL ) != LIBSPECTRUM_ERROR_NONE ) { - fprintf( stderr, "%s: error serializing RZX\n", progname ); - libspectrum_rzx_free( rzx ); - return TEST_INCOMPLETE; - } - - libspectrum_rzx_free( rzx ); - libspectrum_free( buffer ); - - if( rzx_length > 49152 ) { - r = TEST_PASS; - } else { - fprintf( stderr, "%s: length %lu too short\n", progname, - (unsigned long)rzx_length ); - r = TEST_FAIL; - } - - return r; -} - -static test_return_t -test_72( void ) -{ - const char *filename = DYNAMIC_TEST_PATH( "complete-tzx.tzx" ); - libspectrum_byte *buffer = NULL; - size_t filesize = 0; - libspectrum_tape *tape; - libspectrum_tape_iterator it; - libspectrum_tape_type expected_next_block_types[19] = { - LIBSPECTRUM_TAPE_BLOCK_TURBO, /* ROM */ - LIBSPECTRUM_TAPE_BLOCK_PURE_TONE, /* Turbo */ - LIBSPECTRUM_TAPE_BLOCK_PULSES, /* Pure tone */ - LIBSPECTRUM_TAPE_BLOCK_PURE_DATA, /* Pulses */ - LIBSPECTRUM_TAPE_BLOCK_PAUSE, /* Pure data */ - LIBSPECTRUM_TAPE_BLOCK_GROUP_START, /* Pause */ - LIBSPECTRUM_TAPE_BLOCK_GROUP_END, /* Group start */ - LIBSPECTRUM_TAPE_BLOCK_JUMP, /* Group end */ - LIBSPECTRUM_TAPE_BLOCK_PURE_TONE, /* Jump */ - LIBSPECTRUM_TAPE_BLOCK_LOOP_START, /* Pure tone */ - LIBSPECTRUM_TAPE_BLOCK_PURE_TONE, /* Loop start */ - LIBSPECTRUM_TAPE_BLOCK_LOOP_END, /* Pure tone */ - LIBSPECTRUM_TAPE_BLOCK_STOP48, /* Loop end */ - LIBSPECTRUM_TAPE_BLOCK_COMMENT, /* Stop tape if in 48K mode */ - LIBSPECTRUM_TAPE_BLOCK_MESSAGE, /* Comment */ - LIBSPECTRUM_TAPE_BLOCK_ARCHIVE_INFO,/* Message */ - LIBSPECTRUM_TAPE_BLOCK_HARDWARE, /* Archive info */ - LIBSPECTRUM_TAPE_BLOCK_CUSTOM, /* Hardware */ - LIBSPECTRUM_TAPE_BLOCK_PURE_TONE, /* Custom info */ - }; - libspectrum_tape_type *next_block_type = &expected_next_block_types[ 0 ]; - test_return_t r = TEST_PASS; - int blocks_processed = 0; - /* Expect to check the next block type of 19 of the 20 blocks in the test - tzx */ - int expected_block_count = ARRAY_SIZE( expected_next_block_types ); - - if( read_file( &buffer, &filesize, filename ) ) return TEST_INCOMPLETE; - - tape = libspectrum_tape_alloc(); - - if( libspectrum_tape_read( tape, buffer, filesize, LIBSPECTRUM_ID_UNKNOWN, - filename ) ) - { - libspectrum_tape_free( tape ); - libspectrum_free( buffer ); - return TEST_INCOMPLETE; - } - - libspectrum_free( buffer ); - - libspectrum_tape_iterator_init( &it, tape ); - - while( libspectrum_tape_iterator_peek_next( it ) ) - { - libspectrum_tape_type actual_next_block_type = - libspectrum_tape_block_type( libspectrum_tape_iterator_peek_next( it ) ); - - if( actual_next_block_type != *next_block_type ) - { - r = TEST_FAIL; - break; - } - - libspectrum_tape_iterator_next( &it ); - next_block_type++; - blocks_processed++; - } - - if( blocks_processed != expected_block_count ) - { - r = TEST_FAIL; - } - - if( libspectrum_tape_free( tape ) ) return TEST_INCOMPLETE; - - return r; -} - -struct test_description { - - test_fn test; - const char *description; - int active; - -}; - -static struct test_description tests[] = { - { test_1, "Tape with unknown block", 0 }, - { test_2, "TZX turbo data with zero pilot pulses and zero data", 0 }, - { test_3, "Writing empty .tap file", 0 }, - { test_4, "Invalid compressed file 1", 0 }, - { test_5, "Invalid compressed file 2", 0 }, - { test_6, "Pointer wraparound in SZX file", 0 }, - { test_7, "Invalid TZX GDB", 0 }, - { test_8, "Empty TZX DRB", 0 }, - { test_9, "Invalid TZX archive info block", 0 }, - { test_10, "Invalid hardware info block causes memory leak", 0 }, - { test_11, "Invalid Warajevo tape file", 0 }, - { test_12, "Invalid TZX custom info block causes memory leak", 0 }, - { test_13, "TZX loop end block with loop start block", 0 }, - { test_14, "TZX loop blocks", 0 }, - { test_15, "Complete TZX file", 0 }, - { test_16, "TZX loop blocks 2", 0 }, - { test_17, "TZX jump blocks", 0 }, - { test_18, "CSW empty file", 0 }, - { test_19, "Complete TZX to TAP conversion", 0 }, - { test_20, "SNA file with SP < 0x4000", 0 }, - { test_21, "SNA file with SP = 0xffff", 0 }, - { test_22, "MDR write protection 1", 0 }, - { test_23, "MDR write protection 2", 0 }, - { test_24, "Complete TZX timings", 0 }, - { test_25, "Writing SNA file", 0 }, - { test_26, "Writing +3 .Z80 file", 0 }, - { test_27, "Reading old SZX file", 0 }, - { test_28, "Zero tail length PZX file", 0 }, - { test_29, "No pilot pulse GDB TZX file", 0 }, - { test_30, "CSW conversion", 0 }, - { test_31, "Write SZX Z80R chunk", 0 }, - { test_32, "Write SZX SPCR chunk", 0 }, - { test_33, "Write SZX JOY chunk", 0 }, - { test_34, "Write SZX KEYB chunk", 0 }, - { test_35, "Write SZX ZXPR chunk", 0 }, - { test_36, "Write SZX AY chunk", 0 }, - { test_37, "Write SZX SCLD chunk", 0 }, - { test_38, "Write SZX ZXAT chunk", 0 }, - { test_39, "Write SZX ZXCF chunk", 0 }, - { test_40, "Write SZX AMXM chunk", 0 }, - { test_41, "Write SZX SIDE chunk", 0 }, - { test_42, "Write SZX DRUM chunk", 0 }, - { test_43, "Write SZX COVX chunk", 0 }, - { test_44, "Read SZX Z80R chunk", 0 }, - { test_45, "Read SZX SPCR chunk", 0 }, - { test_46, "Read SZX JOY chunk", 0 }, - { test_47, "Read SZX KEYB chunk", 0 }, - { test_48, "Read SZX ZXPR chunk", 0 }, - { test_49, "Read SZX AY chunk", 0 }, - { test_50, "Read SZX SCLD chunk", 0 }, - { test_51, "Read SZX ZXAT chunk", 0 }, - { test_52, "Read SZX ZXCF chunk", 0 }, - { test_53, "Read SZX AMXM chunk", 0 }, - { test_54, "Read SZX SIDE chunk", 0 }, - { test_55, "Read SZX DRUM chunk", 0 }, - { test_56, "Read SZX COVX chunk", 0 }, - { test_57, "Write SZX ZMMC chunk", 0 }, - { test_58, "Read SZX ZMMC chunk", 0 }, - { test_59, "Write SZX RAMP chunk", 0 }, - { test_60, "Read SZX RAMP chunk", 0 }, - { test_61, "Write SZX ATRP chunk", 0 }, - { test_62, "Write SZX CFRP chunk", 0 }, - { test_63, "Read SZX ATRP chunk", 0 }, - { test_64, "Read SZX CFRP chunk", 0 }, - { test_65, "Write uncompressed SZX RAMP chunk", 0 }, - { test_66, "Write uncompressed SZX ATRP chunk", 0 }, - { test_67, "Write uncompressed SZX CFRP chunk", 0 }, - { test_68, "Read uncompressed SZX RAMP chunk", 0 }, - { test_69, "Read uncompressed SZX ATRP chunk", 0 }, - { test_70, "Read uncompressed SZX CFRP chunk", 0 }, - { test_71, "Write RZX with incompressible snap", 0 }, - { test_72, "Tape peek next block", 0 }, - { test_73, "Read TZX RAW block edge handling", 0 }, - { test_74, "Trailing pause block TZX file", 0 } -}; - -static size_t test_count = ARRAY_SIZE( tests ); - -static void -parse_test_specs( char **specs, int count ) -{ - int i, j; - - for( i = 0; i < count; i++ ) { - - const char *spec = specs[i]; - const char *dash = strchr( spec, '-' ); - - if( dash ) { - int begin = atoi( spec ), end = atoi( dash + 1 ); - if( begin < 1 ) begin = 1; - if( end == 0 || end > test_count ) end = test_count; - for( j = begin; j <= end; j++ ) tests[j-1].active = 1; - } else { - int test = atoi( spec ); - if( test < 1 || test > test_count ) continue; - tests[ test - 1 ].active = 1; - } - - } -} - -int -main( int argc, char *argv[] ) -{ - struct test_description *test; - size_t i; - int tests_done = 0, tests_skipped = 0; - int pass = 0, fail = 0, incomplete = 0; - - progname = argv[0]; - - if( libspectrum_check_version( LIBSPECTRUM_MIN_VERSION ) ) { - if( libspectrum_init() ) return 2; - } else { - fprintf( stderr, "%s: libspectrum version %s found, but %s required", - progname, libspectrum_version(), LIBSPECTRUM_MIN_VERSION ); - return 2; - } - - if( argc < 2 ) { - for( i = 0; i < test_count; i++ ) tests[i].active = 1; - } else { - parse_test_specs( &argv[1], argc - 1 ); - } - - for( i = 0, test = tests; - i < test_count; - i++, test++ ) { - printf( "Test %d: %s... ", (int)i + 1, test->description ); - if( test->active ) { - tests_done++; - switch( test->test() ) { - case TEST_PASS: - printf( "passed\n" ); - pass++; - break; - case TEST_FAIL: - printf( "FAILED\n" ); - fail++; - break; - case TEST_INCOMPLETE: - printf( "NOT COMPLETE\n" ); - incomplete++; - break; - } - } else { - tests_skipped++; - printf( "skipped\n" ); - } - - } - - /* Stop silly divisions occuring */ - if( !tests_done ) tests_done = 1; - - printf( "\n%3d tests run\n\n", (int)test_count ); - printf( "%3d passed (%6.2f%%)\n", pass, 100 * (float)pass/tests_done ); - printf( "%3d failed (%6.2f%%)\n", fail, 100 * (float)fail/tests_done ); - printf( "%3d incomplete (%6.2f%%)\n", incomplete, 100 * (float)incomplete/tests_done ); - printf( "%3d skipped\n", tests_skipped ); - - if( fail == 0 && incomplete == 0 ) { - return 0; - } else { - return 1; - } -} diff --git a/libspectrum/test/test.h b/libspectrum/test/test.h deleted file mode 100644 index 04bd898..0000000 --- a/libspectrum/test/test.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef TEST_TEST_H -#define TEST_TEST_H - -#include "libspectrum.h" - -extern const char *progname; - -typedef enum test_return_t { - TEST_PASS, - TEST_FAIL, - TEST_INCOMPLETE, -} test_return_t; - -typedef struct test_edge_sequence_t { - - libspectrum_dword length; - size_t count; - int flags; - -} test_edge_sequence_t; - -#define STATIC_TEST_PATH(x) SRCDIR "/test/" x -#define DYNAMIC_TEST_PATH(x) "test/" x - -int read_file( libspectrum_byte **buffer, size_t *length, - const char *filename ); - -test_return_t check_edges( const char *filename, test_edge_sequence_t *edges, - int flags_mask ); - -test_return_t test_15( void ); -test_return_t test_28( void ); -test_return_t test_29( void ); -test_return_t test_73( void ); -test_return_t test_74( void ); - -/* SZX write tests */ -test_return_t test_31( void ); -test_return_t test_32( void ); -test_return_t test_33( void ); -test_return_t test_34( void ); -test_return_t test_35( void ); -test_return_t test_36( void ); -test_return_t test_37( void ); -test_return_t test_38( void ); -test_return_t test_39( void ); -test_return_t test_40( void ); -test_return_t test_41( void ); -test_return_t test_42( void ); -test_return_t test_43( void ); -test_return_t test_57( void ); -test_return_t test_59( void ); -test_return_t test_61( void ); -test_return_t test_62( void ); -test_return_t test_65( void ); -test_return_t test_66( void ); -test_return_t test_67( void ); - -/* SZX read tests */ -test_return_t test_44( void ); -test_return_t test_45( void ); -test_return_t test_46( void ); -test_return_t test_47( void ); -test_return_t test_48( void ); -test_return_t test_49( void ); -test_return_t test_50( void ); -test_return_t test_51( void ); -test_return_t test_52( void ); -test_return_t test_53( void ); -test_return_t test_54( void ); -test_return_t test_55( void ); -test_return_t test_56( void ); -test_return_t test_58( void ); -test_return_t test_60( void ); -test_return_t test_63( void ); -test_return_t test_64( void ); -test_return_t test_68( void ); -test_return_t test_69( void ); -test_return_t test_70( void ); - -#endif diff --git a/libspectrum/test/test_edges.c b/libspectrum/test/test_edges.c deleted file mode 100644 index eb3c787..0000000 --- a/libspectrum/test/test_edges.c +++ /dev/null @@ -1,264 +0,0 @@ -#include "test.h" - -static test_edge_sequence_t -complete_edges_list[] = -{ - /* Standard speed data block */ - { 2168, 3223, 0 }, /* Pilot */ - { 667, 1, 0 }, /* Sync 1 */ - { 735, 1, 0 }, /* Sync 2 */ - - { 1710, 2, 0 }, /* Bit 1 */ - { 855, 2, 0 }, /* Bit 2 */ - { 1710, 2, 0 }, /* Bit 3 */ - { 855, 2, 0 }, /* Bit 4 */ - { 1710, 2, 0 }, /* Bit 5 */ - { 855, 2, 0 }, /* Bit 6 */ - { 1710, 2, 0 }, /* Bit 7 */ - { 855, 2, 0 }, /* Bit 8 */ - - { 8207500, 1, 0 }, /* Pause */ - - /* Turbo speed data block */ - { 1000, 5, 0 }, /* Pilot */ - { 123, 1, 0 }, /* Sync 1 */ - { 456, 1, 0 }, /* Sync 2 */ - - { 789, 16, 0 }, /* Byte 1, bits 1-8 */ - { 400, 16, 0 }, /* Byte 2, bits 1-8 */ - - { 789, 2, 0 }, /* Byte 3, bit 1 */ - { 400, 2, 0 }, /* Byte 3, bit 2 */ - { 789, 2, 0 }, /* Byte 3, bit 3 */ - { 400, 2, 0 }, /* Byte 3, bit 4 */ - { 789, 2, 0 }, /* Byte 3, bit 5 */ - { 400, 2, 0 }, /* Byte 3, bit 6 */ - { 789, 2, 0 }, /* Byte 3, bit 7 */ - { 400, 2, 0 }, /* Byte 3, bit 8 */ - - { 400, 2, 0 }, /* Byte 4, bit 1 */ - { 789, 2, 0 }, /* Byte 4, bit 2 */ - { 400, 2, 0 }, /* Byte 4, bit 3 */ - { 789, 2, 0 }, /* Byte 4, bit 4 */ - - { 3454500, 1, 0 }, /* Pause */ - - /* Pure tone block */ - { 535, 666, 0 }, - - /* List of pulses */ - { 772, 1, 0 }, - { 297, 1, 0 }, - { 692, 1, 0 }, - - /* Pure data block */ - { 1639, 16, 0 }, /* Byte 1, bits 1-8 */ - { 552, 16, 0 }, /* Byte 2, bits 1-8 */ - { 1639, 12, 0 }, /* Byte 3, bits 1-6 */ - { 1939000, 1, 0 }, /* Pause */ - - /* Pause block */ - { 2163000, 1, 0 }, - - /* Group start block */ - { 0, 1, 8 }, - - /* Group end block */ - { 0, 1, 8 }, - - /* Jump block */ - { 0, 1, 8 }, - - /* Pure tone block skipped */ - - /* Loop start block */ - { 0, 1, 8 }, - - /* Iteration 1 */ - { 837, 185, 0 }, /* Pure tone block */ - { 0, 1, 8 }, /* Loop end block */ - - /* Iteration 2 */ - { 837, 185, 0 }, /* Pure tone block */ - { 0, 1, 8 }, /* Loop end block */ - - /* Iteration 3 */ - { 837, 185, 0 }, /* Pure tone block */ - { 0, 1, 8 }, /* Loop end block */ - - /* Stop tape if in 48K mode block */ - { 0, 1, 12 }, - - /* Text description block */ - { 0, 1, 8 }, - - /* Message block */ - { 0, 1, 8 }, - - /* Archive info block */ - { 0, 1, 8 }, - - /* Hardware info block */ - { 0, 1, 8 }, - - /* Custom info block */ - { 0, 1, 8 }, - - /* Pure tone block */ - { 820, 940, 0 }, - { 820, 1, 2 }, - - { -1, 0, 0 } /* End marker */ - -}; - -test_return_t -test_15( void ) -{ - return check_edges( DYNAMIC_TEST_PATH( "complete-tzx.tzx" ), complete_edges_list, - LIBSPECTRUM_TAPE_FLAGS_STOP | - LIBSPECTRUM_TAPE_FLAGS_STOP48 | - LIBSPECTRUM_TAPE_FLAGS_NO_EDGE ); -} - -static test_edge_sequence_t -zero_tail_edges_list[] = -{ - /* Data block with 0 tail */ - { 855, 1, 96 }, /* Data short pulse 1 high */ - { 855, 1, 80 }, /* Data short pulse 2 low */ - { 0, 1, 9 }, /* No edge for tail, end of block */ - - /* Pulse block */ - { 200, 1, 32 }, /* Following pulse 1 high */ - { 200, 1, 275 }, /* Following pulse 2 low, end of block, end of tape, - stop the tape */ - - { -1, 0, 0 } /* End marker */ - -}; - -test_return_t -test_28( void ) -{ - return check_edges( DYNAMIC_TEST_PATH( "zero-tail.pzx" ), - zero_tail_edges_list, 0x1ff ); -} - -static test_edge_sequence_t -no_pilot_gdb_list[] = -{ - /* Set signal level block */ - { 0, 1, 17 }, /* Set signal level low, end of block */ - - /* GDB with 0 tail */ - { 771, 1, 0 }, /* Byte 1, bit 1, pulse 1 */ - { 1542, 1, 0 }, /* Byte 1, bit 1, pulse 2 */ - { 771, 1, 0 }, /* Byte 1, bit 2, pulse 1 */ - { 1542, 1, 0 }, /* Byte 1, bit 2, pulse 2 */ - { 771, 1, 0 }, /* Byte 1, bit 3, pulse 1 */ - { 1542, 1, 0 }, /* Byte 1, bit 3, pulse 2 */ - { 771, 1, 0 }, /* Byte 1, bit 4, pulse 1 */ - { 1542, 1, 0 }, /* Byte 1, bit 4, pulse 2 */ - { 771, 1, 0 }, /* Byte 1, bit 5, pulse 1 */ - { 1542, 1, 0 }, /* Byte 1, bit 5, pulse 2 */ - { 771, 1, 0 }, /* Byte 1, bit 6, pulse 1 */ - { 1542, 1, 0 }, /* Byte 1, bit 6, pulse 2 */ - { 771, 1, 0 }, /* Byte 1, bit 7, pulse 1 */ - { 1542, 1, 0 }, /* Byte 1, bit 7, pulse 2 */ - { 771, 1, 0 }, /* Byte 1, bit 8, pulse 1 */ - { 1542, 1, 0 }, /* Byte 1, bit 8, pulse 2 */ - { 771, 1, 0 }, /* Byte 2, bit 1, pulse 1 */ - { 1542, 1, 0 }, /* Byte 2, bit 1, pulse 2 */ - { 771, 1, 0 }, /* Byte 2, bit 2, pulse 1 */ - { 1542, 1, 0 }, /* Byte 2, bit 2, pulse 2 */ - { 771, 1, 0 }, /* Byte 2, bit 3, pulse 1 */ - { 1542, 1, 0 }, /* Byte 2, bit 3, pulse 2 */ - { 771, 1, 0 }, /* Byte 2, bit 4, pulse 1 */ - { 1542, 1, 0 }, /* Byte 2, bit 4, pulse 2 */ - { 771, 1, 0 }, /* Byte 2, bit 5, pulse 1 */ - { 1542, 1, 0 }, /* Byte 2, bit 5, pulse 2 */ - { 771, 1, 0 }, /* Byte 2, bit 6, pulse 1 */ - { 1542, 1, 0 }, /* Byte 2, bit 6, pulse 2 */ - { 771, 1, 0 }, /* Byte 2, bit 7, pulse 1 */ - { 1542, 1, 0 }, /* Byte 2, bit 7, pulse 2 */ - { 771, 1, 0 }, /* Byte 2, bit 8, pulse 1 */ - { 1542, 1, 0 }, /* Byte 2, bit 8, pulse 2 */ - { 0, 1, 259 }, /* End of block, end of tape, stop the tape (normally no - edge but not at end of tape) */ - - { -1, 0, 0 } /* End marker */ - -}; - -test_return_t -test_29( void ) -{ - return check_edges( DYNAMIC_TEST_PATH( "no-pilot-gdb.tzx" ), - no_pilot_gdb_list, 0x1ff ); -} - -static test_edge_sequence_t -raw_edges_list[] = -{ - /* RAW block with end of tape edge */ - { 40, 1, 32 }, /* Pulse 1 high */ - { 40, 1, 16 }, /* Pulse 2 low */ - { 40, 1, 32 }, /* Pulse 3 high */ - { 40, 1, 16 }, /* Pulse 4 low */ - { 10, 1, 32 }, /* Pulse 5 high */ - { 10, 1, 16 }, /* Pulse 6 low */ - { 20, 1, 32 }, /* Pulse 7 high */ - { 0, 1, 259 }, /* End of block, end of tape, stop the tape (normally no - edge but not at end of tape) */ - - { -1, 0, 0 } /* End marker */ - -}; - -/* Test for bugs #369: TZX raw block last edge handling, #444: Spurious - pulse at the beginning of a raw data block and #445 "Used bits in last - byte" takes the LSB in raw data blocks*/ -test_return_t -test_73( void ) -{ - return check_edges( DYNAMIC_TEST_PATH( "raw-data-block.tzx" ), - raw_edges_list, 0xffff ); -} - -static test_edge_sequence_t -trailing_pause_edges_list[] = -{ - /* Standard speed data block */ - { 2168, 3223, 0 }, /* Pilot */ - { 667, 1, 0 }, /* Sync 1 */ - { 735, 1, 0 }, /* Sync 2 */ - - { 1710, 2, 0 }, /* Bit 1 */ - { 1710, 2, 0 }, /* Bit 2 */ - { 1710, 2, 0 }, /* Bit 3 */ - { 1710, 2, 0 }, /* Bit 4 */ - { 1710, 2, 0 }, /* Bit 5 */ - { 1710, 2, 0 }, /* Bit 6 */ - { 1710, 2, 0 }, /* Bit 7 */ - { 1710, 2, 0 }, /* Bit 8 */ - - { 0, 1, 8 }, /* 0ms Trailing pause End of block, no edge */ - - /* 1s Pause block */ - { 3500000, 1, 0 }, /* Pulse End of block, end of tape, stop the tape - (should have an edge and not override the level) */ - - { -1, 0, 0 } /* End marker */ - -}; - -test_return_t -test_74( void ) -{ - return check_edges( DYNAMIC_TEST_PATH( "trailing-pause-block.tzx" ), - trailing_pause_edges_list, - LIBSPECTRUM_TAPE_FLAGS_NO_EDGE | - LIBSPECTRUM_TAPE_FLAGS_LEVEL_LOW | - LIBSPECTRUM_TAPE_FLAGS_LEVEL_HIGH ); -} \ No newline at end of file diff --git a/libspectrum/test/trailing-pause-block.tzx b/libspectrum/test/trailing-pause-block.tzx deleted file mode 100644 index d0791b126bbdb1842d97044397b3b6c24a18fb74..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 19 acma!w2uUnRRg_{B5MW?nWcaV}f*AlW00g7} diff --git a/libspectrum/test/turbo-zeropilot.tzx b/libspectrum/test/turbo-zeropilot.tzx deleted file mode 100644 index 7f0da2d5d0ba0b27f4c249f082300f95f4c252b2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 29 jcma!w2uUnRRg_{>5Uk*s&2*nBoOvA^0|UbgW*`9oa`gtG diff --git a/libspectrum/test/writeprotected.mdr b/libspectrum/test/writeprotected.mdr deleted file mode 100644 index 5b26aa244320b88bb4f69f6244a1ae8417028096..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5432 wcmeIuF#!Mo48x$zzv-Pd0TL(-7%*VKfB^#r3>YwAz<>b*1`HT5U|<8+0~I;|0ssI2 diff --git a/libspectrum/test/zero-tail.pzx b/libspectrum/test/zero-tail.pzx deleted file mode 100644 index 39371c90df809491da3b3570e19fe85229d22cdb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 49 zcmWHDiU?t1U|?WmaB&QA6a=#v8W - -#define ui_error_specific fuse_ui_error_specific -#include -#undef ui_error_specific diff --git a/src/fuse/options_enumerate.c b/src/fuse/options_enumerate.c new file mode 100644 index 0000000..fd9acd3 --- /dev/null +++ b/src/fuse/options_enumerate.c @@ -0,0 +1,231 @@ +/* options_enumerate.c: map string-valued settings onto their enum values + Copyright (c) 2001-2013 Philip Kendall + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + Author contact information: + + E-mail: philip-fuse@shadowmagic.org.uk + +*/ + +/* Extracted verbatim from fuse/ui/widget/options.c (generated there by + options.pl from options.dat) when the widget UI was removed: these + option_enumerate_*() mappings are consumed by the emulation proper - + sound.c for the speaker type and AY stereo separation, the disk + peripherals and +3 for the drive types, uimedia.c for disk merging - + and are the only part of that generated file the core ever executed. + The combo tables give the canonical spelling of each string setting; + the last argument of each mapping is the default enum value when the + setting is unset or not recognised. */ + +#include + +#include + +#include "settings.h" + +static int +option_enumerate_combo( const char * const *options, char *value, int def ) { + int i; + if( value != NULL ) { + for( i = 0; options[i] != NULL; i++) { + if( !strcmp( value, options[ i ] ) ) + return i; + } + } + return def; +} + +static const char * const widget_stereo_ay_combo[] = { + "None", + "ACB", + "ABC", + NULL +}; + +int +option_enumerate_sound_stereo_ay( void ) { + return option_enumerate_combo( widget_stereo_ay_combo, + settings_current.stereo_ay, + 0 ); +} + +static const char * const widget_speaker_type_combo[] = { + "TV speaker", + "Beeper", + "Unfiltered", + NULL +}; + +int +option_enumerate_sound_speaker_type( void ) { + return option_enumerate_combo( widget_speaker_type_combo, + settings_current.speaker_type, + 0 ); +} + +static const char * const widget_drive_plus3a_type_combo[] = { + "Single-sided 40 track", + "Double-sided 40 track", + "Single-sided 80 track", + "Double-sided 80 track", + NULL +}; + +int +option_enumerate_diskoptions_drive_plus3a_type( void ) { + return option_enumerate_combo( widget_drive_plus3a_type_combo, + settings_current.drive_plus3a_type, + 0 ); +} + +static const char * const widget_drive_plus3b_type_combo[] = { + "Disabled", + "Single-sided 40 track", + "Double-sided 40 track", + "Single-sided 80 track", + "Double-sided 80 track", + NULL +}; + +int +option_enumerate_diskoptions_drive_plus3b_type( void ) { + return option_enumerate_combo( widget_drive_plus3b_type_combo, + settings_current.drive_plus3b_type, + 4 ); +} + +#define widget_drive_beta128a_type_combo widget_drive_plus3a_type_combo + +int +option_enumerate_diskoptions_drive_beta128a_type( void ) { + return option_enumerate_combo( widget_drive_beta128a_type_combo, + settings_current.drive_beta128a_type, + 3 ); +} + +#define widget_drive_beta128b_type_combo widget_drive_plus3b_type_combo + +int +option_enumerate_diskoptions_drive_beta128b_type( void ) { + return option_enumerate_combo( widget_drive_beta128b_type_combo, + settings_current.drive_beta128b_type, + 4 ); +} + +#define widget_drive_beta128c_type_combo widget_drive_plus3b_type_combo + +int +option_enumerate_diskoptions_drive_beta128c_type( void ) { + return option_enumerate_combo( widget_drive_beta128c_type_combo, + settings_current.drive_beta128c_type, + 4 ); +} + +#define widget_drive_beta128d_type_combo widget_drive_plus3b_type_combo + +int +option_enumerate_diskoptions_drive_beta128d_type( void ) { + return option_enumerate_combo( widget_drive_beta128d_type_combo, + settings_current.drive_beta128d_type, + 4 ); +} + +#define widget_drive_plusd1_type_combo widget_drive_plus3a_type_combo + +int +option_enumerate_diskoptions_drive_plusd1_type( void ) { + return option_enumerate_combo( widget_drive_plusd1_type_combo, + settings_current.drive_plusd1_type, + 3 ); +} + +#define widget_drive_plusd2_type_combo widget_drive_plus3b_type_combo + +int +option_enumerate_diskoptions_drive_plusd2_type( void ) { + return option_enumerate_combo( widget_drive_plusd2_type_combo, + settings_current.drive_plusd2_type, + 4 ); +} + +#define widget_drive_didaktik80a_type_combo widget_drive_plus3a_type_combo + +int +option_enumerate_diskoptions_drive_didaktik80a_type( void ) { + return option_enumerate_combo( widget_drive_didaktik80a_type_combo, + settings_current.drive_didaktik80a_type, + 3 ); +} + +#define widget_drive_didaktik80b_type_combo widget_drive_plus3b_type_combo + +int +option_enumerate_diskoptions_drive_didaktik80b_type( void ) { + return option_enumerate_combo( widget_drive_didaktik80b_type_combo, + settings_current.drive_didaktik80b_type, + 4 ); +} + +#define widget_drive_disciple1_type_combo widget_drive_plus3a_type_combo + +int +option_enumerate_diskoptions_drive_disciple1_type( void ) { + return option_enumerate_combo( widget_drive_disciple1_type_combo, + settings_current.drive_disciple1_type, + 3 ); +} + +#define widget_drive_disciple2_type_combo widget_drive_plus3b_type_combo + +int +option_enumerate_diskoptions_drive_disciple2_type( void ) { + return option_enumerate_combo( widget_drive_disciple2_type_combo, + settings_current.drive_disciple2_type, + 4 ); +} + +#define widget_drive_opus1_type_combo widget_drive_plus3a_type_combo + +int +option_enumerate_diskoptions_drive_opus1_type( void ) { + return option_enumerate_combo( widget_drive_opus1_type_combo, + settings_current.drive_opus1_type, + 0 ); +} + +#define widget_drive_opus2_type_combo widget_drive_plus3b_type_combo + +int +option_enumerate_diskoptions_drive_opus2_type( void ) { + return option_enumerate_combo( widget_drive_opus2_type_combo, + settings_current.drive_opus2_type, + 1 ); +} + +static const char * const widget_disk_try_merge_combo[] = { + "Never", + "With single-sided drives", + "Always", + NULL +}; + +int +option_enumerate_diskoptions_disk_try_merge( void ) { + return option_enumerate_combo( widget_disk_try_merge_combo, + settings_current.disk_try_merge, + 1 ); +} diff --git a/src/fuse/scalers16.c b/src/fuse/scalers16.c deleted file mode 100644 index 4131cdf..0000000 --- a/src/fuse/scalers16.c +++ /dev/null @@ -1,2 +0,0 @@ -#define SCALER_DATA_SIZE 2 -#include diff --git a/src/fuse/scalers32.c b/src/fuse/scalers32.c deleted file mode 100644 index 88da818..0000000 --- a/src/fuse/scalers32.c +++ /dev/null @@ -1,2 +0,0 @@ -#define SCALER_DATA_SIZE 4 -#include