Re: [hatari-devel] Hatari UI, Python & Gtk, v2 vs v3

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

On lauantai 07 tammikuu 2012, David Savinkoff wrote:
> > Have you tested that the other python code:
> > * hconsole example.py 
> bytes() is python 2.6
>
> > * stuff in atari-hd-image.sh
> bytearray() is python 2.6

Ok, so in general it's better to require Python 2.6.
RHEL/CentOS v5 are just too old although they can build
Hatari and run most important things with patches.

I added more comments about RHEL/CentOS v5 to Hatari readme
+ link to your mail with patches.


> > * rest of Hatari UI
....
> Search for >>> in the log to find my comments.
> Search for IndexError and AssertionError.

Due to an exception, Hatari UI saves an empty configuration file
i.e. all user's config changes done in Hatari / Hatari UI are lost.

This same exception and empty config file also cause the snapshot loading
exception/failure and probably also rest of the problems you had.

The exception appears to be because when Nicolas changed slowfdc option to
fastfdc, he forgot the "b" prefix from the boolean config variable name:
	$ grep -i -e true -e false ~/.hatari/hatari.cfg | grep -v '^b'
	FastFloppy = FALSE

However, Hatari UI uses the config variable prefixes to infer their types
(Python is dynamically, but strongly typed language and needs correct
types for variables)...


Similar problem would also be in the following numerical configuration
values, if Hatari UI support would be added to them:
	$ grep '= [0-9]' ~/.hatari/hatari.cfg|grep -v '^[nk]'
	YmVolumeMixing = 2
	AviRecordVcodec = 2
	AviRecordFps = 0


This is pretty bad bug, but I'm not completely sure how to fix it:
* Change these new Hatari config variable name(s) to match the convention
  (single character change per variable in Hatari sources)
* Add specific kludge for each of these variables to generic
  Hatari UI config handling code
?

Neither of them is very nice, but I would prefer the first one.

Nicolas?


Attached patches:
* fix Hatari config variable names
* for Hatari UI add YM mixing & mic options and simplify the sound
  options handling a bit, fix (mainly cosmetic) exception from your
  log and update some texts


-------------------------
>>> Load Snapshot:
....
killed hatari with PID 7042
....
AssertionError

>>> Black Screen      
>>> Cannot Reset
....
ERROR: no Hatari (control socket)
No configuration changes to save, skipping

>>> Debug > Debugger (again) BTW the debugger menu pops up as it should
>>> ps -ej shows that hatariui is running and hatari is not.
>>> attemping Load snapshot again
-------------------------

If Hatari goes away, you should be able to just "re"-run it again.

However, if Hatari config file gets messed, that might not work.


> hatariui doesn't have an option for [model] [table] [linear] in
> hatariui: Devices > Sound > Sound settings



....
> Line 9 of the log shows this ubiquitous and unexplained message:
> /usr/bin/../share/hatari/hatariui/hatariui.py:608: GtkWarning:
> gtk_accel_label_set_accel_closure: assertion
> `gtk_accel_group_from_accel_closure (accel_closure) != NULL' failed

I get it also, but I have no idea where that comes from and
googling didn't find anything useful.


> The tracebacks in the log don't appear to be obviously related to my
> patches (as far as I can see). Maybe python 2.4 vs python 2.6
> incompatibilities or bugs.

I'm not sure about the debugger UI exception:
---------------
Traceback (most recent call last):
  File "/usr/share/hatari/hatariui/debugui.py", line 455, in stop_cb
    self.address.dump()
  File "/usr/share/hatari/hatariui/debugui.py", line 249, in dump
    self._get_registers()
  File "/usr/share/hatari/hatariui/debugui.py", line 272, in _get_registers
    self.first  = int(output[-2][:output[-2].find(":")], 16)
IndexError: list index out of range
---------------

As I don't know how I should reproduce it, but the other
exceptions are Hatari & Hatari UI bugs.

Can you reproduce it without trying any config savings
or after applying the attached patches?


	- Eero
diff -r e5917358e2df python-ui/dialogs.py
--- a/python-ui/dialogs.py	Sat Jan 07 23:24:13 2012 +0200
+++ b/python-ui/dialogs.py	Sun Jan 08 01:34:19 2012 +0200
@@ -300,7 +300,7 @@
         row += 1
         fastfdc = gtk.CheckButton("Fast floppy access")
         fastfdc.set_active(config.get_fastfdc())
-        fastfdc.set_tooltip_text("Can cause incompatibilites with some games/demos")
+        fastfdc.set_tooltip_text("Can cause incompatibilites with some rare games/demos")
         table_add_widget_row(table, row, None, fastfdc)
 
         table.show_all()
@@ -431,7 +431,7 @@
         scalew.set_tooltip_text("Preferred/maximum zoomed width")
         scaleh.set_tooltip_text("Preferred/maximum zoomed height")
 
-        desktop = gtk.CheckButton("Keep desktop resolution")
+        desktop = gtk.CheckButton("Keep desktop resolution (Falcon/TT)")
         desktop.set_active(config.get_desktop())
         desktop.set_tooltip_text("Whether to keep desktop resolution in fullscreen and (try to) scale Atari screen by an integer factor instead")
 
@@ -620,24 +620,36 @@
 class SoundDialog(HatariUIDialog):
 
     def _create_dialog(self, config):
-        combo = gtk.combo_box_entry_new_text()
-        for text in config.get_sound_values():
-            combo.append_text(text)
-        enabled, hz = config.get_sound()
+        enabled, curhz = config.get_sound()
+
         self.enabled = gtk.CheckButton("Sound enabled")
         self.enabled.set_active(enabled)
-        combo.child.set_text(hz)
-        box = gtk.HBox()
-        box.pack_start(gtk.Label("Sound frequency:"), False, False)
-        box.add(combo)
-        self.sound = combo.child
+
+        hz = gtk.combo_box_new_text()
+        for text in config.get_sound_values():
+            hz.append_text(text)
+        hz.set_active(curhz)
+        self.hz = hz
+
+        ymmixer = gtk.combo_box_new_text()
+        for text in config.get_ymmixer_types():
+            ymmixer.append_text(text)
+        ymmixer.set_active(config.get_ymmixer())
+        self.ymmixer = ymmixer
+
+        self.mic = gtk.CheckButton("Enable (Falcon) microphone")
+        self.mic.set_active(config.get_mic())
 
         dialog = gtk.Dialog("Sound settings", self.parent,
             gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
             (gtk.STOCK_APPLY,  gtk.RESPONSE_APPLY,
              gtk.STOCK_CANCEL,  gtk.RESPONSE_CANCEL))
         dialog.vbox.add(self.enabled)
-        dialog.vbox.add(box)
+        dialog.vbox.add(gtk.Label("Sound frequency::"))
+        dialog.vbox.add(hz)
+        dialog.vbox.add(gtk.Label("YM voices mixing method:"))
+        dialog.vbox.add(ymmixer)
+        dialog.vbox.add(self.mic)
         dialog.vbox.show_all()
         self.dialog = dialog
 
@@ -648,11 +660,13 @@
         response = self.dialog.run()
         self.dialog.hide()
         if response == gtk.RESPONSE_APPLY:
+            config.lock_updates()
+            config.set_mic(self.mic.get_active())
+            config.set_ymmixer(self.ymmixer.get_active())
             enabled = self.enabled.get_active()
-            hz1 = self.sound.get_text()
-            hz2 = config.set_sound(enabled, hz1)
-            if hz2 != hz1:
-                self.sound.set_text(hz2)
+            hz = self.hz.get_active()
+            config.set_sound(enabled, hz)
+            config.flush_updates()
         
 
 # ---------------------------
@@ -704,7 +718,7 @@
         "dsp_state"
     ]
     def __init__(self, parent):
-        self.savedpoints = "none"
+        self.savedpoints = None
         hbox1 = gtk.HBox()
         hbox1.add(create_button("Load", self._load_traces))
         hbox1.add(create_button("Clear", self._clear_traces))
@@ -746,6 +760,8 @@
 
     def _set_traces(self, tracepoints):
         self._clear_traces()
+        if not tracepoints:
+            return
         for trace in tracepoints.split(","):
             if trace in self.tracewidgets:
                 self.tracewidgets[trace].set_active(True)
diff -r e5917358e2df python-ui/hatari.py
--- a/python-ui/hatari.py	Sat Jan 07 23:24:13 2012 +0200
+++ b/python-ui/hatari.py	Sun Jan 08 01:34:19 2012 +0200
@@ -436,27 +436,38 @@
     def get_sound(self):
         enabled = self.get("[Sound]", "bEnableSound")
         hz = str(self.get("[Sound]", "nPlaybackFreq"))
-        return (enabled, hz)
+        idx = self.get_sound_values().index(hz)
+        return (enabled, idx)
 
-    def set_sound(self, enabled, hz):
+    def set_sound(self, enabled, idx):
         # map get_sound_values() index to Hatari config
-        try:
-            hz = int(hz)
-        except ValueError:
-            hz = 0
-        if hz < 6000 or hz > 50066:
-            hz = 44100
-        self.set("[Sound]", "nPlaybackFreq", hz)
+        hz = self.get_sound_values()[idx]
+        self.set("[Sound]", "nPlaybackFreq", int(hz))
         self.set("[Sound]", "bEnableSound", enabled)
-        value = str(hz)
         # and to cli option
         if enabled:
-            self._change_option("--sound %s" % value)
+            self._change_option("--sound %s" % hz)
         else:
             self._change_option("--sound off")
-        return value
-        
-        
+    
+    def get_ymmixer_types(self):
+        return ("linear", "table", "model")
+    
+    def get_ymmixer(self):
+        return self.get("[Sound]", "nYmVolumeMixing")
+    
+    def set_ymmixer(self, value):
+        # values for types are start from 1, not 0
+        self.set("[Sound]", "nYmVolumeMixing", value+1)
+        self._change_option("--ym-mixing %s" % self.get_ymmixer_types()[value])
+    
+    def get_mic(self):
+        return self.get("[Sound]", "bEnableMicrophone")
+    
+    def set_mic(self, value):
+        self.set("[Sound]", "bEnableMicrophone", value)
+        self._change_option("--mic %s" % str(value))
+
     # ----------- joystick --------------
     def get_joystick_types(self):
         return ("Disabled", "Real joystick", "Keyboard")
@@ -498,10 +509,10 @@
 
     # ------------ fast FDC access ---------------
     def get_fastfdc(self):
-        return self.get("[Floppy]", "FastFloppy")
+        return self.get("[Floppy]", "bFastFloppy")
 
     def set_fastfdc(self, value):
-        self.set("[Floppy]", "FastFloppy", value)
+        self.set("[Floppy]", "bFastFloppy", value)
         self._change_option("--fastfdc %s" % str(value))
 
     # ------------- disk protection -------------
diff -r e5917358e2df src/configuration.c
--- a/src/configuration.c	Sat Jan 07 23:24:13 2012 +0200
+++ b/src/configuration.c	Sun Jan 08 01:34:19 2012 +0200
@@ -235,7 +235,7 @@
 	{ "nPlaybackFreq", Int_Tag, &ConfigureParams.Sound.nPlaybackFreq },
 	{ "nSdlAudioBufferSize", Int_Tag, &ConfigureParams.Sound.SdlAudioBufferSize },
 	{ "szYMCaptureFileName", String_Tag, ConfigureParams.Sound.szYMCaptureFileName },
-	{ "YmVolumeMixing", Int_Tag, &ConfigureParams.Sound.YmVolumeMixing },
+	{ "nYmVolumeMixing", Int_Tag, &ConfigureParams.Sound.YmVolumeMixing },
 	{ NULL , Error_Tag, NULL }
 };
 
@@ -254,7 +254,7 @@
 static const struct Config_Tag configs_Floppy[] =
 {
 	{ "bAutoInsertDiskB", Bool_Tag, &ConfigureParams.DiskImage.bAutoInsertDiskB },
-	{ "FastFloppy", Bool_Tag, &ConfigureParams.DiskImage.FastFloppy },
+	{ "bFastFloppy", Bool_Tag, &ConfigureParams.DiskImage.FastFloppy },
 	{ "nWriteProtection", Int_Tag, &ConfigureParams.DiskImage.nWriteProtection },
 	{ "szDiskAZipPath", String_Tag, ConfigureParams.DiskImage.szDiskZipPath[0] },
 	{ "szDiskAFileName", String_Tag, ConfigureParams.DiskImage.szDiskFileName[0] },
@@ -343,9 +343,9 @@
 /* Used to load/save video options */
 static const struct Config_Tag configs_Video[] =
 {
-	{ "AviRecordVcodec", Int_Tag, &ConfigureParams.Video.AviRecordVcodec },
-	{ "AviRecordFps", Int_Tag, &ConfigureParams.Video.AviRecordFps },
-	{ "AviRecordFile", String_Tag, ConfigureParams.Video.AviRecordFile },
+	{ "nAviRecordVcodec", Int_Tag, &ConfigureParams.Video.AviRecordVcodec },
+	{ "nAviRecordFps", Int_Tag, &ConfigureParams.Video.AviRecordFps },
+	{ "sAviRecordFile", String_Tag, ConfigureParams.Video.AviRecordFile },
 	{ NULL , Error_Tag, NULL }
 };
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/