December 22, 2012

zxsp 0.8.0.pre10: Debugger

Let's the year's end rallye start...
(phht, i had to look up 'rallye'...)

The last weeks i was working on the debugger, especially on break points, and some cosmetic&nice stuff.

So what's new?

In Hex and Disass Memory Inspector:
  • Highlight opcode addressed by register
  • Indicate breakpoints
  • Set & clear Breakpoints
  • Edit memory

Editing in the Hex Memory Inspector

Color codes in the Hex Memory Inspector

The toolbar in the hex inspector now has a button group "Edit", "R", "W" + "X".

If you push down "Edit" you can directly edit the displayed hex data. Any editing is instantaneous. Note, that key input now goes to the edit field and no longer to the running machine. Currently it is not visually shown that the hex field has focus. That's on the ToDo list. Also you cannot yet edit in the Ascii field.

If you push down "R", "W" and/or "X" you are in breakpoint editor mode. Where ever you click you set or clear a breakpoint for Read, Write or Execute. Breakpoints are indicated with colored hex characters:
  • Blue = read
  • Green = Write
  • Red = Execute
  • and any combination, e.g. Yellow = Green+Red = Write+Execute.
If a register points to a certain memory address, the background of the bytes is colored:
  • red (pink) = PC
  • green = SP
  • cyan = HL
  • yellow = other registers
If you hover the mouse over the byte the register is displayed in the tooltip.

Editing in the Disass Inspector

PC highlight and the Edit mode popup in Disass View
The toolbar in the disass view now contains a popup menu for selecting edit mode or breakpoint mode. It has the same functionality as the button group in the hex view. I'm not sure which method is better. 
As in the hex view registers and breakpoints are indicated with colors. As you can see im the screenshot the colors are shown in the hex code column, except for the PC which is shown in the full row. 
If you have selected "Edit" you can edit memory in the hex code column. Again there is not yet a visual indicator that this view has keyboard focus. Also, while you can click on the disassembled opcode to toggle breakpoints you cannot yet edit the opcodes. This will come next.

Other Changes

The Disass inspector now tries to lock on actual opcode boundaries. But this can only be done 95% because this is unavoidably ambiguous.

Qt Version

As you may know Qt 5.0.0 was release yesterday. I have already tried to compile zxsp with Qt 5.0.0. Most code compiled with no problems, but i'm currently stuck because i probably ran into a bug in Qt 5.0.0: OpenGL drawing cannot be set to single buffer mode, but that's what i use in zxsp. Switching to double buffered mode is not trivial in this special case. I hope this is fixed quickly and the next version is compiled against Qt 5.0.0. We'll see.

Happy Christmas to all and a peaceful start into the new year!

    ... Kio !

St. Johann, Erlangen 2012-12-08

p.s: as written, we had a fire in our building and one apartment was completely destroyed.
If you start at the burnt-out flat and go 3 flats right and 6 floors up you may note the small black spot at my window, which is the "little-bat". :-)

December 7, 2012

zxsp 0.8.0.pre9: Memory Inspectors

And on it goes...

"0.8.0.pre9" is out.

What's new?
  • Audio input from standard audio input device
  • Memory inspectors. see screenshot. :-)
Screenshot of zxsp with memory (and some other) inspectors

22:30 It's late and i'm tired.

03:00 Fire in the building, smell of smoke, blue flashlights, -5°C, brrrr...

10:00 Front got a new painting (partially): black.

11:00 ok, back to zxsp!

Audio input

I must admit, this is a little bit kind of "forgotten". Audio input is now enabled by default, if the standard audio input device is compatible with the standard audio out device. Basically this requires the sampling frequencies to be the same. Audio-in selection and support for different sampling frequencies will be added some day in the future.

Memory Inspectors

They can be accessed from the "Windows" menu. 
There are 4 kinds of them: 
  • Hex Inspector
  • Disassembler Inspector
  • Graphical Inspector
  • Memory Access Inspector

Common Functions

All windows are updated in real-time. 
Most windows are freely resizable.

Data Source and Page Selector, Base Address
The first popup lets you select from 5 different kinds of sources: 
  • As seen by CPU: This will display the 64 kB which the CPU currently sees when reading (writing may differ). On some models memory is mirrored or some addresses are not mapped to any memory. Note: if you display memory which is repeatedly mapped to different physical ram or rom with a very large inspector window, then this will result in high CPU usage (of your Mac's CPU).
  • All Ram: Show (a section of) all ram. Memory order is as seen by the CPU for models with no paged memory and in sequence of page numbers for models with paged memory.
  • All Rom: Similar, except for the rom. Note: You cannot display the contents of an external rom, e.g. a rom cartridge, this way. But it can be displayed with "as seen by cpu".
  • Ram Pages: Limit view to certain ram pages. The "Page" popup is added to the tool bar. Ram pages typically range from 1 kB to 16 kB in size. On models with no memory paging the ram is divided into 16 kB chunks. 
  • Rom Pages: Similar, except for the rom.
The second popup let's you select the ram or rom page, if "Ram Pages" or "Rom Pages" is selected.

The address view shows the base address of the inspector display and a new address can be entered here.

Hex Inspector

Hex Inspector
Three fields are shown: The start address of the row, memory contents in hex and memory contents in ascii characters. Editing is not yet supported.
The display can be toggled between byte and word display.
There's a popup which let's you navigate quickly to the address in a register.
Two buttons let you quickly resize the window to 16 and 32 bytes per row.

Disassembler Inspector

Disassembler Inspector
The disassembler also shows three fields: Address of an instruction, up to 4 bytes which construct the instruction and the disassembled opcode.
There's also a quick "goto register" popup. 
Note that the disassembler currently does not try to "lock" to the real start of a Z80 opcode for the first line, so the first lines may always contain garbage, due to a misaligned window base address. 
It's nice to point it at some self-modifying code and watch how the addresses change. :-)
I plan to add a "import labels" option for some later release.

Graphical Inspector

Graphical Inspector: video ram; pixels and attributes

The graphical memory view lets you easily find where the graphics are stored or e.g. view the video ram in it's real layout. 
There's also a quick "goto register" popup and 
a "quick resize" button for 32 bytes per row.
You can make the window as tall as 1 byte per row to see 1-byte-wide graphics or e.g. a character set.

Memory Access Inspector

ZX80 Space Invaders running in 2 kB of ram
The optical highlight, due to it's colors, is the memory access inspector.
Every grid point represents one byte of memory and it's color is composed from red, green and blue.
Each color component has a distinct meaning:
  • Red: This address was executed by the CPU
  • Green: This address was written to by the CPU
  • Blue: This address was read by the CPU
These 3 color components combine to 8 base colors:
  • Black: not accessed
  • Red: executed
  • Green: written
  • Blue: read
  • Cyan: = Green + Blue = read and written
  • Yellow: = Red + Green  = executed and written
  • Magenta: = Red + Blue   = Executed & read: rarely seen.
  • White: = Red + Green + Blue = Executed, written & read.
Depending on the decay mode all color components may come in shades. White tends to be a little magenta'ish.

Decay modes:
  • Flash: The currently accessed memory only flashes once. The update speed is roughly 1/10 sec, so you'll see what has been accessed within 0.1 sec.
  • Decay fast: The displayed pixels are faded slowly, like on a very old oscilloscope. 
  • Decay slow: The displayed pixels are faded very slowly.
  • Accumulate: Pixels are not faded and the access information accumulates. This is good to determine code sections on a long run or to display access during single stepping the CPU.
A popup let's you select the grid size from 2x2 to 4x4.

The rightmost popup let's you select the display width from 32 bytes per row to 512 bytes per row.
The memory access inspector window cannot be resized freely.

Note: You can open as many inspectors as you like and fit on your screen, but the memory access inspector should only opened once, because it "consumes" meta information collected in the target machine. You could, however, open one for ram only and one for rom only, which will not interfere. Or for two different machines, as soon as multiple instances are supported by this version of zxsp.


These four memory inspectors give you a complete new insight into any scrutinized game! :-)