Exemplo n.º 1
0
def setup_module():
    global vars, symbol_table, execution_address
    """Load the Emulator from the ROM script and Mandelbrot
    """
    reload(asm)
    name, _ = os.path.splitext(os.path.basename(SCRIPT))
    script_globals = {"__file__": str(SCRIPT.absolute()), "__name__": name}
    with SCRIPT.open("rb") as file:
        exec(compile(file.read(), SCRIPT, "exec"), script_globals)
    Emulator.load_rom_from_asm_module()
    vars = SimpleNamespace(**script_globals)

    # This sequence of calls is roughly taken from compilegcl.py
    old_rom_size = asm._romSize
    program = gcl.Program("Mandelbrot", forRom=False)
    user_code = asm.symbol("userCode")
    user_vars = asm.symbol("userVars")
    program.org(user_code)
    asm.align(1)
    asm.zpReset(user_vars)
    with GCL.open("r", encoding="utf-8") as fp:
        for line in fp.readlines():
            program.line(line)
    program.end()
    asm.end()

    # Copy the resulting data straight into RAM, in the appropriate blocks
    data = asm.getRom1()[old_rom_size:]
    index, more_data = 0, bool(data)
    while more_data:
        start_address = int.from_bytes(data[index:index + 2],
                                       "big",
                                       signed=False)
        index += 2
        size = data[index] or 256
        index += 1
        chunk = data[index:index + size]
        index += size
        RAM[start_address:start_address + len(chunk)] = chunk
        more_data = data[index]
    execution_address = program.execute
    symbol_table = program.vars
Exemplo n.º 2
0
                    help='Optional output directory')
args = parser.parse_args()

#-----------------------------------------------------------------------
#       Compile
#-----------------------------------------------------------------------

asm.loadBindings(args.sym)
if args.gt1x:
  asm.loadBindings('Core/interface-dev.json')

userCode = asm.symbol('userCode')
userVars = asm.symbol('userVars')

print('Compiling file %s' % args.gclSource)
program = gcl.Program('Main', forRom=False)
program.org(userCode)
asm.align(1)          # Forces default maximum ROM size
asm.zpReset(userVars) # User variables can start here
for line in open(args.gclSource).readlines():
  program.line(line)
program.end()
asm.end() # End assembly
data = asm.getRom1()

#-----------------------------------------------------------------------
#       Append ending
#-----------------------------------------------------------------------

address = program.execute
Exemplo n.º 3
0
                    nargs='?',
                    default='.',
                    help='Optional output directory')
args = parser.parse_args()

#-----------------------------------------------------------------------
#       Compile
#-----------------------------------------------------------------------

asm.loadBindings(args.sym)

userCode = asm.symbol('userCode')
userVars = asm.symbol('userVars')

print('Compiling file %s' % args.gclSource)
program = gcl.Program(userCode, 'Main', forRom=False)
asm.align(1)  # Forces default maximum ROM size
asm.zpReset(userVars)  # User variables can start here
for line in open(args.gclSource).readlines():
    program.line(line)
program.end()
asm.end()  # End assembly
data = asm.getRom1()

#-----------------------------------------------------------------------
#       Append ending
#-----------------------------------------------------------------------

address = program.execute

# Inject patch for reliable start using ROM v1 Loader application