Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PC Speaker stuttering #81

Open
keenmaster486 opened this issue Dec 29, 2023 · 13 comments
Open

PC Speaker stuttering #81

keenmaster486 opened this issue Dec 29, 2023 · 13 comments

Comments

@keenmaster486
Copy link

MartyPC build:
Branch: version_0_2_0
Commit:

commit 587693817c7efba9dab1a0356bd6688e0cc2898e
Author: dbalsom <[email protected]>
Date:   Mon Dec 25 10:31:53 2023 -0500

    Make some types public for compile issues

Built using cargo build -r --features=ega
My martypc.toml:

# martypc.toml
# Main configuration file for the MartyPC emulator
[meta]
file_type = "main_config"
config_version = "0.2"

# ----------------------------------------------------------------------------
# Emulator paths
#
# By default, emulator paths are defined as relative to the base_dir path.
# If $base_dir$ is omitted from a path specifier, then that patch becomes
# an absolute path.
# Each path entry must be defined on a single line due to TOML grammar.
# 
# Multiple entries for the same resource string can be defined for the
# following resources:
#
# hdd    - MartyPC will search all defined paths for valid VHD images.
# rom    - MartyPC will search all defined paths for valid ROMs. 
# floppy - MartyPC will search all defined paths for valid floppy images.
# ----------------------------------------------------------------------------
[emulator]
# basedir: Base emulator data directory. 
#          Other emulator paths can be set as absolute paths, or relative to 
#          basedir with $basedir$
#          The default is ".", effecting a portable installation with all
#          directories relative to the current working directory.
basedir = "."
paths = [
    { resource = "machine", path = "$basedir$/configs/machines", recurse = true },
    { resource = "rom", path = "$basedir$/roms", recurse = true },
    { resource = "hdd", path = "$basedir$/hdd", recurse = true },
    { resource = "floppy", path = "$basedir$/floppy", recurse = true },
    { resource = "dump", path = "$basedir$/output/dumps" },
    { resource = "trace", path = "$basedir$/output/traces" },
    { resource = "screenshot", path = "$basedir$/output/screenshots" },
]

# Exclude any matching directories from recursion. Useful for temporarily
# hiding files, or moving files in and out of a "library" subdir.
ignore_dirs = [ "parking" ]

# -------------------------------------------------------------------------------------
# General emulator options
# -------------------------------------------------------------------------------------

# Power on the emulated machine on startup (only applicable in gui mode)
auto_poweron = true

# cpu_autostart: Run the CPU on startup - if false CPU will start paused
# (only applicable in gui mode)
cpu_autostart = true

# headless: Run MartyPC without any windows
headless = false

# fuzzer: Run the instruction fuzzer (requires validator feature)
fuzzer = false

# Debug mode does a few miscellaneous things. 
# - CPU Autostart is disabled
# - Several debug panels are opened automatically
# - CPU Instruction history is turned on (overrides setting)
debug_mode = false

# Warn if MartyPC was compiled in debug mode. Disable this if you intend to
# do so and don't want the nag.
debug_warn = true

# Help the developer debug any keyboard issues you may be having. With this
# feature set to true, MartyPC will print information about every keystroke
# to the terminal.
debug_keyboard = false

# Don't load BIOS if true (not useful on its own)
no_bios = false

# Run the specified program instead of booting BIOS. The CPU reset vector will
# be set to 'run_bin_seg:run_bin_ofs'
#run_bin = "./program/a_effect.bin"
run_bin_seg = 0x1000
run_bin_ofs = 0x0000

[emulator.backend]
# Enable vsync. For wgpu frontend, I would recommend leaving this off. FIFO
# presentation mode increase latency and causes window resizing issues.
vsync = false

[emulator.audio]
# Set to false to disable sound system initialization.
enabled = true

[emulator.media]
# Provide a list of file extensions to interpret as raw floppy sector images.
raw_sector_image_extensions = [ "img", "ima", "dsk", "mnx" ]

[[emulator.media.vhd]]
# VHD to mount into drive 0 (Typically C:)
drive = 0
filename = "main.vhd"

[[emulator.media.vhd]]
# VHD to mount into drive 1 (Typically D:)
drive = 1
filename = "storage.vhd"

# ----------------------------------------------------------------------------
# Emulator Window Options
#
# MartyPC will always have a main window, unless run headless. The main
# window can be set to display a video adapter, or not. Additional windows
# can be defined in [[emulator.window]] sections. Multiple windows can 
# reference the same video card - aperture and scaling options are set 
# per-window, so you can visualize an adapter's output multiple ways.
# Of course, every window you create has a cost in memory throughput and
# rendering time.
#
# At least one [[emulator.window]] section must be present. The first 
# [[emulator.window]] defines the main window.
#
# A note about sizes - the real minimum size of a window is the unscaled size
# of the card's selected video aperture, which may be larger than expected
# due to overscan. If this is larger than the requested min_size, min_size
# will be ignored, the scaler will not resample downwards.
# Therefore if you specifically want a 640x480 window, you should
# select the "Cropped" aperture.
# ----------------------------------------------------------------------------
[[emulator.window]]
# Provide a name for this window. (Required)
name = "Main GUI"

# If this parameter is provided, the window will be created at *at least* 
# this size, or the video aperture resolution, whichever is higher.
# It is useful to use this value for the main window, but for secondary
# display windows, you may wish to use card_scale instead.
size = { w=1024, h=768 }

# If this window has a GUI menu, add the vertical height of the menu to the
# window height, and adjust the scaler to display the emulated display 
# beneath it.  Otherwise, if you create a 640x480 Cropped main window, 
# the menu bar will overlap the top of image unless the GUI is hidden.
menu_adjust = true

# If set to false, the window cannot be resized by the user. It may still
# resize if the associated video card changes resolutions or the display
# aperture is changed.
resizable = true

# If this field is present, the window will display the specified card in its
# client area. If you do not want the window to display a card, comment this
# out.
# card_id is the numeric index of cards defined under the Machine section in
# [[videocard]] blocks. A standard PC will likely only have at most 0 and 1.
card_id = 0

# Size the initial window dimensions to the specified card's aperture size
# times this number.
# Setting this value overrides 'size' and 'resizable'.
#card_scale = 1

# Specify the scaler preset to use for this window. See the 
# [[emulator.scaler_preset]] definitions defined below for reference.
scaler_preset = "default"

# Request that this window remain on top. Not recommended for main window.
always_on_top = false

# Second window, optional. Set 'enabled' to true to activate.
[[emulator.window]]
enabled = false
name = "Secondary Window"
size = { w=800, h=600 }
resizable = false
card_id = 0
card_scale = 1
scaler_preset = "Green CRT"
always_on_top = false

# Third window, optional
[[emulator.window]]
enabled = false
name = "Tertiary Window"
size = { w=640, h=480 }
resizable = false
card_id = 0
card_scale = 1
scaler_preset = "default"
always_on_top = false

# ----------------------------------------------------------------------------
# Emulator Scaler Presets
# 
# Rather than define scaler settings for each possible window/display target,
# targets can reference a scaler preset defined here. Any number of 
# [[emulator.scaler_preset]] sections can be defined, as long as the 'name'
# field is unique. 
#
# At least one preset named "default" must be present. 
# 
# MartyPC's display pipeline for a video card has two stages - rendering
# and shading. Renderer options are listed under 
# [emulator.scaler_preset.renderer] blocks. These must appear at the end
# of a scaler_preset definition.
# ----------------------------------------------------------------------------
[[emulator.scaler_preset]]
# Provide a unique name for this preset. Reference this name in window 
# definitions. A name is required.
name = "default" # Default preset must exist! Do not rename.

# Specify the scaler mode to use for this window when displaying a video card.
# The default value is "Integer". This has no effect if no card_id is provided.
#
# Valid options for Scaler mode are
# Fixed1x - Video and shader output will be displayed at native base resolution
# Fixed2x - Video and shader output will be displayed at double base resolution
# Integer - Video and shader output will be scaled to the largest integer
#           multiple that will fit in the window. This generally produces the
#           clearest results, but can leave large black borders.
# Fit     - Video will be scaled proportionally to fit the window.
# Stretch - Video will be scaled to fit the window.
mode = "Fit"

# Valid options for filter are:
# Linear  - Bilinear filtering. Best results but may introduce blur. 
# Nearest - Nearest neighbor filtering. Crisp, but may introduce scanline 
#           artifacts at non-integer scale sizes. Looks terrible with crt 
#           effects.
filter = "Nearest"

# RGBA color to use for the 'border' area around scaler output.
# This is also used for the background color of a window with no card 
# attachment.
border_color = 0x323338 # Medium gray.

# Enable or disable CRT shader effects
crt_effect = false

# Degree to which the corners of the display should be rounded, from
# 0.0 (sharp corners) to 1.0 (maximum rounding)
crt_corner_radius = 0.0

# Amount of barrel distortion from 0 (no distortion) to 1.0
crt_barrel_distortion = 0.0

# Emulated phosphor type
# Valid values are:
# Color - (default) Normal color CRT
# White - White CRT phosphors
# Green - Green CRT phosphors
# Amber - Amber CRT phosphors
crt_phosphor_type = "Color"

# Emulate scanlines?
crt_scanlines = false

# Gamma correction value (only used when crt_phosphor_type != Color)
gamma = 1.0

# Renderer options. In MartyPC a renderer is responsible for presenting data 
# to the scaler for display. These options are not technically part of the 
# scaler, but included in scaler presets for convenience.
[emulator.scaler_preset.renderer]
#
# display_aperture: Valid options are:
# Cropped  - Display the card in the "traditional" resolution for each graphics
#            mode, with no overscan. Ie, 320x200 for low resolution CGA, 
#            640x350 for high resolution EGA, 640x480 for high resolution VGA
# Accurate - Display the card with overscan extents as they would appear on a 
#            typical CRT monitor
# Full     - Display the entire overscan area
# Debug    - Display the entire video field, including horizontal and vertical
#            blanking periods. Helpful for debugging video code.
#display_aperture = "Cropped"

# Aspect-correct scaler output to 4:3. This will make the video output more
# visually accurate to what you would see on a real monitor, but will introduce
# vertical blur if using Integer or Fixed scaling modes. This can be toggled in
# the GUI.
aspect_correction = true

# Aspect ratio to use, representing a w:h ratio. Both fields should be 
# integers.
aspect_ratio = { h=4, v=3 }

# Emulate a composite color signal (and produce artifact color)
# Has no effect unless card type is CGA.
composite = false

# Define additional scaler presets below...
[[emulator.scaler_preset]]
name = "IBM 5153"
filter = "Linear"
border_color = 0x323338 # Medium gray.
crt_effect = true
crt_barrel_distortion = 0.2
crt_corner_radius = 0.2
crt_phosphor_type = "Color"
crt_scanlines = true
gamma = 1.0
[emulator.scaler_preset.renderer]
display_aperture = "Accurate"
aspect_correction = true
aspect_ratio = { h=4, v=3 }
composite = false

[[emulator.scaler_preset]]
name = "Green CRT"
filter = "Linear"
border_color = 0x323338 # Medium gray.
crt_effect = true
crt_barrel_distortion = 0.2
crt_corner_radius = 0.2
crt_phosphor_type = "Green"
crt_scanlines = true
gamma = 1.0
[emulator.scaler_preset.renderer]
display_aperture = "Accurate"
aspect_correction = true
aspect_ratio = { h=4, v=3 }
composite = false

[[emulator.scaler_preset]]
name = "Amber CRT"
filter = "Linear"
border_color = 0x323338 # Medium gray.
crt_effect = true
crt_barrel_distortion = 0.2
crt_corner_radius = 0.2
crt_phosphor_type = "Amber"
crt_scanlines = true
gamma = 1.0
[emulator.scaler_preset.renderer]
display_aperture = "Accurate"
aspect_correction = true
composite = false
aspect_ratio = { h=4, v=3 }

# ----------------------------------------------------------------------------
# GUI options
# ----------------------------------------------------------------------------
[gui]
# Disable the GUI entirely. Use autostart=true or you'll have no way to start
# the machine.
disabled = false

# Global zoom level for GUI. Smaller numbers will make all the GUI elements 
# smaller. Default: 1.0 Max: 1.0 Min: 0.1
zoom = 1.0

# Enable dark theme (Recommended)
theme_dark = true

# Specify the color modifier for the selected EGUI theme. Comment out for the
# default color scheme. Theme colors only work properly with Dark mode.
theme_color = 0x382D59  # Marty purple (for Dark theme)
#theme_color = 0x2D4859  # Alt blue (for Dark theme)

[input]
# ----------------------------------------------------------------------------

# Some platforms reverse the left and right mouse button id #'s. 
# We try to detect this, but it can be overridden here.
reverse_mouse_buttons = false

# ----------------------------------------------------------------------------
# CPU Options
# ----------------------------------------------------------------------------
[machine.cpu]

# Enable CPU wait states. This includes wait states from DMA, memory access
# and device IO. Setting this to false may speed up the CPU, but reduce 
# accuracy (Area 5150 will break)
wait_states = true

# Attempt to detect when the CPU is executing invalid instructions and halt.
# May need to disable for certain test programs like acid88
off_rails_detection = false

# What to do when the CPU has entered an unrecoverable halt condition. 
# Valid options are:
#  Continue - Do nothing; just keep running
#  Stop     - Stop the system and display a warning notification
#  Warn     - Keep running, but display a warning notification
on_halt = "Warn"

# Enable instruction history. This slows down the emulator a modest amount 
# when enabled. Only enable if debugging.
instruction_history = false

# Enable MartyPC's internal emulator serivce interrupt at 0xFC. You may need
# to disable this if conflicts arise. 'mdebug.com' requires this to be set 
# true.
service_interrupt = true

# ----------------------------------------------------------------------------
# CPU Tracing Options
# ----------------------------------------------------------------------------
# CPU tracing may be enabled by specifying trace_mode
# Tracing does not begin unless trace_on == true or set in GUI
#
# Valid values for trace_mode:
#  Instruction  - Output per-instruction traces (slow, big)
#  Cycle        - Output per-cycle traces, text format (very slow, huge)
#  Sigrok       - Output per-cycle traces, csv format (very slow, huge)
#                 Designed for import into sigrok PulseView for debugging.
#                 Use an import string of t,x20,l,l,x2,x3,l,l,l,l,l,l
#
# >>> WARNING: Any of these options will quickly make multi-gigabyte files <<<
#
# Additionally, a valid value for trace_file must be supplied.
#
trace_on = false
#trace_mode = "Instruction"
#trace_mode = "Cycle"
#trace_file = "./traces/cycle_trace.log"

# ----------------------------------------------------------------------------
# Machine Options
# ----------------------------------------------------------------------------
[machine]
# Specify the name of a machine configuration to load.
config_name = "ibm5160_hdd"
#config_name = "ibm5160_hdd_ega"

# Specify configuration overlays to load on top of machine configuration.
#config_overlays = ["ega"]

# Turbo Button
# ----------------------------------------------------------------------------
# Change the clock divisor/multiplier for the CPU to run the CPU faster than 
# normal. Other devices like the timer will continue to run at the same rate.
#
# On IBM PC/XT, turbo increases CPU clock from 4.77Mhz to 7.16Mhz.
turbo = false

# Emulate phase offset of PIT vs CPU. Don't change this if you don't know why 
# you would want to do that.
pit_phase = 0

# Keyboard Type
# ----------------------------------------------------------------------------
# Valid options for keyboard_type are:
# ModelF - This was the original 83-key keyboard shipped with the PC/XT
#          (More keyboard types yet to be implemented)
keyboard_type = "ModelF"

# Keyboard layout. Used to load the appropriate keyboard translation file. 
# MartyPC will look for the file keyboard_XX.toml in the ./keyboard/ directory
# where XX is the string specified by keyboard_layout.
#
# Certain scancodes have changed their meaning since the 1980's. Your help
# would be appreciated in developing new translation files.
keyboard_layout="US"

# Enable typematic repeat for the emulated keyboard. Host repeat is ignored.
typematic = true
# Delay in milliseconds before typematic repeat begins.
typematic_delay = 500.0
# Delay in milliseconds between each scancode during typematic repeat.
typematic_rate= 50.0

# ----------------------------------------------------------------------------
# Benchmarking (not yet implemented - configs are placeholder)
# ----------------------------------------------------------------------------
[benchmark]
# Machine configuration to benchmark
config_name = "ibm5160"

# Valid options for benchmark_end_condition are:
# "Timeout" - Benchmark for 'timeout' seconds and exit
# "Trigger" - Terminate benchmark on signal from internal service interrupt
# "Cycles"  - Terminate benchmark after 'cycles' CPU cycles
end_condition = "Timeout"
timeout = 60
cycles = 572400000 # 2 minutes

# ----------------------------------------------------------------------------
# Options for the CPU Validator module.
# ----------------------------------------------------------------------------
# You must have an Arduino8088 connected via USB to utilize
# the validator. For more information, see 
# https://github.com/dbalsom/arduino_8088
[validator]
type = "Arduino8088"
trigger_address = 0xFFFF0
trace_file = "./traces/validator_trace.log"

# ----------------------------------------------------------------------------
# Options for JSON test facilities
# MartyPC can create JSON tests or validate them.
# ----------------------------------------------------------------------------
# Test generation requires a functioning CPU Validator module, see above
[tests]

# Valid values for test_mode are:
# None - Do not generate or validate tests (default - run emulator normally)
# Generate - generate tests based on supplied parameters
# Valdidate - validate tests 
test_mode="None"

# Random seed for testing. The same random seed should produce the same
# set of tests. If you want a different set of tests, change this to any 
# other number.
test_seed=1234

# Directory to look for / place tests
test_dir="tests/v1"

# Opcode range to generate or validate. Provide start and end opcodes.
# If start == end, that single opcode will be generated or validated.
test_opcode_range = [0, 0]

# List of opcodes to exclude in generation or validation. 
test_opcode_exclude_list = [0xF1]

# Number of tests to generate per opcode.
test_opcode_gen_count = 5000

# If true, append to existing test JSON if < test_opcode_gen_count.
# If false, generation will replace any existing JSON file.
test_opcode_gen_append = true

Output of MartyPC when run:

Resolved resource path: "./roms"
Resolved resource path: "./hdd"
Resolved resource path: "./floppy"
Resolved resource path: "./output/traces"
Resolved resource path: "./configs/machines"
Resolved resource path: "./output/dumps"
Resolved resource path: "./output/screenshots"
Have 11 Machine Configurations:
 generic_xt_base
  videocard 0: type: CGA
 generic_xt_hdd_ega
  videocard 0: type: EGA
 ibm5150_64k_hdd
  videocard 0: type: CGA
 generic_xt_hdd
  videocard 0: type: CGA
 ibm5150_256k_hdd
  videocard 0: type: MDA
 ibm5160
  videocard 0: type: CGA
 ibm5150_64k
  videocard 0: type: MDA
 generic_xt
  videocard 0: type: CGA
 ibm5160_hdd_ega
  videocard 0: type: EGA
 ibm5160_hdd
  videocard 0: type: CGA
 ibm5150_256k
  videocard 0: type: MDA
Hash collision! Rom #1: "./roms/ibm_6277356_ega_card_u44_27128.bin" Rom #2 "./roms/ibm_6277356_ega_card_u44_27128 (1).bin" both have hash 0636f46316f3e15cb287ce3da6ba43a1. Rom #2 will be ignored.
Hash collision! Rom #1: "./roms/IBM_XEBEC_62X0822_1985 (1).BIN" Rom #2 "./roms/IBM_XEBEC_62X0822_1985.BIN" both have hash 66631d1a095d8d0d54cc917fbdece684. Rom #2 will be ignored.
Hash collision! Rom #1: "./roms/IBM_XEBEC_6359121_1982.BIN" Rom #2 "./roms/IBM_XEBEC_5000059_1982.BIN" both have hash bac8f05bedbec7009dd9dbc55e9ee22f. Rom #2 will be ignored.
Hash collision! Rom #1: "./roms/IBM_XEBEC_104839E.BIN" Rom #2 "./roms/IBM_XEBEC_104839RE.BIN" both have hash a9335919a1960998d83192cf449c38f6. Rom #2 will be ignored.
ROM scan found 33 unique ROMs.
Selected machine config ibm5160_hdd requires the following ROM features:
  expansion
  ibm5160
  ibm_basic
  ibm_xebec
Selected machine config ibm5160_hdd has resolved the following ROM sets:
  ibm5160_86_v2_wbasic
  ibm_xebec
Found VHD image: "./hdd/storage.vhd" size: 21412352
Found VHD image: "./hdd/main.vhd" size: 21412352
Using default audio device: default
Failed to load keyboard mapping file: ./keyboard/keyboard_US.toml Err: No such file or directory (os error 2)
[2023-12-29T05:40:22Z ERROR martypc_pixels_desktop::emulator] Number of videocards installed does not match number of cards in config!

My machine:

             ...-:::::-...                 <redacted>@<redacted> 
          .-MMMMMMMMMMMMMMM-.              --------------- 
      .-MMMM`..-:::::::-..`MMMM-.          OS: Linux Mint 21.2 x86_64 
    .:MMMM.:MMMMMMMMMMMMMMM:.MMMM:.        Host: MS-7D91 2.0 
   -MMM-M---MMMMMMMMMMMMMMMMMMM.MMM-       Kernel: 6.2.0-33-generic 
 `:MMM:MM`  :MMMM:....::-...-MMMM:MMM:`    Uptime: 11 days, 6 hours, 28 mins 
 :MMM:MMM`  :MM:`  ``    ``  `:MMM:MMM:    Packages: 2875 (dpkg), 16 (flatpak) 
.MMM.MMMM`  :MM.  -MM.  .MM-  `MMMM.MMM.   Shell: bash 5.1.16 
:MMM:MMMM`  :MM.  -MM-  .MM:  `MMMM-MMM:   Resolution: 2560x1440 
:MMM:MMMM`  :MM.  -MM-  .MM:  `MMMM:MMM:   DE: Cinnamon 5.8.4 
:MMM:MMMM`  :MM.  -MM-  .MM:  `MMMM-MMM:   WM: Mutter (Muffin) 
.MMM.MMMM`  :MM:--:MM:--:MM:  `MMMM.MMM.   WM Theme: Mint-L-Dark (Mint-Y) 
 :MMM:MMM-  `-MMMMMMMMMMMM-`  -MMM-MMM:    Theme: Mint-L [GTK2/3] 
  :MMM:MMM:`                `:MMM:MMM:     Icons: Mint-L [GTK2/3] 
   .MMM.MMMM:--------------:MMMM.MMM.      Terminal: lxterminal 
     '-MMMM.-MMMMMMMMMMMMMMM-.MMMM-'       Terminal Font: Fixedsys Excelsior 3. 
       '.-MMMM``--:::::--``MMMM-.'         CPU: 12th Gen Intel i5-12400 (12) @  
            '-MMMMMMMMMMMMM-'              GPU: NVIDIA GeForce RTX 3070 Ti 
               ``-:::::-``                 GPU: Intel Device 4692 
                                           Memory: 10838MiB / 31863MiB 

Issue: I'm only getting about 53 fps. Seems like my machine should be able to handle 60.
MartyPC does seem to be running only on one core.
See attached screenshot of performance monitor:
image

@dbalsom
Copy link
Owner

dbalsom commented Dec 30, 2023

I think what's going on is there are too many UPS (353,293) Your actual emulation time (2.89ms) is fine but there are so many updates to process the overhead of that eats up all the frame time. I added a single, 1ms sleep to the event loop which in theory would cap UPS to 1000. Can you see if that helps?

@keenmaster486
Copy link
Author

Pulled the latest and built. I now get a stable 60fps, but PC speaker is still stuttering.

I'm testing it by running Quick Basic and entering the command PLAY "cdefgabc", which plays perfectly smoothly on a real 5150.

The stuttering is also noticable in the startup beep and games such as Commander Keen.
image

@dbalsom
Copy link
Owner

dbalsom commented Jan 4, 2024

Ok, glad we got performance up. I am not going to dig too deeply into speaker issues at this time as the sound system is going to be rewritten soon. For the moment, you can disable sound in the config if it is distracting.

@dbalsom dbalsom changed the title Only getting ~53fps (Linux) PC Speaker stuttering Jan 19, 2024
@dbalsom
Copy link
Owner

dbalsom commented Jan 19, 2024

I was verifying that Area 5150 still ran after making some CPU changes, and noticed the audio problem myself. Turns out adding that 1ms sleep has disturbed the timestep calculations and so the emulator has been running slightly above 60fps and starving the audio buffer:

image

my timestep code is a bit slapdash so I will take the time to refactor it while fixing this. I swear 0.2 is never coming out at this rate...

@keenmaster486
Copy link
Author

keenmaster486 commented Jan 26, 2024

2024-01-26.11-53-10.mp4

Having serious issues with the latest for a week or so now. PC speaker making all sorts of weird stuttering noises on startup, and now the keyboard is not working, so the emulator is unusable. See attached video with sound so you can hear my typing as the emulator seems to have a mind of its own, inserting random characters that I did not type, and constant backspaces to delete everything. Happens with EGA or CGA. Tried a fresh martypc.toml, same issue.

@dbalsom
Copy link
Owner

dbalsom commented Jan 27, 2024

sorry you're having issues. can you change debug_keyboard to true in martypc.toml and show the terminal messages when you type a few keys (or see if key events are happening on their own)

either the phantom keystrokes are coming from the window system or from the emulator itself, and this would help determine that.

the current commit also adds a graph in the performance viewer it would be interesting to see.

@keenmaster486
Copy link
Author

2024-01-27.11-10-49.mp4

Looking at the terminal output, the keyboard events it's reporting are the correct ones, reflecting what I'm actually typing. What appears on the screen definitely is not.

@dbalsom
Copy link
Owner

dbalsom commented Jan 27, 2024

what machine configuration are you using?

@dbalsom
Copy link
Owner

dbalsom commented Jan 27, 2024

can you pull the latest commit, then show me with the PIC and PPI viewers open from the Debug->Devices menu?

what we're looking for is if there are spontaneous IRQ1s (keyboard interrupts) and if the 'Last Keyboard Byte' seems to change on its own

@keenmaster486
Copy link
Author

keenmaster486 commented Jan 27, 2024

2024-01-27.11-52-44.mp4

I'm seeing that Last Keyboard Byte changing spontaneously from AA to 4D several times about once a second.

My machine configuration:

name = "ibm5160_hdd"
type = "Ibm5160"
rom_set = "auto"
speaker = true

    [machine.memory]
    conventional.size = 0xA0000
    conventional.wait_states = 0

    # Floppy disk controller
    [machine.fdc]
    type = "IbmNec"
    
        # Drives connected to controller. Maximum of 4.
        [[machine.fdc.drive]]
        type  = "360k"
        image = "marty_util.img"
        [[machine.fdc.drive]]
        type  = "360k"   

    # Hard disk controller
    [machine.hdc]
    type = "IbmXebec"
    
        # Drives connected to controller. Maximum of 2.
        # Drive #0 - (Typically C:)
        [[machine.hdc.drive]]
        type = "Mfm"
        vhd = "main.vhd"
        
        # Drive #1 - (Typically D:)
        [[machine.hdc.drive]]
        type = "Mfm"        
        vhd = "storage.vhd"

    # Serial card
    [[machine.serial]]
    type = "IbmAsync"
        [[machine.serial.port]]
        io_base = 0x3F8
        irq = 4
        [[machine.serial.port]]
        io_base = 0x2F8
        irq = 3
    
    # Video cards
    [[machine.video]]
    type = "CGA"
    clock_mode = "Dynamic"

    [machine.keyboard]
    type = "ModelF"
    layout = "US"    

@dbalsom
Copy link
Owner

dbalsom commented Jan 27, 2024

we can see IRQ1 ticking up very fast. so something is generating lots of keyboard interrupts.

4D is the scancode for Numpad 6...

can you disconnect your keyboard and see if the problem still occurs?
if you reset the machine does it keep happening on next boot?
if you remove the '[machine.keyboard]' section from the config does that stop the interrupts? (you won't be able to type, but if something else is causing it...)

@keenmaster486
Copy link
Author

Well I'll be darned, I unplugged my keyboard and plugged it back in again and now the problem's gone.

I wonder why this didn't affect any of my other programs.

Still having PC speaker problems though.

@dbalsom
Copy link
Owner

dbalsom commented Jan 27, 2024

yeah, that is weird. let me know if it comes back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants