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

Rework PyBeeb into a reusable system, with host interfaces #5

Open
wants to merge 54 commits into
base: master
Choose a base branch
from

Commits on Nov 24, 2023

  1. Replace DOS line endings; strip trailing spaces.

    The files appear to be formatted for DOS line endings, and had trailing
    spaces on some lines. These have now been stripped with:
    
      for i in *.py */*.py ; do
          echo $i ; sed -E -i '' 's/ *\r?$//g' $i
      done
    gerph committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    affbd62 View commit details
    Browse the repository at this point in the history

Commits on Nov 25, 2023

  1. Add Unicorn-like interface.

    There's now an interface that's similar in style to the Unicorn
    interface. The intention is that whilst this won't be a drop in for
    Unicorn, the expectations that you might have from Unicorn, such
    as the means of accessing registers and memory, and executing code,
    are similar.
    gerph committed Nov 25, 2023
    Configuration menu
    Copy the full SHA
    e33331c View commit details
    Browse the repository at this point in the history
  2. Move the entire emulation system into a package.

    In order to be reusable in other systems, it is better if the whole
    emulation system be in a package, rather than at the top level of the
    namespace.
    
    This change moves everything into a `pybeeb` package.
    gerph committed Nov 25, 2023
    Configuration menu
    Copy the full SHA
    453e5b6 View commit details
    Browse the repository at this point in the history
  3. Fix up tests to run with the new structure.

    The tests hadn't been updated to run in the new packaged structure.
    gerph committed Nov 25, 2023
    Configuration menu
    Copy the full SHA
    65335c1 View commit details
    Browse the repository at this point in the history
  4. Make the executable code executable.

    The PyBeeb, PyBeebU and test files are now executable under unix systems
    and given shebang lines.
    gerph committed Nov 25, 2023
    Configuration menu
    Copy the full SHA
    9e8a67a View commit details
    Browse the repository at this point in the history
  5. Move execution hooks to just before execution.

    The execution hook was happening before the start of the decode
    because there wasn't an easy way to inject after it. This meant that
    it was not possible to report the instruction length. It might not
    be a big problem, but it did mean that we couldn't call the hook
    as easily. We now call the hook with the right details by having
    a class that inherits from the Dispatcher do the hook calls.
    gerph committed Nov 25, 2023
    Configuration menu
    Copy the full SHA
    b24b2cd View commit details
    Browse the repository at this point in the history
  6. Fix for BRK not dispatching to the IRQ handler.

    The last address in the memory map regions would not be supplied - the
    check for whether the memory was in the mapped object was not allowing
    for the inclusive end address of the mapping. This meant that the
    IRQ entry point (which is used by BRK) would be called with the high
    address byte being returned from the standard memory, which was 0.
    Instead of calling &DC1C, it was calling &001C.
    
    We now check the memory region inclusively.
    gerph committed Nov 25, 2023
    Configuration menu
    Copy the full SHA
    005547f View commit details
    Browse the repository at this point in the history
  7. Standardise instruction exceptions.

    The instruction exceptions are now standarised to use an Exception
    for the instructions, rather than a BaseException. The undefined
    instructions are also reported as exceptions now, as well.
    gerph committed Nov 25, 2023
    Configuration menu
    Copy the full SHA
    472abbb View commit details
    Browse the repository at this point in the history
  8. Update Registers to have a useful __repr__.

    The __repr__ for Registers now includes their values.
    gerph committed Nov 25, 2023
    Configuration menu
    Copy the full SHA
    ef80517 View commit details
    Browse the repository at this point in the history

Commits on Nov 26, 2023

  1. Fix for readBytes/writeBytes interface not terminating.

    The readBytes and writeBytes interfaces hadn't stopped when they reached
    the end of the requested region because of a failure to account of the
    end of mapped regions.
    gerph committed Nov 26, 2023
    Configuration menu
    Copy the full SHA
    777a57d View commit details
    Browse the repository at this point in the history
  2. Fix PyBeebicorn's handling of register writes; hooks can now reset PC.

    The register writes in the PyBeebicorn interface were always being
    AND'd with 255, even for the PC. The value stored is checked in each
    writer function now.
    
    The execution hooks are now able to reset the PC value when they are
    run, preventing the execution of the instruction that was decoded.
    gerph committed Nov 26, 2023
    Configuration menu
    Copy the full SHA
    deb9acc View commit details
    Browse the repository at this point in the history
  3. Minor clean up to the dispatch handler.

    The BRK now returns the address to call, and reset has a variable
    instead of just calling a magic address.
    gerph committed Nov 26, 2023
    Configuration menu
    Copy the full SHA
    c22fca4 View commit details
    Browse the repository at this point in the history
  4. Add console handling - RDCH is able to work.

    The RDCH entry point is replaced by a key reader from the console.
    This uses the console code that I wrote for RISC OS Pyromaniac,
    modified to be independant on Pyro.
    
    This allows the RDCH entry point to be modified to handle the key
    input. It's not great because we lose *Exec handling, but since we
    don't have a filesystem or any other interfaces, that's not a big
    deal right now.
    gerph committed Nov 26, 2023
    Configuration menu
    Copy the full SHA
    718043b View commit details
    Browse the repository at this point in the history
  5. Fix for timeout being None not being handled.

    The timeout value of None means 'wait forever', but it wasn't actually
    working because it had never been tested. We now check this more
    carefully.
    gerph committed Nov 26, 2023
    Configuration menu
    Copy the full SHA
    77cbeb6 View commit details
    Browse the repository at this point in the history
  6. Removed stray debug in PyBeebicorn.

    A debug had been left in the PyBeebicorn interface when the PC
    was set.
    gerph committed Nov 26, 2023
    Configuration menu
    Copy the full SHA
    c4bf2e6 View commit details
    Browse the repository at this point in the history
  7. Update the PyBeebU to handle lack of input.

    If there's no input, we could return None. This might happen if there
    had been input but no characters were actually read, or the timeout
    occurred.
    gerph committed Nov 26, 2023
    Configuration menu
    Copy the full SHA
    f66c406 View commit details
    Browse the repository at this point in the history
  8. Update the handling of backspace to delete characters.

    We can now delete characters in the character input handler, and
    they will be output properly.
    gerph committed Nov 26, 2023
    Configuration menu
    Copy the full SHA
    d89e473 View commit details
    Browse the repository at this point in the history
  9. Add support for memory access hooks.

    The memory access hooks allow us to report when reads or writes happen
    to memory. They may be problematic at the moment as the store operations
    appear to read the values from the memory as well, before they then go
    and store to the locations.
    gerph committed Nov 26, 2023
    Configuration menu
    Copy the full SHA
    9658662 View commit details
    Browse the repository at this point in the history
  10. Add support for Escape in the RDCH function.

    The RDCH function was not reading the escape key properly, because
    we weren't setting the C flag. It also appears that unless you set
    the error condition in zero-page, the system won't report the error
    properly.
    gerph committed Nov 26, 2023
    Configuration menu
    Copy the full SHA
    00184d8 View commit details
    Browse the repository at this point in the history

Commits on Nov 28, 2023

  1. Update the console.py module with full version from Pyromaniac.

    I had originally cut down the console.py to be a limited, POSIX only,
    version of the console.py implementation. However, there's no reason
    why this cannot be used on Windows so I may as well include the
    Windows version. It should work reasonably well, but it's not as
    polished as the POSIX version.
    gerph committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    7154399 View commit details
    Browse the repository at this point in the history

Commits on Dec 4, 2023

  1. Add support for disassembling the 6502 code as it executes.

    There is now a simple disassembler (more than the original one) in
    the PyBeebicorn code, which can disassemble the code as it is
    executed. This can be used in a hook to trace only certain sections
    of the code.
    gerph committed Dec 4, 2023
    Configuration menu
    Copy the full SHA
    b62b89d View commit details
    Browse the repository at this point in the history

Commits on Dec 5, 2023

  1. Add code coverage for the tests that we have.

    We can now exercise the code in some tests that can be run in a
    Makefile. Only the coverage run is explicitly supported right now,
    and it'll fail if the tests fail, so it's a combined coverage
    and test reporter. We mix the unit tests and the integration tests
    at the moment, and the output from the integration test isn't
    checked for regressions.
    gerph committed Dec 5, 2023
    Configuration menu
    Copy the full SHA
    49f46a3 View commit details
    Browse the repository at this point in the history
  2. Add github workflow to run the coverage/tests on pushes.

    There is a simple workflow here to run the coverage and tests on
    push. We're only running under Python 2, still, but it should be
    sufficient to make it work for us.
    gerph committed Dec 5, 2023
    Configuration menu
    Copy the full SHA
    c8df945 View commit details
    Browse the repository at this point in the history

Commits on Dec 7, 2023

  1. Rework the OSInterfaces in the example program.

    The PyBeepicorn example program now has some more abstracted interface
    entry points. These are set up in such a way that we can use them
    without (in theory) having the knowledge of the underlying system.
    They should be easy to extend for the other APIs.
    gerph committed Dec 7, 2023
    Configuration menu
    Copy the full SHA
    afe9090 View commit details
    Browse the repository at this point in the history
  2. Add an OSCLI handler to allow exiting.

    We now have a very simple OSCLI handler so that we can trap *QUIT and
    exit the emulator. If we don't recognise the command it is passed
    to the rest of the handler system.
    gerph committed Dec 7, 2023
    Configuration menu
    Copy the full SHA
    5e8ec79 View commit details
    Browse the repository at this point in the history

Commits on Dec 8, 2023

  1. Add OSBYTE and OSWORD hooked classes.

    We now have classes which are hookable so that we can replace the
    OSBYTE and OSWORD implementations. This allows us to provide some
    interfaces to the host system which override the BBC implementation.
    gerph committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    d368369 View commit details
    Browse the repository at this point in the history
  2. Move all the host interfaces for the BBC MOS to a package.

    The host interfaces have now moved into a package so that they can
    be used more generically if people want. Specific routines that
    interface with the host are separate from the base implementations
    so that they don't have to be the way that you communicate with
    the system.
    gerph committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    17d5702 View commit details
    Browse the repository at this point in the history

Commits on Dec 9, 2023

  1. Add initial support for filesystem interfaces.

    The filesystem interfaces OSFILE, OSARGS, OSBPUT, OSBGET, OSFIND
    have been given base implementations which dispatch to different
    routines. They're not especially well suited to being overridden
    because each class is independant. Ideally we'd allow a common
    interface to be provided for the filesystem, which those classes
    could access.
    gerph committed Dec 9, 2023
    Configuration menu
    Copy the full SHA
    7b7ceae View commit details
    Browse the repository at this point in the history
  2. Rework the base OS interfaces to be more flexible.

    The base OS interfaces were duplicating some behaviour and not as
    common as you might like. The interfaces are a little easier to
    update now. It's not clear that they're actually going to make for
    a better general experience but they will allow some more
    flexibility.
    
    Also a few typos fixed.
    gerph committed Dec 9, 2023
    Configuration menu
    Copy the full SHA
    710238f View commit details
    Browse the repository at this point in the history

Commits on Dec 10, 2023

  1. Initial implementation of OSGBPB.

    OSGBPB's byte operations are now implemented in a base class. The other
    GBPB operations that handle the media name, and directory enumeration
    are not yet implemented.
    gerph committed Dec 10, 2023
    Configuration menu
    Copy the full SHA
    2204c0a View commit details
    Browse the repository at this point in the history

Commits on Dec 11, 2023

  1. Allow the cursor key decoding to work when no timeout present.

    When the timeout is absent, we weren't handling the cursor key
    decoding. This meant that they came out as escaped VT codes instead
    of BBC style codes.
    gerph committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    50d21d0 View commit details
    Browse the repository at this point in the history
  2. Initial support for Python 3.

    Most of the operations have now been updated so that they work with
    Python 3, allowing us to run the commands safely with Python 3.9 at
    least. The code still works with Python 2.7 as well.
    gerph committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    8181172 View commit details
    Browse the repository at this point in the history
  3. Add dispatcher for the remaining OSGBPB calls.

    We now have the dispatcher handling OSGBPB calls for directory names
    and the reading of filenames.
    gerph committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    fe4cd25 View commit details
    Browse the repository at this point in the history

Commits on Dec 12, 2023

  1. Added base implementation of the OSFSC interface.

    The OSFSC base implementation is now provided.
    gerph committed Dec 12, 2023
    Configuration menu
    Copy the full SHA
    f35e493 View commit details
    Browse the repository at this point in the history

Commits on Dec 16, 2023

  1. Add rudimetary host filesystem module and implementation of load/save.

    We now have a host filesystem module, fsbbc.py, which provides a
    BBC-like interface to the host filesystem. It's not tested beyond
    being run through a few simple exercises, but the name translation
    is based on code from RISC OS Pyromaniac so it should have the
    right style of thing in it.
    
    The OSFILE load and OSFILE save operations are implemented and these
    allow BASIC to load files and save them.
    gerph committed Dec 16, 2023
    Configuration menu
    Copy the full SHA
    ee17e65 View commit details
    Browse the repository at this point in the history

Commits on Dec 18, 2023

  1. Implement remaining OSFILE interfaces for host filesystem.

    We now have the read/write file information and their variants,
    and the delete operation, implemented in the host filesystem version
    of OSFILE.
    gerph committed Dec 18, 2023
    Configuration menu
    Copy the full SHA
    88aa903 View commit details
    Browse the repository at this point in the history
  2. Add simple implementation of host stream open and output.

    OSFIND, OSBGET and OSBPUT are now implemented. This should hopefully
    do the right thing for us, although they're not well tested.
    gerph committed Dec 18, 2023
    Configuration menu
    Copy the full SHA
    587abc6 View commit details
    Browse the repository at this point in the history
  3. Fix for incorrect data mode for ADC indexed Y access.

    The data mode for ADC indexed Y access was listed as `imy` instead
    of `iny`.
    gerph committed Dec 18, 2023
    Configuration menu
    Copy the full SHA
    046a41b View commit details
    Browse the repository at this point in the history
  4. Add simple implementation of the OSARGS calls.

    We now implement some of the stream handling in OSARGS, allowing us
    to manipulate the pointer.
    gerph committed Dec 18, 2023
    Configuration menu
    Copy the full SHA
    73ff734 View commit details
    Browse the repository at this point in the history

Commits on Dec 19, 2023

  1. Update Makefile to clean away .pyc files.

    The .pyc files can be cleaned away to make them get rebuilt. Useful
    if we're changing content.
    gerph committed Dec 19, 2023
    Configuration menu
    Copy the full SHA
    2bcfd52 View commit details
    Browse the repository at this point in the history
  2. Move host.py to hosttty.py.

    The hosttty.py file is there to operate only on the TTY, so we might as
    well name it as such.
    gerph committed Dec 19, 2023
    Configuration menu
    Copy the full SHA
    6f366a8 View commit details
    Browse the repository at this point in the history
  3. Add hosttty support for INKEY(+ve).

    Reading a key within a time limit is now supported by the INKEY
    OSBYTE call.
    gerph committed Dec 19, 2023
    Configuration menu
    Copy the full SHA
    f9391ca View commit details
    Browse the repository at this point in the history
  4. Add support for EOF to host FS implementation.

    The EOF check now works, either when called through OSFSC or OSBYTE.
    gerph committed Dec 19, 2023
    Configuration menu
    Copy the full SHA
    dca7658 View commit details
    Browse the repository at this point in the history

Commits on Dec 20, 2023

  1. Fix for OSARGS not triggering.

    Two hex digits in the code address for OSARGS had been transposed,
    meaning it was never called. And the EXT handler hadn't assigned the
    right variable.
    gerph committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    ce3919f View commit details
    Browse the repository at this point in the history
  2. Update OSRDCH to allow buffer and *exec to be used.

    Buffering and *Exec are handled as part of OSRDCH, but we need to
    process the routing a little later, after all the code which retrieves
    from the file, and checks the buffer. That way, if there is buffered
    data, we'll use it.
    gerph committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    51d96ab View commit details
    Browse the repository at this point in the history

Commits on Dec 22, 2023

  1. Rename PyBeebicorn to Emulation; replace 'regs, memory' with 'pb'.

    The PyBeebicorn interface is now a main interface, with the name
    Emulation, instead of PyBeebicorn. This allows it to be passed
    around more freely. As such, instead of referring throug the regs
    and memory objects which are passed in, we now pass through the
    emulator obejct `pb`.
    gerph committed Dec 22, 2023
    Configuration menu
    Copy the full SHA
    bfbe5a7 View commit details
    Browse the repository at this point in the history

Commits on Dec 23, 2023

  1. Add MOS interfaces to call code; implement *CAT.

    We now have a MOS interface that allows us to call 6502 code which is
    necessary to write characters to the display. And we use this with the
    *CAT interface. We also have a CWD in the filesystem now.
    gerph committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    9e57509 View commit details
    Browse the repository at this point in the history
  2. Add support for *DIR.

    We now support *DIR properly, and we have a number of fixes for command
    line uses.
    gerph committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    e343cf4 View commit details
    Browse the repository at this point in the history
  3. Fix for Python 3 support in the Host/base.py module.

    Python 3 support had been broken when the CLI handling had been
    reworked.
    gerph committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    d69f5bc View commit details
    Browse the repository at this point in the history
  4. Update documentation to reflect current state.

    The documentation has been updated to reflect how the code has changed
    to focus on the new hooking system and the ability to interact with the
    host system. The old code has been moved to PyBeebMinimal.py as part
    of this.
    gerph committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    8849c81 View commit details
    Browse the repository at this point in the history
  5. Fixes for the Coverage runs.

    Coverage runs of the Memory tests hadn't been working at all. They were
    not invoking the unittest on the module. We now correctly invoke that
    and get better coverage because of it.
    
    The coverage had been confused on MacOS because PyBeeb.py and
    pybeeb/__init__.py are effectively the same module, so we were getting
    other references to modules that weren't really there. To avoid this
    problem, and to make it easier to understand the difference between
    the tool and the package, the command line program has been renamed
    to `RunBeeb.py`.
    gerph committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    e6c0e36 View commit details
    Browse the repository at this point in the history
  6. Updated Python 3 support to cover filesystem interfaces.

    The filesystem interfaces should now be reporting the filenames
    properly to the BBC and back out again to the host filesystem,
    when used in both Python 2 and Python 3.
    gerph committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    30cf7b9 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    5c155b0 View commit details
    Browse the repository at this point in the history

Commits on Jun 13, 2024

  1. Allow *Exec to work with the host readline; ctrl-c=>escape in RDCH.

    When *Exec is used and we're trying to read a line, don't call the
    host ReadLine interface. Instead we fall back to the standard
    ReadLine in the MOS which will read characters and insert them into
    the input from the file.
    
    When ctrl-c is pressed whilst waiting for a key press, we now treat
    this as an escape press.
    gerph committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    312c229 View commit details
    Browse the repository at this point in the history