Improving the Memory Manager
Taking a step back to review the Memory Manager that displays the data in memory chips and allows for editing of the data, I realized that several improvements could be made.
- Display the data in 16bit or 8bit chunks in binary or hex
- Create a data input popup that captures keyboard input without using an LineEdit box
- Set up different text areas for Address, Data, and ASCII
I got most of this done today. Having separate Labels in an HBox means that the text may be colored differently, the hand pointer may only show over the data that may be edited, and the offset of points into the data area is zero.
The new popup for entering data works great! Rather than using a LineEdit, it has a Label that prompts you to type the value on the keyboard and the digits shift left as they are entered into the value in say:
0b00000000 for binary and
0x00 for hex. Some simple tests of the Scan Code values (ASCII) determine the validity of characters.
Much of this was fun to code and I came up with some quite compact solutions for number conversions.
func _on_NumberInputPanel_popup_hide(): hide_mask() var v = $NumberInputPanel.txt.text if v != "0": # No entry was made return var x = 0 if mode == BIN: for i in v.length(): if i > 1: # Skip the prefix 0b x *= 2 if v[i] == "1": x += 1 else: x = v.hex_to_int() # Godot function data.bytes[current_addr] = x % 0x100 if data.width == 16: data.bytes[current_addr + 1] = x / 0x100 set_view() func int2bin(x: int) -> String: var b = "" for n in data.width: b = String(x % 2) + b x /= 2 return b
One weird bug appeared that took me a while to fix. A property that I set in the Popup to indicate Hex or Binary was mysteriously resetting as I entered values from the keyboard.
The cause of this was that the Popup is used by other Memory Parts (ROM and RAM) so there was no linkage to which Part was using the Popup. So when the Popup is Opened, I simply tag a property with what object opened it and check that before acting on the keyboard input. Otherwise, the properties are in the default state for the inactive ones, yet the attached script still runs in the Parts that are in the Parts Factory autoload.
I spotted the cause by looking at the reference ID of the object when break-pointing the code at the point of failure and realizing that it belonged to another place in the scene.
Another weird bug was that the Popup insisted in expanding to a certain size when it opened, but it was bigger than the internal items. The only fix I could come up with was to set the rectangle size to zero after it popped up on the next frame to force it to resize again, this time correctly.
- Just a few things to do to complete the Memory Manager
- Add labelling ability for Part pins
More Devlog entries
Most recent first
- 2021 07 26 Logic Simulator Update
- 2021 07 24 - Launch of V1.0
- 2021 07 23 - Truth Tables
- 2021 07 22 Progress Update
- 2021 07 21 - Simple Computer Simulation
- 2021 07 16 - Community Forum
- 2021 07 15 - Community News
- 2021 07 11 - Save and Load ROM Data
- 2021 07 09 - Documentation About The Logic Simulator
- 2021 07 08 - Big Progress
- 2021 07 07 - RAM and ROM Testing Complete
- 2021 07 06 - Implementing Tests
- 2021 07 05 - Cool algorithm for binary text string
- 2021 07 04 - Debugging Complex Situations
- 2021 06 30 - End of June - Refactoring Continues
- 2021 06 29 Community
- 2021 06 28 Implementing More OOP
- 2021 06 27 Memory Parts
- 2021 06 25 Memory Data
- 2021 06 24 Memory Management
- 2021 06 23 First Devlog Entry