DREAMER DEBUGGER


To enter debug mode, check the Debugger box in the main screen.


The debugger has 4 windows:
        -Disassembly window
           In this window you can see the disassembled code that is being
           executed. The White bar marks the next instruction to be executed
        -Registers window
           Here you can see the values of the SH4 registers
        -Data window
           In this window you can see a dump of the memory contents at a
           given address.
        -Messages window
           Here will appear messages given by the emulator and by the debugging
           interface (see below).


Executing code:
        The disassembly window is divided in 2 zones, the code zone and
        the command zone.

        In the command zone you can write commands to the emulator. The
        supported commands are:

                D address       - Display the data at the specified address
                E address hex   - Writes the value to the byte at that address
                F               - Write the framebuffer to the screen
                G address       - Execute until the given address
                R register hex  - Write the 32 bit hex value to the given reg
                                  (not all regs can be modified, T flag can be
                                  used "ex: r t 1")
                S               - Stop emulation (and return to debugger)
                WC 1|0          - Shows/hides the code window
                WD 1|0          - Shows/hides the data window
                WM 1|0          - Shows/hides the messages window
                WR 1|0          - Shows/hides the registers window
                X               - Exit emulator
                Z               - Reset (not working)
                <               - Show RCount value in messages window (see
                                  patches.txt for the usage of RCount).

        The execution keys are:
                F5              - Run
                F7              - Trace Into
                F8              - Step Over
                S               - Stop emulation (and return to debugger)



Debugging interface:

        The debugging interface provides communication between the program
        currently running in the emulator and the programmer that is
        debugging it. It currently supports 2 features:

                Stop emulation
                Write Message into message window

        The interface works using an unused SH4 opcode. This opcode is 0x004b
        (be careful with different endianness compilers, it could be 0x4b00)

        The feature is selected by the value of the R5 register:
                R5=0    Stop debugger (and return control to debugger)
                R5=1    Write Message to message window. You must set R6 to
                        the address of a zero terminated string stored in the
                        main SH4 RAM in any access mode (0x0c000000-0x0d000000,
                        0x8c000000-0x8d000000 or 0xac000000-0xad000000)

        Examples:       (using Hitachi assembler syntax)
        void debug_message(char *string)
        {
                register unsigned int k=(int) string;
                asm
                {
                        mov 0,R5
                        mov k,R6
                        .data.w 0x004b
                }
        }

        void debug_halt()
        {
                asm
                {
                        mov 1,R5
                        mov 0,R6
                        .data.w 0x004b
                }
        }

