Beispiel #1
0
 def change_file(self):
     oldselected = self.fb_selected - self.fb_topitem
     self.fb_selected = self.fb_cursor
     try:
         filename = self.fullpath(self.direntries[self.fb_cursor][0])
     except:
         filename = False
         self.fb_selected = -1
     self.show_dir_line(oldselected)
     self.show_dir_line(self.fb_cursor - self.fb_topitem)
     if filename:
         if filename.endswith(".bit"):
             self.spi_request.irq(handler=None)
             self.timer.deinit()
             self.enable[0] = 0
             self.osd_enable(0)
             self.spi.deinit()
             tap = ecp5.ecp5()
             tap.prog_stream(open(filename, "rb"), blocksize=1024)
             if filename.endswith("_sd.bit"):
                 os.umount("/sd")
                 for i in bytearray([2, 4, 12, 13, 14, 15]):
                     p = Pin(i, Pin.IN)
                     a = p.value()
                     del p, a
             result = tap.prog_close()
             del tap
             gc.collect()
             #os.mount(SDCard(slot=3),"/sd") # BUG, won't work
             self.init_spi()  # because of ecp5.prog() spi.deinit()
             self.spi_request.irq(trigger=Pin.IRQ_FALLING,
                                  handler=self.irq_handler_ref)
             self.irq_handler(0)  # handle stuck IRQ
         if filename.endswith(".nes") \
         or filename.endswith(".snes") \
         or filename.endswith(".smc") \
         or filename.endswith(".sfc"):
             import ld_nes
             s = ld_nes.ld_nes(self.spi, self.cs)
             s.ctrl(1)
             s.ctrl(0)
             s.load_stream(open(filename, "rb"), addr=0, maxlen=0x101000)
             del s
             gc.collect()
             self.enable[0] = 0
             self.osd_enable(0)
         if filename.startswith(
                 "/sd/ti99_4a/") and filename.lower().endswith(".bin"):
             import ld_ti99_4a
             s = ld_ti99_4a.ld_ti99_4a(self.spi, self.cs)
             s.load_rom_auto(open(filename, "rb"), filename)
             del s
             gc.collect()
             self.enable[0] = 0
             self.osd_enable(0)
         if (filename.startswith("/sd/msx") and filename.endswith(".rom")) \
         or filename.endswith(".mx1"):
             import ld_msx
             s = ld_msx.ld_msx(self.spi, self.cs)
             s.load_msx_rom(open(filename, "rb"))
             del s
             gc.collect()
             self.enable[0] = 0
             self.osd_enable(0)
         if filename.endswith(".z80"):
             self.enable[0] = 0
             self.osd_enable(0)
             import ld_zxspectrum
             s = ld_zxspectrum.ld_zxspectrum(self.spi, self.cs)
             s.loadz80(filename)
             del s
             gc.collect()
         if filename.endswith(".ora") or filename.endswith(".orao"):
             self.enable[0] = 0
             self.osd_enable(0)
             import ld_orao
             s = ld_orao.ld_orao(self.spi, self.cs)
             s.loadorao(filename)
             del s
             gc.collect()
         if filename.endswith(".vsf"):
             self.enable[0] = 0
             self.osd_enable(0)
             import ld_vic20
             s = ld_vic20.ld_vic20(self.spi, self.cs)
             s.loadvsf(filename)
             del s
             gc.collect()
         if filename.endswith(".prg"):
             self.enable[0] = 0
             self.osd_enable(0)
             import ld_vic20
             s = ld_vic20.ld_vic20(self.spi, self.cs)
             s.loadprg(filename)
             del s
             gc.collect()
         if filename.endswith(".cas"):
             self.enable[0] = 0
             self.osd_enable(0)
             import ld_trs80
             s = ld_trs80.ld_trs80(self.spi, self.cs)
             s.loadcas(filename)
             del s
             gc.collect()
         if filename.endswith(".cmd"):
             self.enable[0] = 0
             self.osd_enable(0)
             import ld_trs80
             s = ld_trs80.ld_trs80(self.spi, self.cs)
             s.loadcmd(filename)
             del s
             gc.collect()
Beispiel #2
0
def change_file():
    global fb_selected, fb_topitem, fb_cursor
    oldselected = fb_selected - fb_topitem
    fb_selected = fb_cursor
    try:
        filename = fullpath(direntries[fb_cursor][0])
    except:
        filename = False
        fb_selected = -1
    show_dir_line(oldselected)
    show_dir_line(fb_cursor - fb_topitem)
    if filename:
        if filename.endswith(".bit"):
            spi_request.irq(handler=None)
            timer.deinit()
            enable[0] = 0
            osd_enable(0)
            spi.deinit()
            tap = ecp5.ecp5()
            tap.prog_stream(open(filename, "rb"), blocksize=1024)
            if filename.endswith("_sd.bit"):
                os.umount("/sd")
                for i in bytearray([2, 4, 12, 13, 14, 15]):
                    p = Pin(i, Pin.IN)
                    a = p.value()
                    del p, a
            result = tap.prog_close()
            del tap
            gc.collect()
            #os.mount(SDCard(slot=3),"/sd") # BUG, won't work
            init_spi()  # because of ecp5.prog() spi.deinit()
            spi_request.irq(trigger=Pin.IRQ_FALLING, handler=irq_handler_ref)
            irq_handler(0)  # handle stuck IRQ
        if filename.endswith(".z80"):
            enable[0] = 0
            osd_enable(0)
            import ld_zxspectrum
            s = ld_zxspectrum.ld_zxspectrum(spi, cs)
            s.loadz80(filename)
            del s
            gc.collect()
        if filename.endswith(".nes"):
            import ld_zxspectrum
            s = ld_zxspectrum.ld_zxspectrum(spi, cs)
            s.ctrl(1)
            s.ctrl(0)
            s.load_stream(open(filename, "rb"), addr=0, maxlen=0x101000)
            del s
            gc.collect()
            enable[0] = 0
            osd_enable(0)
        if filename.endswith(".ora") or filename.endswith(".orao"):
            enable[0] = 0
            osd_enable(0)
            import ld_orao
            s = ld_orao.ld_orao(spi, cs)
            s.loadorao(filename)
            del s
            gc.collect()
        if filename.endswith(".vsf"):
            enable[0] = 0
            osd_enable(0)
            import ld_vic20
            s = ld_vic20.ld_vic20(spi, cs)
            s.loadvsf(filename)
            del s
            gc.collect()
        if (filename.find("vic20") >= 0 or filename.find("VIC20") >= 0) and (
                filename.endswith(".prg") or filename.endswith(".PRG")):
            enable[0] = 0
            osd_enable(0)
            import ld_vic20
            s = ld_vic20.ld_vic20(spi, cs)
            s.loadprg(filename)
            del s
            gc.collect()
        if (filename.find("c64") >= 0 or filename.find("C64") >= 0) and (
                filename.endswith(".prg") or filename.endswith(".PRG")):
            enable[0] = 0
            osd_enable(0)
            import ld_c64
            s = ld_c64.ld_c64(spi, cs)
            s.loadprg(filename)
            del s
            gc.collect()