├── .clang-format ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── .gitmodules ├── .jenkinsfile ├── 65xx_and_c64_docs └── cpu_internals.txt ├── LICENSE.txt ├── Makefile ├── README.md ├── TRADEMARKS.md ├── assets ├── 8x8font.png ├── alphatest.bin ├── ascii00-7f.png ├── game │ ├── blackness.gif │ ├── bomb.gif │ ├── dark.gif │ ├── hammer.gif │ ├── posion.gif │ ├── shadow.gif │ ├── soldier.gif │ └── turret.gif ├── matrix.png ├── matrix_banner.txt ├── mega65_320x64.png ├── synthesised-60ns.dat ├── track2-40ns.dat └── vfpga-bitstream.bin ├── bin └── .gitkeep ├── d81-files ├── benchscores.prg └── raster65.mega.prg ├── docs ├── 45GS10-Processor-Notes.md ├── MEGA65_System_Partition.md ├── build.md ├── fat32.md ├── hickup.md ├── howtocontribute.md ├── howtoedit.md ├── images │ ├── container-small.jpg │ ├── container.jpg │ ├── container.pdf │ ├── iomapper-small.jpg │ ├── iomapper.jpg │ ├── iomapper.pdf │ ├── machine-small.jpg │ ├── machine.jpg │ ├── machine.pdf │ ├── monitor-small.jpg │ ├── monitor.jpg │ ├── monitor.pdf │ ├── precomp-small.jpg │ ├── precomp.jpg │ └── precomp.pdf ├── index.md ├── math-unit.md ├── monitor.md ├── sdcard-and-floppy-drive.md ├── secure_mode.md ├── structural.md ├── supported-hardware.md ├── test-c65mode.md ├── test-powerandbootup.md ├── test.md ├── usermanual0.md ├── using.md ├── viciv-modes-16-bit-charmode-1.prg ├── viciv-modes.md └── xemu.md ├── i2c_slave ├── license.txt └── rtl │ └── vhdl │ ├── i2c_slave.vhdl │ └── pca9555.vhdl ├── iomap.txt ├── mega65_config.inc ├── megaphone-write-flash.sh ├── megaphone-write-flash.tcl ├── nexys4ddr-write-flash.sh ├── nexys4ddr-write-flash.tcl ├── record-m65 ├── release-build ├── Changelog.md ├── README-dev.md ├── README.md ├── UPGRADE.md ├── build-release.sh └── prepare.sh ├── run_ise ├── spdif_out ├── spdf_out.vhd ├── tb_spdif_out.vhd └── tb_timebase.vhd ├── src ├── _unused │ ├── 4510tables.c │ ├── 64net.opc │ ├── 911001.bin │ ├── c65-rom-910111.bin │ ├── c65-rom-annotations.txt │ ├── chargen_debug.c │ ├── dis4510.c │ ├── diskchooser.a65 │ ├── em4510.c │ ├── etherload_done.a65 │ ├── etherload_stub.a65 │ ├── ghdl-frame-gen.c │ ├── monitor_drive.c │ ├── read_mem.c │ ├── textmodetest-dejavus.f65 │ └── textmodetest.a65 ├── _unused2 │ ├── DCM_1x_2x.vhd │ ├── Ram2Ddr.vhd │ ├── alpha_blend_top.vhd │ ├── bcdadder.vhdl │ ├── c64accel.xise │ ├── cpu6502.ucf │ ├── cputest.a65 │ ├── dual_stream_blend.vhd │ ├── fontfiddle.c │ ├── ghdl_ram151x512.vhdl │ ├── ghdl_ram8x64k.vhdl │ ├── kernel65.a65 │ ├── load.java │ ├── makeslowram │ ├── mkversiona65.sh │ ├── rom_4k_template.vhdl │ ├── rxvideo.c │ ├── serialproxy.c │ ├── slowram_template.vhdl │ ├── sprite_iv.vhdl │ ├── tb_adder.vhdl │ ├── tb_cia.vhdl │ └── upload.py ├── bitmap800x480.a65 ├── border.a65 ├── ftphelper.a65 ├── hyppo │ ├── audiomix.asm │ ├── constants.asm │ ├── debug.asm │ ├── debugtests.asm │ ├── dos.asm │ ├── dos_write.asm │ ├── freeze.asm │ ├── hyppo.test │ ├── joyflash.asm │ ├── keyboard.asm │ ├── machine.asm │ ├── macros.asm │ ├── main.asm │ ├── mem.asm │ ├── process_descriptor.asm │ ├── sdfat.asm │ ├── securemode.asm │ ├── syspart.asm │ ├── targetsetup.asm │ ├── task.asm │ ├── ultimax.asm │ └── virtual_f011.asm ├── i2ctest.a65 ├── keyboard.txt ├── mega65_64x64.png ├── megacartstub.a65 ├── modeline.c ├── monitor │ ├── gen_dis.c │ └── monitor.a65 ├── test_fdisk ├── tests │ ├── Makefile │ ├── bitplanes.a65 │ ├── eth_mdio.c │ ├── fatload.a65 │ ├── horses.h │ ├── instructiontiming.c │ ├── instructiontiming_asm.s │ ├── keyboard.a65 │ ├── packedtileset.a65 │ ├── pulseoxy.c │ ├── test_diskmenu_sort.a65 │ ├── test_fdc_equal_flag.a65 │ ├── text_overwrite.a65 │ ├── thumbnail.a65 │ ├── unicorns.c │ ├── vicii.c │ ├── vicii.cfg │ └── vicii_asm.s ├── tools │ ├── .gitignore │ ├── bin2c.c │ ├── bit2mcs.c │ ├── bitinfo.c │ ├── c64float.c │ ├── etherhyppo │ │ └── etherhyppo.c │ ├── etherload │ │ └── etherload.c │ ├── ethermon.c │ ├── format_banner.c │ ├── fpgajtag │ │ ├── boundary_scan.c │ │ ├── cortex.c │ │ ├── dumpdata.h │ │ ├── elfdef.h │ │ ├── fpga.h │ │ ├── fpgajtag.c │ │ ├── mdm.c │ │ ├── process.c │ │ ├── util.c │ │ └── util.h │ ├── frame2png.c │ ├── freq_finder.c │ ├── ghdl-vcd.c │ ├── hotpatch │ │ └── hotpatch.c │ ├── hyppotest-opcodes.test │ ├── hyppotest-self.test │ ├── hyppotest.c │ ├── i2cstatemapper.c │ ├── iecwaveform.c │ ├── makerom │ │ ├── colourram_template.vhdl │ │ ├── makerom │ │ └── rom_template.vhdl │ ├── matrix_banner.c │ ├── matrix_munger.c │ ├── matrixgen.c │ ├── mempacker │ │ ├── mempacker.c │ │ ├── mempacker_new.c │ │ └── mempacker_v.c │ ├── merge-issue.c │ ├── mkdriverom.c │ ├── on_screen_keyboard_gen.c │ ├── osk_image.c │ ├── pngprepare │ │ ├── giftotiles.c │ │ ├── pngprepare.c │ │ ├── pngtoscreens.c │ │ └── rlepack.c │ ├── screenbuilder.py │ ├── sdstates.c │ ├── test_procedure_format.c │ ├── utilpacker │ │ ├── Makefile │ │ └── utilpacker.c │ ├── vhdl-path-finder.c │ ├── videoproxy.c │ └── vncserver.c ├── utilities │ ├── c65-rom-910111-fastload-patch.a65 │ ├── c65test02prg.a65 │ ├── cpusim.asm │ ├── diskmenu.a65 │ ├── diskmenu_sort.a65 │ ├── diskmenuc000.a65 │ ├── diskmenuprg.a65 │ ├── etherload.a65 │ ├── ethertxtest.a65 │ ├── floppystatus.c │ ├── getsdcardinfo.sh │ ├── hdmistatus.a65 │ ├── hdmitest.a65 │ ├── hyperramtest.c │ ├── i2clist.c │ ├── i2cstatus.c │ ├── joyflash.c │ ├── makeemptyimg.sh │ ├── makesdcardimg.sh │ ├── mega65_config.inc │ ├── mega65_config.s │ ├── mega65_keyboardtest.a65 │ ├── megaflash │ │ ├── README.md │ │ ├── crc32accl.h │ │ ├── crc32accl.s │ │ ├── megaflash.c │ │ ├── megaflash.scr │ │ ├── mf_buffers.c │ │ ├── mf_buffers.h │ │ ├── mf_hlflash.c │ │ ├── mf_hlflash.h │ │ ├── mf_progress.c │ │ ├── mf_progress.h │ │ ├── mf_selectcore.c │ │ ├── mf_selectcore.h │ │ ├── mf_utility.c │ │ ├── mf_utility.h │ │ ├── mhexes.c │ │ ├── mhexes.h │ │ ├── mhx_bin2scr.h │ │ ├── mhx_bin2scr.s │ │ ├── nohysdc.c │ │ ├── nohysdc.h │ │ ├── qspibitbash.c │ │ ├── qspibitbash.h │ │ ├── qspiflash.c │ │ ├── qspiflash.h │ │ ├── qspihwassist.c │ │ ├── qspihwassist.h │ │ ├── s25flxxxl.c │ │ ├── s25flxxxl.h │ │ ├── s25flxxxs.c │ │ └── s25flxxxs.h │ ├── onboard.c │ ├── qspijoy.c │ ├── qspijoy.h │ ├── scope.a65 │ ├── sdbitbash.a65 │ ├── setsdcardinfo.sh │ ├── test01prg.a65 │ ├── tftpserver.a65 │ ├── util-core.cfg │ ├── util-std.cfg │ ├── vertical_rasters_test.a65 │ └── vfpgatest.a65 ├── verilog │ ├── 6502_alu.v │ ├── 6502_inc.vh │ ├── 6502_mux.v │ ├── 6502_reg.v │ ├── 6502_timing.v │ ├── 6502_top.v │ ├── 6502_ucode.v │ ├── UART_TX_CTRL.v │ ├── asym_ram_sdp.v │ ├── calc_phase_inc.v │ ├── calc_rhythm_phase.v │ ├── edge_detector.v │ ├── env_rate_counter.v │ ├── envelope_generator.v │ ├── hyper_xface.v │ ├── ksl_add_rom.v │ ├── monitor_bus.v │ ├── monitor_ctrl.v │ ├── monitor_top.v │ ├── operator.v │ ├── opl2.v │ ├── opl3.vh │ ├── opl3_exp_lut.v │ ├── opl3_log_sine_lut.v │ ├── phase_generator.v │ ├── sid_envelope.v │ ├── sid_voice_8580.v │ ├── syn_fifo.v │ ├── tremolo.v │ ├── uart_rx.v │ ├── uart_rx_buffered.v │ └── vibrato.v ├── version.sh └── vhdl │ ├── 74LS125.vhdl │ ├── 74LS165.vhdl │ ├── 74LS595.vhdl │ ├── TMDS_encoder.vhdl │ ├── Timebase.vhdl │ ├── UART_TX_CTRL.vhdl │ ├── accessible_keyboard.vhdl │ ├── asym_ram.vhdl │ ├── audio_clock.vhdl │ ├── audio_clock100.vhdl │ ├── audio_complex.vhdl │ ├── audio_mixer.vhdl │ ├── audio_out_test_tone.vhdl │ ├── aux_ecc1.vhdl │ ├── aux_ecc2.vhdl │ ├── aux_encoder.vhdl │ ├── bitplane.vhdl │ ├── bitplanes.vhdl │ ├── buffereduart.vhdl │ ├── c65uart.vhdl │ ├── cia1581.vhdl │ ├── cia6526.vhdl │ ├── clocking.vhdl │ ├── clocking50mhz.vhdl │ ├── conversions.vhdl │ ├── cpu_only.vhdl │ ├── cpu_test.vhdl │ ├── cputypes.vhdl │ ├── crc.vhdl │ ├── crc1581.vhdl │ ├── ddr_out_emard.vhdl │ ├── ddrwrapper.vhdl │ ├── debounce.vhdl │ ├── debugtools.vhdl │ ├── divider32.vhdl │ ├── dpram8x4096.vhdl │ ├── dpram8x8192.vhdl │ ├── driverom.vhdl │ ├── dummy_opl2.vhdl │ ├── dummy_uart_monitor.vhdl │ ├── dvid.vhdl │ ├── dvid_test.vhdl │ ├── dvienc_defs.vhdl │ ├── edid_i2c.vhdl │ ├── edvi_ucode.vhdl │ ├── eth_beacon_ram.vhdl │ ├── ethernet.vhdl │ ├── ethernet_miim.vhdl │ ├── expansion_port_controller.vhdl │ ├── fake_expansion_port.vhdl │ ├── fake_opl2.vhdl │ ├── fake_reconfig.vhdl │ ├── fake_sd.vhdl │ ├── fake_sdcard.vhdl │ ├── fakehyperram.vhdl │ ├── fast_divide.vhdl │ ├── floppy_read_compensator.vhdl │ ├── fpgatemp.vhdl │ ├── frame_generator.vhdl │ ├── frame_test.vhdl │ ├── framepacker.vhdl │ ├── gen_utils.vhdl │ ├── ghdl_8580_voice_stub.vhdl │ ├── ghdl_alpha_blend.vhdl │ ├── ghdl_bug.vhdl │ ├── ghdl_chipram8bit.vhdl │ ├── ghdl_farstack.vhdl │ ├── ghdl_fpgatemp.vhdl │ ├── ghdl_ram128x1k.vhdl │ ├── ghdl_ram18x2k.vhdl │ ├── ghdl_ram32x1024.vhdl │ ├── ghdl_ram32x1024_sync.vhdl │ ├── ghdl_ram36x1k.vhdl │ ├── ghdl_ram8x2048.vhdl │ ├── ghdl_ram8x4096.vhdl │ ├── ghdl_ram8x4096_sync.vhdl │ ├── ghdl_ram8x4096_sync_2cs.vhdl │ ├── ghdl_ram8x512.vhdl │ ├── ghdl_ram9x4k.vhdl │ ├── ghdl_screen_ram_buffer.vhdl │ ├── ghdl_videobuffer.vhdl │ ├── grove_i2c.vhdl │ ├── gs4510.vhdl │ ├── hdmi_i2c.vhdl │ ├── hdmi_spdif.vhdl │ ├── hdmi_test_r3.vhdl │ ├── hdmi_test_r3.xdc │ ├── hdmi_test_r4.vhdl │ ├── hdmi_test_r4.xdc │ ├── hdmi_tx_encoder.vhdl │ ├── hdmidebug.vhdl │ ├── hdmidebug.xdc │ ├── hyperram.vhdl │ ├── i2c_controller.vhdl │ ├── i2c_master.vhdl │ ├── i2c_slave.vhdl │ ├── i2c_wrapper.vhdl │ ├── i2s_clock.vhdl │ ├── i2s_clock_r3.vhdl │ ├── i2s_transceiver.vhdl │ ├── icape2.vhdl │ ├── icape2sim.vhdl │ ├── iec_serial.vhdl │ ├── infoframe_rom_800x600_60hz_40M_48k.vhdl │ ├── internal1541.vhdl │ ├── internal1581.vhdl │ ├── iomapper.vhdl │ ├── is42s16320f_model.vhdl │ ├── kb_matrix_ram.vhdl │ ├── keyboard_complex.vhdl │ ├── keyboard_to_matrix.vhdl │ ├── keyboard_to_matrix_wukong.vhdl │ ├── keymapper.vhdl │ ├── lcdtest.vhdl │ ├── lfsr16.vhdl │ ├── m6522.vhdl │ ├── machine.vhdl │ ├── machine_container.vhdl │ ├── matrix_to_ascii.vhdl │ ├── max10.vhdl │ ├── mega65kbd_to_matrix.vhdl │ ├── mega65r1.vhdl │ ├── mega65r1.xdc │ ├── mega65r2.vhdl │ ├── mega65r2.xdc │ ├── mega65r2_i2c.vhdl │ ├── mega65r3.vhdl │ ├── mega65r3.xdc │ ├── mega65r3_container.vhdl │ ├── mega65r3_i2c.vhdl │ ├── mega65r4.tcl │ ├── mega65r4.vhdl │ ├── mega65r4.xdc │ ├── mega65r4_i2c.vhdl │ ├── mega65r5.vhdl │ ├── mega65r5.xdc │ ├── mega65r5_board_i2c.vhdl │ ├── mega65r6.vhdl │ ├── megaphoner1.vhdl │ ├── megaphoner1.xdc │ ├── megaphoner2.vhdl │ ├── megaphoner4.vhdl │ ├── megaphoner4.xdc │ ├── megaphonetest.vhdl │ ├── megaphonetest.xdc │ ├── mfm_bits_to_bytes.vhdl │ ├── mfm_bits_to_gaps.vhdl │ ├── mfm_decoder.vhdl │ ├── mfm_deglitch.vhdl │ ├── mfm_gaps.vhdl │ ├── mfm_gaps_to_bits.vhdl │ ├── mfm_quantise_gaps.vhdl │ ├── mfm_test.vhdl │ ├── mk2_to_mk1.vhdl │ ├── mouse_input.vhdl │ ├── mp8869.vhdl │ ├── multiply32.vhdl │ ├── multisid.vhdl │ ├── my_bufg.vhdl │ ├── my_vcomponents.vhdl │ ├── neotrng.vhdl │ ├── nexys4.vhdl │ ├── nexys4.xdc │ ├── nexys4ddr-widget.vhdl │ ├── nexys4ddr-widget.xdc │ ├── nexys4ddr.vhdl │ ├── nexys4ddr.xdc │ ├── nexysvideo.vhdl │ ├── nexysvideo.xdc │ ├── nocpu.vhdl │ ├── pal_simulation.vhdl │ ├── pca9555.vhdl │ ├── pcm_clock.vhdl │ ├── pcm_to_pdm.vhdl │ ├── pcm_transceiver.vhdl │ ├── pdm_to_pcm.vhdl │ ├── pin_id.vhdl │ ├── pinprober.vhdl │ ├── pixel_driver.vhdl │ ├── pixel_fifo.vhdl │ ├── pixeltest.vhdl │ ├── pixeltest.xdc │ ├── ps2_to_matrix.vhdl │ ├── ps2_to_uart.vhdl │ ├── qm200t.vhdl │ ├── qm200t.xdc │ ├── qmtech-a200t.vhdl │ ├── qmtech-a200t.xdc │ ├── qmtech-k325t.vhdl │ ├── qmtech-k325t.xdc │ ├── r3_expansion.vhdl │ ├── rain.vhdl │ ├── ram32x1024.vhdl │ ├── ramlatch64.vhdl │ ├── raw_bits_to_gaps.vhdl │ ├── reconfig.vhdl │ ├── rll27_bits_to_gaps.vhdl │ ├── rll27_gaps_to_bits.vhdl │ ├── rll27_quantise_gaps.vhdl │ ├── s27kl0641.vhdl │ ├── sc_cell_calc.vhdl │ ├── sdcard.vhdl │ ├── sdcardio.vhdl │ ├── sdram.vhdl │ ├── sdram_controller.vhdl │ ├── serialiser_10to1_selectio.vhdl │ ├── shifter32.vhdl │ ├── sid_6581.vhdl │ ├── sid_coeffs.vhdl │ ├── sid_coeffs_mux.vhdl │ ├── sid_components.vhdl │ ├── sid_filters.vhdl │ ├── sid_tables.vhdl │ ├── sid_voice.vhdl │ ├── sim_exp_board_rings.vhdl │ ├── simple_cpu6502.vhdl │ ├── slewtest.vhdl │ ├── slewtest.xdc │ ├── slow_devices.vhdl │ ├── slowram.vhdl │ ├── soundSource.vhdl │ ├── spdif_encoder.vhdl │ ├── sprite.vhdl │ ├── tb_iec_serial.vhdl │ ├── tb_iec_serial_1581.vhdl │ ├── tb_mega65kbd_to_matrix.vhdl │ ├── tb_pixel_driver.vhdl │ ├── tb_r5_i2c.vhdl │ ├── tb_sdram.vhdl │ ├── te0725.vhdl │ ├── te0725.xdc │ ├── test_ascii.vhdl │ ├── test_buffereduart.vhdl │ ├── test_ethernet.vhdl │ ├── test_framepacker.vhdl │ ├── test_grove.vhdl │ ├── test_hyperram.vhdl │ ├── test_hyperram16.vhdl │ ├── test_i2c.vhdl │ ├── test_kv.vhdl │ ├── test_matrix.vhdl │ ├── test_mfm.vhdl │ ├── test_miim.vhdl │ ├── test_osk.vhdl │ ├── test_pdm.vhdl │ ├── test_qspi.vhdl │ ├── test_readcomp.vhdl │ ├── test_rxbuff.vhdl │ ├── test_sc.vhdl │ ├── test_sprite.vhdl │ ├── testdiv.vhdl │ ├── testkey.vhdl │ ├── testr2.vhdl │ ├── testr2.xdc │ ├── touch.vhdl │ ├── touch_test.vhdl │ ├── types_pkg.vhdl │ ├── uart_charrom.vhdl │ ├── uart_rx.vhdl │ ├── uart_rx_buffered.vhdl │ ├── upscaler.vhdl │ ├── upscaler_ram32x1024.vhdl │ ├── utils_pkg.vhdl │ ├── vfpga │ ├── DMA_data_in.hex │ ├── DMA_data_out.hex │ ├── app_bitstream.hex │ ├── app_init_snapshot.hex │ ├── overlay_IP.vhdl │ ├── vfpga_clock_controller_pausable.vhdl │ └── vfpga_wrapper_8bit.vhdl │ ├── vga_hdmi.vhdl │ ├── vga_to_hdmi.vhdl │ ├── vicii_sprites.vhdl │ ├── viciv.vhdl │ ├── victypes.vhdl │ ├── video_frame.vhdl │ ├── virtual_to_matrix.vhdl │ ├── visual_keyboard.vhdl │ ├── wdc1772.vhdl │ ├── widget_to_matrix.vhdl │ ├── wukong.vhdl │ └── wukong.xdc ├── test-iec-c128.py ├── test-iec-jd.py ├── test-iec.py ├── test.py ├── test_r5_i2c.py ├── testprocedure_in.tex ├── tests ├── dc_offset.py ├── dc_offset.vhdl ├── debugtools.vhdl ├── hardware_divider.py ├── hardware_divider.vhdl └── setup_vunit ├── vivado ├── hdmi_test_r3_gen.tcl ├── hdmi_test_r3_impl.tcl ├── hdmi_test_r4_gen.tcl ├── hdmi_test_r4_impl.tcl ├── hdmidebug_gen.tcl ├── hdmidebug_impl.tcl ├── m65debug_gen.tcl ├── m65debug_impl.tcl ├── mega65r1_gen.tcl ├── mega65r1_impl.tcl ├── mega65r2_gen.tcl ├── mega65r2_impl.tcl ├── mega65r3_container_gen.tcl ├── mega65r3_container_impl.tcl ├── mega65r3_gen.tcl ├── mega65r3_impl.tcl ├── mega65r4_gen.tcl ├── mega65r4_impl.tcl ├── mega65r5_gen.tcl ├── mega65r5_impl.tcl ├── mega65r6_gen.tcl ├── mega65r6_impl.tcl ├── megaphoner1_gen.tcl ├── megaphoner1_impl.tcl ├── megaphoner4_gen.tcl ├── megaphoner4_impl.tcl ├── megaphonetest_gen.tcl ├── megaphonetest_impl.tcl ├── nexys4_gen.tcl ├── nexys4_impl.tcl ├── nexys4ddr-widget_gen.tcl ├── nexys4ddr-widget_impl.tcl ├── nexys4ddr_gen.tcl ├── nexys4ddr_impl.tcl ├── nexysvideo_gen.tcl ├── nexysvideo_impl.tcl ├── nocpu_gen.tcl ├── nocpu_impl.tcl ├── pixeltest_gen.tcl ├── pixeltest_impl.tcl ├── qm200t_gen.tcl ├── qm200t_impl.tcl ├── qmtech-a200t_gen.tcl ├── qmtech-a200t_impl.tcl ├── qmtech-k325t_gen.tcl ├── qmtech-k325t_impl.tcl ├── run_mcs.tcl ├── slewtest_gen.tcl ├── slewtest_impl.tcl ├── te0725_gen.tcl ├── te0725_impl.tcl ├── testr2_gen.tcl ├── testr2_impl.tcl ├── wukong_gen.tcl └── wukong_impl.tcl ├── vivado_check ├── vivado_timing ├── vivado_wrapper └── watch-m65 /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: Webkit 4 | ColumnLimit: 125 5 | IndentWidth: 2 6 | AlignTrailingComments: true 7 | BreakBeforeBraces: Stroustrup 8 | SortIncludes: false 9 | BreakBeforeBinaryOperators: All 10 | BreakBeforeTernaryOperators: true 11 | PenaltyBreakAssignment: 100 12 | PenaltyBreakComment: 100 13 | AlignOperands: AlignAfterOperator 14 | AllowShortFunctionsOnASingleLine: None 15 | PointerAlignment: Right 16 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: new 6 | type: Bug 7 | assignees: '' 8 | 9 | --- 10 | 11 | **Test Environment (required)** 12 | You can use MEGAINFO from within FREEZER to obtain this information 13 | (long press RESTORE to enter FREEZER, then press HELP to start MEGAINFO) 14 | - Platform: (DevKit, MEGA65R3, MEGA65R6, NexysA7, xemu, etc.) 15 | - Core Commit: (7 digit hex number, press MEGA-TAB) 16 | - ROM Release: (i.e. 920XXX) 17 | 18 | **Describe the bug** 19 | A clear and concise description of what the bug is. 20 | 21 | **To Reproduce** 22 | Steps to reproduce the behavior: 23 | 1. Go to '...' 24 | 2. Click on '....' 25 | 3. Scroll down to '....' 26 | 4. See error 27 | 28 | **Expected behavior** 29 | A clear and concise description of what you expected to happen. 30 | 31 | **Screenshots** 32 | If applicable, add screenshots to help explain your problem. 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: new 6 | type: Feature 7 | assignees: '' 8 | 9 | --- 10 | 11 | **Is your feature request related to a problem? Please describe.** 12 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 13 | 14 | **Describe the solution you'd like** 15 | A clear and concise description of what you want to happen. 16 | 17 | **Describe alternatives you've considered** 18 | A clear and concise description of any alternative solutions or features you've considered. 19 | 20 | **Additional context** 21 | Add any other context or screenshots about the feature request here. 22 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "cc65"] 2 | path = cc65 3 | url = https://github.com/cc65/cc65.git 4 | ignore = dirty 5 | [submodule "cbmconvert"] 6 | path = cbmconvert 7 | url = https://github.com/sasq64/cbmconvert.git 8 | ignore = dirty 9 | [submodule "Ophis"] 10 | path = Ophis 11 | url = https://github.com/gardners/Ophis.git 12 | ignore = dirty 13 | [submodule "src/mega65-fdisk"] 14 | path = src/mega65-fdisk 15 | url = https://github.com/MEGA65/mega65-fdisk.git 16 | ignore = dirty 17 | [submodule "iverilog"] 18 | path = iverilog 19 | url = https://github.com/steveicarus/iverilog.git 20 | ignore = dirty 21 | [submodule "ghdl"] 22 | path = ghdl 23 | url = https://github.com/ghdl/ghdl.git 24 | ignore = dirty 25 | [submodule "src/mega65-freezemenu"] 26 | path = src/mega65-freezemenu 27 | url = https://github.com/MEGA65/mega65-freezemenu.git 28 | ignore = dirty 29 | [submodule "open-roms"] 30 | path = src/open-roms 31 | url = https://github.com/MEGA65/open-roms.git 32 | ignore = dirty 33 | [submodule "src/mega65-libc"] 34 | path = src/mega65-libc 35 | url = https://github.com/MEGA65/mega65-libc.git 36 | ignore = dirty 37 | [submodule "src/tools/acme"] 38 | path = src/tools/acme 39 | url = https://github.com/MEGA65/acme.git 40 | ignore = dirty 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MEGA65 = Enhanced C65 running in FPGA. 2 | 3 | Refer to "[./docs/index.md](./docs/index.md)" for the index file of the main DOC documentation. 4 | This documentation is best viewed using the github web-interface at: 5 | https://github.com/MEGA65/mega65-core/blob/master/README.md 6 | 7 | You will optionally need the a MEGA65 ROM file, if you wish to use BASIC65: 8 | https://files.mega65.org?id=54e69439-f25e-4124-8c78-22ea7ddc0f1c 9 | 10 | If you do not have such a file, the MEGA65 contains the free and open-source 11 | OpenROM alternative. 12 | 13 | # Automated Build Server 14 | 15 | The MEGA65 project maintains an automated build server at https://builder.mega65.org/ 16 | 17 | -------------------------------------------------------------------------------- /TRADEMARKS.md: -------------------------------------------------------------------------------- 1 | The MEGA65 BIOS/Hypervisor was called KICKSTART. 2 | We believe that this does not infringe on any 3 | existing trademarks. Our reasoning being as follows: 4 | 5 | KICKSTART lapsed as a trademark on computers in 6 | Australia on 17 July 1990 (Trademark 478242). 7 | 8 | A search for KICKSTART in the US Trademark register 9 | revealed no registered trademark for KICKSTART with 10 | relation to Commodore(tm) or Amiga(tm) computers. 11 | 12 | However, in an abundance of caution, and without 13 | conceding that any trademark rights might still 14 | exist, we are instead calling it HYPPO or HYPPOBOOT, 15 | depending on the context. 16 | -------------------------------------------------------------------------------- /assets/8x8font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/assets/8x8font.png -------------------------------------------------------------------------------- /assets/alphatest.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/assets/alphatest.bin -------------------------------------------------------------------------------- /assets/ascii00-7f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/assets/ascii00-7f.png -------------------------------------------------------------------------------- /assets/game/blackness.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/assets/game/blackness.gif -------------------------------------------------------------------------------- /assets/game/bomb.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/assets/game/bomb.gif -------------------------------------------------------------------------------- /assets/game/dark.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/assets/game/dark.gif -------------------------------------------------------------------------------- /assets/game/hammer.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/assets/game/hammer.gif -------------------------------------------------------------------------------- /assets/game/posion.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/assets/game/posion.gif -------------------------------------------------------------------------------- /assets/game/shadow.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/assets/game/shadow.gif -------------------------------------------------------------------------------- /assets/game/soldier.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/assets/game/soldier.gif -------------------------------------------------------------------------------- /assets/game/turret.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/assets/game/turret.gif -------------------------------------------------------------------------------- /assets/matrix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/assets/matrix.png -------------------------------------------------------------------------------- /assets/matrix_banner.txt: -------------------------------------------------------------------------------- 1 | *** MEGA65 Memory/Machine Inspection Interface *** 2 | GIT commit: GITCOMMITID 3 | F1/F3/UP/DOWN - View Memory, F7 - Wipe all memory 4 | ACCEPT - Accept entry/exit of secure compartment 5 | REJECT - Wipe secure compartment before exiting. 6 | -------------------------------------------------------------------------------- /assets/mega65_320x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/assets/mega65_320x64.png -------------------------------------------------------------------------------- /assets/synthesised-60ns.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/assets/synthesised-60ns.dat -------------------------------------------------------------------------------- /assets/track2-40ns.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/assets/track2-40ns.dat -------------------------------------------------------------------------------- /assets/vfpga-bitstream.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/assets/vfpga-bitstream.bin -------------------------------------------------------------------------------- /bin/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/bin/.gitkeep -------------------------------------------------------------------------------- /d81-files/benchscores.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/d81-files/benchscores.prg -------------------------------------------------------------------------------- /d81-files/raster65.mega.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/d81-files/raster65.mega.prg -------------------------------------------------------------------------------- /docs/howtoedit.md: -------------------------------------------------------------------------------- 1 | ## This is the 'how to edit documentation' documentation file. 2 | 3 | # Introduction 4 | We have decided to try and use the github '*.md' pages to document the design. 5 | The intention is to have the documentation in one place, close to the source, and always reflect the current build status. 6 | 7 | # What to document 8 | Everything. 9 | At this stage we want to draw a line in the sand and document everything we know about the project. This includes: 10 | 11 | 1. how-to guides 12 | 1. how software is developed 13 | 1. how hardware is connected 14 | 1. how to use/develop 15 | 1. etc 16 | 17 | # How to document 18 | 19 | 1. git uses the markdown language, some online pages describing the format can be found here: 20 | https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/ 21 | https://guides.github.com/features/mastering-markdown/ 22 | 1. a suggested workflow for modifying/adding pages is: 23 | 1. clone the repo, 24 | 1. edit the .md file, 25 | 1. view the rendered page in your browser using 'grip' (see below), 26 | 1. re-edit the .md file, 27 | 1. re-view the rendered page (and loop 4-5 until it looks nice), 28 | 1. commit the file locally and push to the repo. 29 | 30 | 1. grip can be found here: 31 | https://github.com/joeyespo/grip 32 | 1. install the python-installer ```sudo apt-get install python-pip``` 33 | 1. clone the repo ```git clone https://github.com/joeyespo/grip``` 34 | 1. cd into the base dir ```cd grip``` 35 | 1. install grip ```sudo python setup.py install``` 36 | 37 | 38 | 39 | 1. grip can now be run from your working directory 40 | 1. navigate to working directory ```cd /mega65-core/doc``` 41 | 1. start grip rendering pages ```grip index.md &``` 42 | 1. in browser, goto [http://localhost:6419/](http://localhost:6419/) where grip is rendering the index.md file 43 | 1. to stop grip ```killall grip``` 44 | 45 | [User Manual](./usermanual0.md) - 46 | 47 | The End. 48 | -------------------------------------------------------------------------------- /docs/images/container-small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/docs/images/container-small.jpg -------------------------------------------------------------------------------- /docs/images/container.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/docs/images/container.jpg -------------------------------------------------------------------------------- /docs/images/container.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/docs/images/container.pdf -------------------------------------------------------------------------------- /docs/images/iomapper-small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/docs/images/iomapper-small.jpg -------------------------------------------------------------------------------- /docs/images/iomapper.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/docs/images/iomapper.jpg -------------------------------------------------------------------------------- /docs/images/iomapper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/docs/images/iomapper.pdf -------------------------------------------------------------------------------- /docs/images/machine-small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/docs/images/machine-small.jpg -------------------------------------------------------------------------------- /docs/images/machine.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/docs/images/machine.jpg -------------------------------------------------------------------------------- /docs/images/machine.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/docs/images/machine.pdf -------------------------------------------------------------------------------- /docs/images/monitor-small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/docs/images/monitor-small.jpg -------------------------------------------------------------------------------- /docs/images/monitor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/docs/images/monitor.jpg -------------------------------------------------------------------------------- /docs/images/monitor.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/docs/images/monitor.pdf -------------------------------------------------------------------------------- /docs/images/precomp-small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/docs/images/precomp-small.jpg -------------------------------------------------------------------------------- /docs/images/precomp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/docs/images/precomp.jpg -------------------------------------------------------------------------------- /docs/images/precomp.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/docs/images/precomp.pdf -------------------------------------------------------------------------------- /docs/secure_mode.md: -------------------------------------------------------------------------------- 1 | Secure mode disables all IO, except $D6Bx (touch pad) and $D6F0-E (audio), 2 | the SIDs and the VIC-IV. This is enabled by setting bit 7 of the protected 3 | hardware register. 4 | 5 | The CPU sets the two upper bits in protected_hardware ($D672), which is 6 | detected by the monitor (in software in the embedded 65C02 that runs the 7 | monitor). The Hypervisor should infinite loop while waiting for this to happen. 8 | 9 | *** We should modify the CPU to stop itself at this point. 10 | 11 | The monitor then asks the user to ACCEPT or REJECT the transition. If the 12 | user accepts, then the monitor should resume the CPU, and the CPU should be placed 13 | into user mode, instead of hypervisor mode, presumably by having the monitor 14 | synthesising a write to $D67F to exit hypervisor mode. 15 | 16 | *** Better is have the monitor provide the CPU a flag that indicates whether it 17 | should be in a secure compartment or not. If that signal is wrong, then the CPU 18 | stops. When the flags match, this allows the hypervisor to resume the entry 19 | routine, which causes the hypervisor to exit to user land with the loaded 20 | secure service running. 21 | 22 | At this point, the secure compartment is running, and ANY hypervisor trap should 23 | instead cause the monitor to reactivate in secure mode colours, and allow the 24 | user to accept or reject. 25 | 26 | *** We should modify the CPU to stop itself at this point. 27 | 28 | The user then types ACCEPT or REJECT in the monitor. If REJECT was typed, the 29 | monitor erases all of memory before allowing the CPU to continue. 30 | 31 | -------------------------------------------------------------------------------- /docs/test.md: -------------------------------------------------------------------------------- 1 | ## This is the 'test' documentation file. 2 | 3 | # Table of Contents: 4 | 5 | [Introduction](#introduction) 6 | [Test Procedure](#test-procedure) 7 | 8 | 9 | ## Introduction 10 | 11 | This document describes a number of tests that can be performed to verify that the design works as it should. 12 | 13 | Within each test procedure, the tests are denoted as bullet-points, followed by some text describing what to do. 14 | Results are denoted as "-> something", where something is the expected result. 15 | 16 | A description of the hardware is shown below: 17 | ![alt tag](https://raw.githubusercontent.com/Ben-401/mega65pics/master/board.jpg) 18 | The above image shows: 19 | * Nexys4DDR development board, 20 | * VGA port connected to a vga monitor capable of 800x600 @ 50Hz and 60Hz 21 | * USB port connected to a simple USB keyboard, 22 | * PROG/UART port connected to host-PC, for two reasons: 23 | * to provide power to the Nexys board, and 24 | * to allow serial comms between Nexys and host-PC. 25 | The host-PC should have the m65dbg running or a suitable serial-port program. I use picocom. 26 | * SDMICRO port has a SDcard inserted, SDcard should contain the following files at a minimum: 27 | * ``bit03141732_dev..._1541f08~.bit (or similar)`` 28 | ``BOOTLOGO.M65 (optional)`` 29 | ``CHARROM.M65`` 30 | ``MEGA65.D81`` 31 | ``MEGA65.ROM`` 32 | * FPGA-Switches (SW-x) all in their OFF position, which is DOWN, if using a Nexys4 or Nexys4DDR development board. 33 | 34 | ## Test Procedure 35 | 36 | All tests, unless otherwise noted, begin with the hardware as described above in the "Introduction" section above. 37 | 38 | For the individual tests, please see below. 39 | * [Power and BOOT-up](./test-powerandbootup.md) - applies power and describes what should happen when the buttons/switches are manipulated. 40 | * [c65 mode](./test-c65mode.md) - navigates around the c65 environment exploring its features. 41 | 42 | 43 | The End. 44 | -------------------------------------------------------------------------------- /docs/viciv-modes-16-bit-charmode-1.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/docs/viciv-modes-16-bit-charmode-1.prg -------------------------------------------------------------------------------- /i2c_slave/license.txt: -------------------------------------------------------------------------------- 1 | I2C Slave VHDL project 2 | Copyright (c) 2006 Frank Buss (fb@frank-buss.de) 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the .Software.), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED .AS IS., WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /megaphone-write-flash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/csh -f 2 | 3 | if ( x"$1" == "x" ) then 4 | echo "usage: $0 " 5 | exit 0 6 | endif 7 | 8 | echo sed -e 's,THEMCSFILE,'"$1"',g' 9 | sed -e 's,THEMCSFILE,'"$1"',g' < megaphone-write-flash.tcl > temp.tcl 10 | /opt/Xilinx/Vivado/2019.2/bin/vivado -mode batch -nojournal -nolog -notrace -source temp.tcl 11 | -------------------------------------------------------------------------------- /megaphone-write-flash.tcl: -------------------------------------------------------------------------------- 1 | open_hw 2 | connect_hw_server 3 | open_hw_target 4 | create_hw_cfgmem -hw_device [lindex [get_hw_devices xc7a100t_0] 0] [lindex [get_cfgmem_parts {s25fl256sxxxxxx0-spi-x1_x2_x4}] 0] 5 | set_property PROGRAM.BLANK_CHECK 0 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 6 | set_property PROGRAM.ERASE 1 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 7 | set_property PROGRAM.CFG_PROGRAM 1 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 8 | set_property PROGRAM.VERIFY 1 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 9 | set_property PROGRAM.CHECKSUM 0 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 10 | refresh_hw_device [lindex [get_hw_devices xc7a100t_0] 0] 11 | set_property PROGRAM.ADDRESS_RANGE {use_file} [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 12 | set_property PROGRAM.FILES [list "THEMCSFILE" ] [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 13 | set_property PROGRAM.PRM_FILE {} [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 14 | set_property PROGRAM.UNUSED_PIN_TERMINATION {pull-none} [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 15 | set_property PROGRAM.BLANK_CHECK 0 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 16 | set_property PROGRAM.ERASE 1 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 17 | set_property PROGRAM.CFG_PROGRAM 1 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 18 | set_property PROGRAM.VERIFY 1 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 19 | set_property PROGRAM.CHECKSUM 0 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 20 | startgroup 21 | if {![string equal [get_property PROGRAM.HW_CFGMEM_TYPE [lindex [get_hw_devices xc7a100t_0] 0]] [get_property MEM_TYPE [get_property CFGMEM_PART [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]]]]] } { create_hw_bitstream -hw_device [lindex [get_hw_devices xc7a100t_0] 0] [get_property PROGRAM.HW_CFGMEM_BITFILE [ lindex [get_hw_devices xc7a100t_0] 0]]; program_hw_devices [lindex [get_hw_devices xc7a100t_0] 0]; }; 22 | program_hw_cfgmem -hw_cfgmem [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 23 | endgroup 24 | quit 25 | -------------------------------------------------------------------------------- /nexys4ddr-write-flash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/csh -f 2 | 3 | if ( x"$1" == "x" ) then 4 | echo "usage: $0 " 5 | exit 0 6 | endif 7 | 8 | echo sed -e 's,THEMCSFILE,'"$1"',g' 9 | sed -e 's,THEMCSFILE,'"$1"',g' < nexys4ddr-write-flash.tcl > temp.tcl 10 | /opt/Xilinx/Vivado/2019.2/bin/vivado -mode batch -nojournal -nolog -notrace -source temp.tcl 11 | -------------------------------------------------------------------------------- /nexys4ddr-write-flash.tcl: -------------------------------------------------------------------------------- 1 | open_hw_manager 2 | connect_hw_server 3 | open_hw_target 4 | create_hw_cfgmem -hw_device [lindex [get_hw_devices xc7a100t_0] 0] [lindex [get_cfgmem_parts {s25fl128sxxxxxx0-spi-x1_x2_x4}] 0] 5 | set_property PROGRAM.BLANK_CHECK 0 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 6 | set_property PROGRAM.ERASE 1 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 7 | set_property PROGRAM.CFG_PROGRAM 1 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 8 | set_property PROGRAM.VERIFY 1 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 9 | set_property PROGRAM.CHECKSUM 0 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 10 | refresh_hw_device [lindex [get_hw_devices xc7a100t_0] 0] 11 | set_property PROGRAM.ADDRESS_RANGE {use_file} [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 12 | set_property PROGRAM.FILES [list "THEMCSFILE" ] [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 13 | set_property PROGRAM.PRM_FILE {} [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 14 | set_property PROGRAM.UNUSED_PIN_TERMINATION {pull-none} [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 15 | set_property PROGRAM.BLANK_CHECK 0 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 16 | set_property PROGRAM.ERASE 1 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 17 | set_property PROGRAM.CFG_PROGRAM 1 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 18 | set_property PROGRAM.VERIFY 1 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 19 | set_property PROGRAM.CHECKSUM 0 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 20 | startgroup 21 | if {![string equal [get_property PROGRAM.HW_CFGMEM_TYPE [lindex [get_hw_devices xc7a100t_0] 0]] [get_property MEM_TYPE [get_property CFGMEM_PART [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]]]]] } { create_hw_bitstream -hw_device [lindex [get_hw_devices xc7a100t_0] 0] [get_property PROGRAM.HW_CFGMEM_BITFILE [ lindex [get_hw_devices xc7a100t_0] 0]]; program_hw_devices [lindex [get_hw_devices xc7a100t_0] 0]; }; 22 | program_hw_cfgmem -hw_cfgmem [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a100t_0] 0]] 23 | endgroup 24 | quit 25 | -------------------------------------------------------------------------------- /record-m65: -------------------------------------------------------------------------------- 1 | if [ "x$1" == "x" ]; then 2 | echo "usage: record-m65 " 3 | echo "" 4 | echo "NOTE: You must first enable the ethernet video stream on the MEGA65" 5 | echo " sffd36e1 29 from the serial monitor interface will do this." 6 | exit 7 | fi 8 | make bin/videoproxy bin/vncserver 9 | pkill vncserver 10 | sudo echo 11 | sudo ifconfig $1 mtu 9000 12 | sudo bin/videoproxy $1 & 13 | sleep 1 14 | bin/vncserver & 15 | sleep 1 16 | vncviewer localhost & 17 | sleep 2 18 | xwininfo -name "VNC: MEGA65 Remote Display" 19 | x1=`xwininfo -name "VNC: MEGA65 Remote Display" | grep "Absolute upper-left X:" | cut -f2 -d: | sed s'/ //g'` 20 | y1=`xwininfo -name "VNC: MEGA65 Remote Display" | grep "Absolute upper-left Y:" | cut -f2 -d: | sed s'/ //g'` 21 | wmctrl -a "VNC: MEGA65 Remote Display" 22 | rm output.mp4 23 | echo ffmpeg -video_size 800x600 -framerate 50 -f x11grab -show_region 1 -i :0.0+${x1},${y1} output.mp4 24 | ffmpeg -video_size 800x600 -framerate 50 -f x11grab -show_region 1 -i :0.0+${x1},${y1} output.mp4 25 | pkill vncserver 26 | -------------------------------------------------------------------------------- /release-build/README-dev.md: -------------------------------------------------------------------------------- 1 | 2 | # MEGA65 Core Release 0.95 Release Candidate 3 | 4 | Target system: ${RM_TARGET} 5 | 6 | **WARNING:** This is an **unstable** and **experimental** test core. Please watch 7 | for files starting with `WARNING` in the archive and read the logs if you want to 8 | know the test results. 9 | 10 | **NOTE:** The `#UNSAFE` tag in the version and the `ATTENTION_THIS_COULD_BRICK_YOUR_MEGA65` 11 | warning file in the archive refers to the possibility that a untested core *might* 12 | have a temporary negative effect on your system. But using a JTAG interface you 13 | are always able to restore your system to a working state. 14 | 15 | ## Contents 16 | 17 | - `*.bit`: bistream file for use with the JTAG adapter (direct transfer to FPGA) 18 | - `*.cor`: MEGA COR file for flashing with the MEGA65 Flasher 19 | - `*.mcs`: Vivado Format for flashing via JTAG using Vivado 20 | - `sdcard-files`: all the basic files needed to add to your boot SD card 21 | - `extra`: contains files you normally don't need, like `HICKUP.M65`. Note: you **don't** need this! 22 | - `log`: regression test logs 23 | 24 | ## How to use a core 25 | 26 | There is an extensive 27 | [How to load or flash a core tutorial](https://files.mega65.org?ar=280a57a6-fb84-40fc-96ac-6da603302aa7) 28 | on filehost. 29 | 30 | ## How to use the SD card files 31 | 32 | There is a 33 | [How to prepare your SD card](https://files.mega65.org?ar=bf23ac42-5786-48f7-a117-4e6f81edd802) 34 | tutorial on filehost. Please follow this tutorial to prepare your SD card. 35 | 36 | Again: **don't** use `HICKUP.M65`! 37 | 38 | You will also need a ROM for your disk. Either get a 39 | [Closed ROM](https://files.mega65.org?id=54e69439-f25e-4124-8c78-22ea7ddc0f1c) or 40 | patch your own, if you don't have access, by using a 41 | [ROM diff file](https://files.mega65.org?id=fd2c40b9-f337-41f7-8a81-0254b1e09fb5). 42 | -------------------------------------------------------------------------------- /release-build/README.md: -------------------------------------------------------------------------------- 1 | 2 | # MEGA65 Core Release 0.95 3 | 4 | Target system: ${RM_TARGET} 5 | 6 | ## Contents 7 | 8 | - `*.bit`: bistream file for use with the JTAG adapter (direct transfer to FPGA) 9 | - `*.cor`: MEGA COR file for flashing with the MEGA65 Flasher 10 | - `*.mcs`: Vivado Format for flashing via JTAG using Vivado 11 | - `sdcard-files`: all the basic files needed to add to your boot SD card 12 | - `extra`: contains files you normally don't need, like `HICKUP.M65`. Note: you **don't** need this! 13 | - `log`: regression test logs 14 | 15 | ## How to use a core 16 | 17 | There is an extensive 18 | [How to load or flash a core tutorial](https://files.mega65.org?ar=280a57a6-fb84-40fc-96ac-6da603302aa7) 19 | on filehost. 20 | 21 | ## How to use the SD card files 22 | 23 | There is a 24 | [How to prepare your SD card](https://files.mega65.org?ar=bf23ac42-5786-48f7-a117-4e6f81edd802) 25 | tutorial on filehost. Please follow this tutorial to prepare your SD card. 26 | 27 | Again: **don't** use `HICKUP.M65`! 28 | 29 | You will also need a ROM for your disk. Either get a 30 | [Closed ROM](https://files.mega65.org?id=54e69439-f25e-4124-8c78-22ea7ddc0f1c) or 31 | patch your own, if you don't have access, by using a 32 | [ROM diff file](https://files.mega65.org?id=fd2c40b9-f337-41f7-8a81-0254b1e09fb5). 33 | ${RM_HASROM} 34 | ## Known Problems 35 | 36 | - The FREEZER does support mounting of D64, but ROM 920377 has no working support for it 37 | - OpenROM only runs in PAL mode, see [core#362](https://github.com/MEGA65/mega65-core/issues/362) 38 | -------------------------------------------------------------------------------- /release-build/prepare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT="$(readlink --canonicalize-existing "$0")" 4 | SCRIPTPATH="$(dirname "${SCRIPT}")" 5 | SCRIPTNAME=${SCRIPT##*/} 6 | 7 | cd ${SCRIPTPATH} 8 | 9 | if [[ $1 = "prunepkg" ]]; then 10 | rm -rf pkg 11 | fi 12 | 13 | # freshly clone release prep 14 | #echo "Removing and recloning mega65-release-prep..." 15 | #rm -rf mega65-release-prep 16 | #git clone https://github.com/MEGA65/mega65-release-prep.git || ( echo "failed to clone mega65-release-prep"; exit 1 ) 17 | 18 | # freshly clone tools 19 | echo 20 | echo "Removing and recloning mega65-tools..." 21 | rm -rf mega65-tools 22 | git clone --depth 1 --branch release-1.00 https://github.com/MEGA65/mega65-tools.git || ( echo "failed to clone mega65-tools"; exit 2 ) 23 | 24 | echo 25 | echo "Building tools..." 26 | cd mega65-tools 27 | make DO_SMU=1 USE_LOCAL_CC65=1 bin/m65 bin/coretool tests || ( echo "failed to build mega65-tools"; exit 3) 28 | -------------------------------------------------------------------------------- /spdif_out/spdf_out.vhd: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------------- 2 | -- Engineer: Mike Field 3 | -- 4 | -- Module Name: spdf_out - Behavioral 5 | -- Description: 6 | -- 7 | -- Top level module fot the S/PDIF output module 8 | -- 9 | ---------------------------------------------------------------------------------- 10 | library IEEE; 11 | use IEEE.STD_LOGIC_1164.ALL; 12 | 13 | entity spdf_out is 14 | Port ( clk : in STD_LOGIC; 15 | spdif_out : out STD_LOGIC); 16 | end spdf_out; 17 | 18 | architecture Behavioral of spdf_out is 19 | 20 | COMPONENT soundSource 21 | PORT( 22 | Clk : IN std_logic; 23 | nextSample : IN std_logic; 24 | channelA : IN std_logic; 25 | Sample : OUT std_logic_vector(19 downto 0) 26 | ); 27 | END COMPONENT; 28 | 29 | 30 | COMPONENT serialiser 31 | PORT( 32 | clk100m : IN std_logic; 33 | auxAudioBits : IN std_logic_vector(3 downto 0); 34 | sample : IN std_logic_vector(19 downto 0); 35 | nextSample : OUT std_logic; 36 | channelA : OUT std_logic; 37 | spdifOut : OUT std_logic 38 | ); 39 | END COMPONENT; 40 | 41 | signal nextSample : std_logic; 42 | signal channelA : std_logic; 43 | signal sample : std_logic_vector(19 downto 0); 44 | begin 45 | 46 | Inst_soundSource: soundSource PORT MAP( 47 | Clk => clk, 48 | nextSample => nextSample, 49 | channelA => channelA, 50 | Sample => sample 51 | ); 52 | 53 | Inst_serialiser: serialiser PORT MAP( 54 | clk100M => clk, 55 | auxAudioBits => "0000", 56 | sample => sample, 57 | nextSample => nextSample, 58 | channelA => channelA, 59 | spdifOut => spdif_out 60 | ); 61 | 62 | end Behavioral; 63 | -------------------------------------------------------------------------------- /spdif_out/tb_spdif_out.vhd: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- Company: 3 | -- Engineer: 4 | -- 5 | -- Create Date: 22:35:20 07/07/2011 6 | -- Design Name: 7 | -- Module Name: C:/Users/Hamster/Projects/FPGA/spdif_out/tb_spdif_out.vhd 8 | -- Project Name: spdif_out 9 | -- Target Device: 10 | -- Tool versions: 11 | -- Description: 12 | -- 13 | -- VHDL Test Bench Created by ISE for module: spdf_out 14 | -- 15 | -- Dependencies: 16 | -- 17 | -- Revision: 18 | -- Revision 0.01 - File Created 19 | -- Additional Comments: 20 | -- 21 | -- Notes: 22 | -- This testbench has been automatically generated using types std_logic and 23 | -- std_logic_vector for the ports of the unit under test. Xilinx recommends 24 | -- that these types always be used for the top-level I/O of a design in order 25 | -- to guarantee that the testbench will bind correctly to the post-implementation 26 | -- simulation model. 27 | -------------------------------------------------------------------------------- 28 | LIBRARY ieee; 29 | USE ieee.std_logic_1164.ALL; 30 | 31 | -- Uncomment the following library declaration if using 32 | -- arithmetic functions with Signed or Unsigned values 33 | --USE ieee.numeric_std.ALL; 34 | 35 | ENTITY tb_spdif_out IS 36 | END tb_spdif_out; 37 | 38 | ARCHITECTURE behavior OF tb_spdif_out IS 39 | 40 | -- Component Declaration for the Unit Under Test (UUT) 41 | 42 | COMPONENT spdf_out 43 | PORT( 44 | clk : IN std_logic; 45 | spdif_out : OUT std_logic 46 | ); 47 | END COMPONENT; 48 | 49 | 50 | --Inputs 51 | signal clk : std_logic := '0'; 52 | 53 | --Outputs 54 | signal spdif_out : std_logic; 55 | 56 | -- Clock period definitions 57 | constant clk_period : time := 20 ns; 58 | 59 | BEGIN 60 | 61 | -- Instantiate the Unit Under Test (UUT) 62 | uut: spdf_out PORT MAP ( 63 | clk => clk, 64 | spdif_out => spdif_out 65 | ); 66 | 67 | -- Clock process definitions 68 | clk_process :process 69 | begin 70 | clk <= '0'; 71 | wait for clk_period/2; 72 | clk <= '1'; 73 | wait for clk_period/2; 74 | end process; 75 | 76 | 77 | -- Stimulus process 78 | stim_proc: process 79 | begin 80 | -- hold reset state for 100 ns. 81 | wait for 100 ns; 82 | 83 | wait for clk_period*10; 84 | 85 | -- insert stimulus here 86 | 87 | wait; 88 | end process; 89 | 90 | END; 91 | -------------------------------------------------------------------------------- /spdif_out/tb_timebase.vhd: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- Company: 3 | -- Engineer: 4 | -- 5 | -- Create Date: 20:25:57 07/07/2011 6 | -- Design Name: 7 | -- Module Name: C:/Users/Hamster/Projects/FPGA/spdif_out/tb_timebase.vhd 8 | -- Project Name: spdif_out 9 | -- Target Device: 10 | -- Tool versions: 11 | -- Description: 12 | -- 13 | -- VHDL Test Bench Created by ISE for module: Timebase 14 | -- 15 | -- Dependencies: 16 | -- 17 | -- Revision: 18 | -- Revision 0.01 - File Created 19 | -- Additional Comments: 20 | -- 21 | -- Notes: 22 | -- This testbench has been automatically generated using types std_logic and 23 | -- std_logic_vector for the ports of the unit under test. Xilinx recommends 24 | -- that these types always be used for the top-level I/O of a design in order 25 | -- to guarantee that the testbench will bind correctly to the post-implementation 26 | -- simulation model. 27 | -------------------------------------------------------------------------------- 28 | LIBRARY ieee; 29 | USE ieee.std_logic_1164.ALL; 30 | 31 | -- Uncomment the following library declaration if using 32 | -- arithmetic functions with Signed or Unsigned values 33 | --USE ieee.numeric_std.ALL; 34 | 35 | ENTITY tb_timebase IS 36 | END tb_timebase; 37 | 38 | ARCHITECTURE behavior OF tb_timebase IS 39 | 40 | -- Component Declaration for the Unit Under Test (UUT) 41 | 42 | COMPONENT Timebase 43 | PORT( 44 | clk : IN std_logic; 45 | bitclock : OUT std_logic 46 | ); 47 | END COMPONENT; 48 | 49 | 50 | --Inputs 51 | signal clk : std_logic := '0'; 52 | 53 | --Outputs 54 | signal bitclock : std_logic; 55 | 56 | -- Clock period definitions 57 | constant clk_period : time := 10 ns; 58 | 59 | BEGIN 60 | 61 | -- Instantiate the Unit Under Test (UUT) 62 | uut: Timebase PORT MAP ( 63 | clk => clk, 64 | bitclock => bitclock 65 | ); 66 | 67 | -- Clock process definitions 68 | clk_process :process 69 | begin 70 | clk <= '0'; 71 | wait for clk_period/2; 72 | clk <= '1'; 73 | wait for clk_period/2; 74 | end process; 75 | 76 | -- Stimulus process 77 | stim_proc: process 78 | begin 79 | -- hold reset state for 100 ns. 80 | wait for 100 ns; 81 | 82 | wait for clk_period*10; 83 | -- insert stimulus here 84 | 85 | wait; 86 | end process; 87 | 88 | END; 89 | -------------------------------------------------------------------------------- /src/_unused/etherload_done.a65: -------------------------------------------------------------------------------- 1 | ; Program to exit etherload when all data has been received 2 | 3 | .org $682c 4 | .scope 5 | 6 | ; Tell etherload that this packet is executable 7 | lda #$00 8 | 9 | ; copy routine to casette buffer, since the routine demaps the packet 10 | ; buffer from which it would otherwise be running. 11 | ldx #$00 12 | l1: lda programentrypoint,x 13 | sta $0340,x 14 | inx 15 | cpx #$40 16 | bne l1 17 | jmp $0340 18 | 19 | programentrypoint: 20 | 21 | ; MEGA65 io 22 | lda #$47 23 | sta $d02f 24 | lda #$53 25 | sta $D02f 26 | 27 | ; Restore memory mapping 28 | lda #$00 29 | ldx #$0f 30 | ldy #$00 31 | ldz #$00 32 | map 33 | eom 34 | 35 | ; $DE000 - $6000 = $D8000 36 | lda #$00 37 | ldx #$00 38 | ldy #$00 39 | ldz #$00 40 | map 41 | eom 42 | 43 | ; pop JSR return address so that we return from etherload completely 44 | pla 45 | pla 46 | 47 | rts 48 | 49 | .scend 50 | 51 | .outfile "etherload_done.bin" -------------------------------------------------------------------------------- /src/_unused/etherload_stub.a65: -------------------------------------------------------------------------------- 1 | .org $682c 2 | 3 | ; Routine to DMA copy the packet to its correct location. 4 | ; For simplicity we will have the destination address and 5 | ; length of the packet at a well known location in the packet. 6 | 7 | ; The packet is mapped at $6800, but to use an embedded DMA list we 8 | ; care about the true address, which is @ $FFDE800. 9 | ; so we need to set MB for DMA list, and also the source and destination 10 | ; MB of the DMA transfer 11 | 12 | ; Routine must begin with LDA #$xx for etherload to JSR to call this 13 | ; routine when it appears in a packet. 14 | 15 | ; Set DMA source and destination 16 | 17 | ; DMA source MB is in Mega-byte $FF 18 | lda #$ff 19 | sta $d705 20 | ; DNA destination MB 21 | lda dest_mb 22 | sta $d706 23 | 24 | ; DMA list lives at $DE85C 25 | lda #$0d 26 | sta $d702 27 | lda #$e8 28 | sta $d701 29 | ; DMA list lives in Mega-byte $FF .. 30 | LDA #$ff 31 | sta $d704 32 | ; set low byte of DMA list address and start DMA 33 | lda # 2 | #include 3 | 4 | int main(int argc, char **argv) 5 | { 6 | char line[1024]; 7 | unsigned int b[8]; 8 | 9 | line[0] = 0; 10 | fgets(line, 1024, stdin); 11 | while (line[0]) { 12 | if (sscanf(line, " x\"%x\", x\"%x\", x\"%x\", x\"%x\", x\"%x\", x\"%x\", x\"%x\", x\"%x\"", &b[0], &b[1], &b[2], &b[3], 13 | &b[4], &b[5], &b[6], &b[7]) 14 | == 8) { 15 | for (int i = 0; i < 8; i++) { 16 | printf(" -- PIXELS: %c%c%c%c%c%c%c%c\n", b[i] & 0x80 ? '*' : ' ', b[i] & 0x40 ? '*' : ' ', b[i] & 0x20 ? '*' : ' ', 17 | b[i] & 0x10 ? '*' : ' ', b[i] & 0x08 ? '*' : ' ', b[i] & 0x04 ? '*' : ' ', b[i] & 0x02 ? '*' : ' ', 18 | b[i] & 0x01 ? '*' : ' '); 19 | } 20 | printf(" x\"%02x\", x\"%02x\", x\"%02x\", x\"%02x\", " 21 | "x\"%02x\", x\"%02x\", x\"%02x\", x\"%02x\",\n", 22 | b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7]); 23 | } 24 | else { 25 | if (strncmp(line, " -- PIXELS:", 12)) 26 | printf("%s", line); 27 | } 28 | line[0] = 0; 29 | fgets(line, 1024, stdin); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/_unused2/ghdl_ram151x512.vhdl: -------------------------------------------------------------------------------- 1 | use WORK.ALL; 2 | 3 | library IEEE; 4 | use IEEE.STD_LOGIC_1164.ALL; 5 | use ieee.numeric_std.all; 6 | use Std.TextIO.all; 7 | use work.debugtools.all; 8 | 9 | ENTITY ram151x512 IS 10 | PORT ( 11 | clka : IN STD_LOGIC; 12 | wea : IN STD_LOGIC_VECTOR(0 DOWNTO 0); 13 | addra : IN STD_LOGIC_VECTOR(8 DOWNTO 0); 14 | dina : IN STD_LOGIC_VECTOR(150 DOWNTO 0); 15 | clkb : IN STD_LOGIC; 16 | addrb : IN STD_LOGIC_VECTOR(8 DOWNTO 0); 17 | doutb : OUT STD_LOGIC_VECTOR(150 DOWNTO 0) 18 | ); 19 | END ram151x512; 20 | 21 | architecture behavioural of ram151x512 is 22 | 23 | type ram_t is array (0 to 511) of std_logic_vector(150 downto 0); 24 | 25 | signal ram : ram_t; 26 | begin -- behavioural 27 | 28 | process(clka) 29 | variable theram : ram_t; 30 | begin 31 | if(rising_edge(Clka)) then 32 | if wea(0)='1' then 33 | ram(to_integer(unsigned(addra))) <= dina; 34 | end if; 35 | 36 | doutb <= ram(to_integer(unsigned(addrb))); 37 | end if; 38 | end process; 39 | 40 | end behavioural; 41 | -------------------------------------------------------------------------------- /src/_unused2/ghdl_ram8x64k.vhdl: -------------------------------------------------------------------------------- 1 | use WORK.ALL; 2 | 3 | library IEEE; 4 | use IEEE.STD_LOGIC_1164.ALL; 5 | use ieee.numeric_std.all; 6 | use Std.TextIO.all; 7 | use work.debugtools.all; 8 | 9 | ENTITY ram8x64k IS 10 | PORT ( 11 | clka : IN STD_LOGIC; 12 | ena : IN STD_LOGIC; 13 | wea : IN STD_LOGIC_VECTOR(0 DOWNTO 0); 14 | addra : IN STD_LOGIC_VECTOR(14 DOWNTO 0); 15 | dina : IN STD_LOGIC_VECTOR(7 DOWNTO 0); 16 | douta : OUT STD_LOGIC_VECTOR(7 DOWNTO 0); 17 | clkb : IN STD_LOGIC; 18 | web : IN STD_LOGIC_VECTOR(0 DOWNTO 0); 19 | addrb : IN STD_LOGIC_VECTOR(14 DOWNTO 0); 20 | dinb : IN STD_LOGIC_VECTOR(7 DOWNTO 0); 21 | doutb : OUT STD_LOGIC_VECTOR(7 DOWNTO 0) 22 | ); 23 | END ram8x64k; 24 | 25 | architecture behavioural of ram8x64k is 26 | 27 | type ram_t is array (0 to 65535) of std_logic_vector(7 downto 0); 28 | signal ram : ram_t := ( 29 | 0 => x"02", 1 => x"03", 2 => x"04", 3 => x"06", 4 => x"06", 5 => x"06", 6 => x"06", 7 => x"06", 8 => x"06", 39 => x"06", 30 | others => x"07"); 31 | 32 | signal douta_drive : std_logic_vector(7 downto 0); 33 | signal doutb_drive : std_logic_vector(7 downto 0); 34 | 35 | begin -- behavioural 36 | 37 | process(clka) 38 | begin 39 | douta_drive <= ram(to_integer(unsigned(addra(15 downto 0)))); 40 | douta <= douta_drive; 41 | 42 | --report "COLOURRAM: A Reading from $" & to_hstring(unsigned(addra)) 43 | -- & " = $" & to_hstring(ram(to_integer(unsigned(addra)))); 44 | if(rising_edge(Clka)) then 45 | if ena='1' then 46 | if(wea="1") then 47 | ram(to_integer(unsigned(addra(15 downto 0)))) <= dina; 48 | report "COLOURRAM: A writing to $" & to_hstring(unsigned(addra)) 49 | & " = $" & to_hstring(dina); 50 | end if; 51 | end if; 52 | end if; 53 | end process; 54 | 55 | process (clkb,addrb,ram) 56 | begin 57 | doutb_drive <= ram(to_integer(unsigned(addrb(15 downto 0)))); 58 | doutb <= doutb_drive; 59 | if(rising_edge(Clkb)) then 60 | if(web="1") then 61 | -- ram(to_integer(unsigned(addrb))) <= dinb; 62 | end if; 63 | end if; 64 | end process; 65 | 66 | end behavioural; 67 | -------------------------------------------------------------------------------- /src/_unused2/load.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.net.*; 3 | 4 | public class load { 5 | public static void main(String[] args) { 6 | if (args.length<3||args.length>4) { 7 | System.out.println("usage: load [load address]"); 8 | return; 9 | } 10 | 11 | // Parse arguments 12 | String hostname = args[0]; 13 | int port = Integer.parseInt(args[1]); 14 | String fileName = args[2]; 15 | int loadAddress = -1; 16 | if (args.length==4) loadAddress = Integer.parseInt(args[3],16); 17 | 18 | // Read file into byte array 19 | File file = new File(fileName); 20 | byte[] data = new byte[(int) file.length()]; 21 | try { 22 | FileInputStream fis = new FileInputStream(file); 23 | if (fis.read(data) != file.length()) { 24 | System.out.println("Could not read all of file. Aborting"); 25 | return; 26 | } 27 | System.out.println("Read " + data.length + " bytes."); 28 | 29 | Socket clientSocket = new Socket(hostname, port); 30 | DataOutputStream outToServer 31 | = new DataOutputStream(clientSocket.getOutputStream()); 32 | BufferedReader inFromServer 33 | = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); 34 | int startOffset=0; 35 | if (loadAddress==-1) { 36 | startOffset=2; 37 | loadAddress = data[0]+256*data[1]; 38 | } 39 | int stepSize=16; 40 | for(int i=startOffset; idata.length) count=data.length-i; 43 | // System.out.println("Sending "+count+" bytes @ offset " + i); 44 | // build string to send 45 | String toSend = "s" + String.format("%x",loadAddress + i - startOffset); 46 | for(int j=0;j-1: 37 | line=line.replace("THEROM",argv[3]) 38 | if line.find("ROMDATA")>-1: 39 | line=line.replace("ROMDATA",romdata) 40 | w.write(line) 41 | 42 | w.close() 43 | -------------------------------------------------------------------------------- /src/_unused2/mkversiona65.sh: -------------------------------------------------------------------------------- 1 | `which echo` -n 'msg_version: .byte "GIT COMMIT: ' >version.a65 2 | `which echo` -n `git log | head -1 | cut -f2 -d" " | cut -c1-7,41-` >>version.a65 3 | echo '",0' >>version.a65 4 | -------------------------------------------------------------------------------- /src/_unused2/rom_4k_template.vhdl: -------------------------------------------------------------------------------- 1 | library IEEE; 2 | use IEEE.STD_LOGIC_1164.ALL; 3 | use ieee.numeric_std.all; 4 | 5 | -- 6 | entity THEROM is 7 | port (Clk : in std_logic; 8 | address : in std_logic_vector(11 downto 0); 9 | -- Yes, we do have a write enable, because we allow modification of ROMs 10 | -- in the running machine, unless purposely disabled. This gives us 11 | -- something like the WOM that the Amiga had. 12 | we : in std_logic; 13 | -- chip select, active low 14 | cs : in std_logic; 15 | data_i : in std_logic_vector(7 downto 0); 16 | data_o : out std_logic_vector(7 downto 0) 17 | ); 18 | end THEROM; 19 | 20 | architecture Behavioral of THEROM is 21 | 22 | -- 8K x 8bit pre-initialised RAM 23 | type ram_t is array (0 to 4095) of std_logic_vector(7 downto 0); 24 | signal ram : ram_t := (ROMDATA); 25 | 26 | begin 27 | 28 | --process for read and write operation. 29 | PROCESS(Clk,cs,ram) 30 | BEGIN 31 | if(rising_edge(Clk)) then 32 | if cs='1' then 33 | if(we='1') then 34 | ram(to_integer(unsigned(address))) <= data_i; 35 | end if; 36 | data_o <= ram(to_integer(unsigned(address))); 37 | end if; 38 | end if; 39 | if cs='1' then 40 | data_o <= ram(to_integer(unsigned(address))); 41 | else 42 | data_o <= "ZZZZZZZZ"; 43 | end if; 44 | END PROCESS; 45 | 46 | end Behavioral; 47 | -------------------------------------------------------------------------------- /src/_unused2/slowram_template.vhdl: -------------------------------------------------------------------------------- 1 | library IEEE; 2 | use IEEE.STD_LOGIC_1164.ALL; 3 | use ieee.numeric_std.all; 4 | 5 | -- 6 | entity THEROM is 7 | port ( 8 | address : in integer range 0 to 65535; 9 | -- output enable, active high 10 | oe : in std_logic; 11 | data_o : out unsigned(15 downto 0) 12 | ); 13 | end THEROM; 14 | 15 | architecture Behavioral of THEROM is 16 | 17 | type ram_t is array (0 to 65535) of unsigned(15 downto 0); 18 | signal ram : ram_t := (ROMDATA); 19 | 20 | begin 21 | 22 | --process for read and write operation. 23 | PROCESS(oe,ram,address) 24 | BEGIN 25 | if oe='0' then 26 | data_o <= ram(address)(7 downto 0)&ram(address)(15 downto 8); 27 | else 28 | data_o <= "ZZZZZZZZZZZZZZZZ"; 29 | end if; 30 | END PROCESS; 31 | 32 | end Behavioral; 33 | -------------------------------------------------------------------------------- /src/_unused2/upload.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import pexpect; 4 | import sys; 5 | 6 | rom=[] 7 | bytes_read = open(sys.argv[1], "rb").read() 8 | load_address = ord(bytes_read[1])*256+ord(bytes_read[0]) 9 | print "load address is $"+hex(load_address) 10 | skip=2 11 | for b in bytes_read: 12 | if skip==0: 13 | rom.append(b.encode('hex').upper()) 14 | else: 15 | skip=skip-1 16 | 17 | p = pexpect.spawn('sudo cu -l /dev/cu.usbserial-000012FDB -s 230400',timeout=3); 18 | #p.logfile = sys.stdout; 19 | 20 | p.sendline('?'); 21 | p.expect('\r\n\.'); 22 | 23 | for a in xrange(0,len(rom),8): 24 | cmd= "\rs" + hex(a+load_address)[2:] + " " + rom[a] + " " + rom[a+1] + " " + rom[a+2] + " " + rom[a+3] + " " + rom[a+4] + " " + rom[a+5] + " " + rom[a+6] + " " + rom[a+7] + "\r" 25 | for c in xrange(0,len(cmd)): 26 | p.send(cmd[c]); 27 | p.expect(cmd[c]); 28 | 29 | # for i in xrange(a,a+7): 30 | # p.expect("=000"+hex(i+load_address).upper()[2:]) 31 | p.expect(".*\r\n\."); 32 | print hex(a); 33 | 34 | print "Got here" 35 | print p.after 36 | 37 | -------------------------------------------------------------------------------- /src/border.a65: -------------------------------------------------------------------------------- 1 | .outfile "bin/border.prg" 2 | 3 | .word $0801 4 | .org $0801 5 | 6 | .scope 7 | .word _next, 10 ; Next line and current line number 8 | .byte $97, "2,0:", $9e, " 2014", $AA, "65",0 ; POKE 2,0 : SYS 2014+65 9 | _next: .word 0 10 | 11 | .checkpc 2079 12 | .advance 2079,$0 13 | 14 | ; enable m65 io 15 | lda #$47 16 | sta $d02f 17 | lda #$53 18 | sta $d02f 19 | ; reset sd 20 | lda #$00 21 | sta $d080 22 | 23 | jsr $e544 24 | 25 | lda #$01 26 | sta $d080 27 | 28 | ; wait for sd reset response 29 | ll1: 30 | inc $d020 31 | lda $d080 32 | sta $0427 33 | bne ll1 34 | 35 | ldx #$00 36 | lda #$ff 37 | 38 | ; read sector 39 | ldy #$02 40 | sty $d080 41 | 42 | loop: cmp $d09b 43 | beq loop 44 | lda $d09b 45 | sta $0400,x 46 | inx 47 | 48 | jmp loop 49 | 50 | .byte "PROP.M65U.NAME=BORDER FLASH",0 51 | .byte "PROP.M65U.ADDR=2079",0 52 | 53 | .scend 54 | -------------------------------------------------------------------------------- /src/hyppo/keyboard.asm: -------------------------------------------------------------------------------- 1 | ;; /* ------------------------------------------------------------------- 2 | ;; MEGA65 "HYPPOBOOT" Combined boot and hypervisor ROM. 3 | ;; Paul Gardner-Stephen, 2014-2024. 4 | ;; ---------------------------------------------------------------- */ 5 | 6 | ;; peek first key in accelerated key buffer, without removing it 7 | ;; carry set if not key found (A is 0 in that case) 8 | ;; keycode is in accumulator 9 | peekkeyboard: 10 | ;; We now use hardware-accelerated keyboard reading 11 | lda ascii_key_in 12 | cmp #$00 13 | beq nokey 14 | clc 15 | rts 16 | nokey: ;; no key currently down, so set carry and return 17 | sec 18 | rts 19 | 20 | ;; get first key from accelerated key buffer, removing it from queue 21 | ;; accumulater holds key 22 | ;; carry set if no key was in buffer (A is 0 in that case) 23 | scankeyboard: 24 | jsr peekkeyboard 25 | bcs nokey 26 | ;; clear key from buffer 27 | sta ascii_key_in 28 | clc 29 | rts 30 | -------------------------------------------------------------------------------- /src/hyppo/macros.asm: -------------------------------------------------------------------------------- 1 | ;; /* ------------------------------------------------------------------- 2 | ;; MEGA65 "HYPPOBOOT" Combined boot and hypervisor ROM. 3 | ;; Paul Gardner-Stephen, 2014-2024. 4 | ;; ---------------------------------------------------------------- */ 5 | 6 | 7 | ;; Convenient macro for checkpoints. Uncomment the body to activate it 8 | !macro Checkpoint .text { 9 | ;;jsr checkpoint 10 | ;;!8 0 11 | ;;!text .text 12 | ;;!8 0 13 | } 14 | -------------------------------------------------------------------------------- /src/hyppo/securemode.asm: -------------------------------------------------------------------------------- 1 | ;; /* ------------------------------------------------------------------- 2 | ;; MEGA65 "HYPPOBOOT" Combined boot and hypervisor ROM. 3 | ;; Paul Gardner-Stephen, 2014-2024. 4 | ;; ---------------------------------------------------------------- */ 5 | 6 | securemode_trap: 7 | 8 | ;; XXX - The following is what we SHOULD do for the complete system to work: 9 | ;; XXX Freeze current process to slot 10 | ;; XXX Find the requested service 11 | ;; XXX Load the requested service 12 | 13 | ;; Set secure mode flag, and set PC and memory map in the secure service 14 | 15 | ;; XXX - What we WILL do for now, is just enable secure mode, and set the PC to 16 | ;; $8000. 17 | 18 | ;; First, disable access to cartridge, force 50MHz mode and 4502 CPU personality 19 | lda #$32 20 | sta hypervisor_feature_enables 21 | 22 | ;; Second, disable all protecteed IO access, and mark matrix mode and secure mode. 23 | ;; This also freezes the CPU until the monitor acknowledges that the CPU is in 24 | ;; secure mode. Only after that will the remainder of this routine proceed, 25 | ;; and thus allow the secure program to run. 26 | ;; XXX - This means that a little piece of the hypervisor is still running when we 27 | ;; go into the secure compartment. For this reason, the CPU needs to be blocked 28 | ;; from writing to hypervisor_secure_mode_flags when in that state. 29 | lda #$c0 30 | sta hypervisor_secure_mode_flags 31 | 32 | 33 | ;; At this point, the monitor detects that we have asked for secure mode, and will 34 | ;; ask for the user to either accept or reject. If they accept, the CPU will be 35 | ;; resumed into the loaded service. If not, all memory will be erased, before the 36 | ;; CPU is resumed. For now, a rejected action will just require a reboot. But 37 | ;; later, we will have the monitor tell the hypervisor by synthesising an appropriate 38 | ;; trap after wiping memory, presumbly by causing a write to a $D65x register. 39 | jmp nosuchtrap 40 | 41 | 42 | leave_securemode_trap: 43 | 44 | ;; If we get here, we have left a secure compartment, with either memory erased 45 | ;; or intact. Either way, we should hand control back to the user, and disable 46 | ;; matrix mode display. 47 | 48 | ;; XXX - Debug 49 | inc $d021 50 | 51 | lda #$00 52 | sta hypervisor_secure_mode_flags 53 | 54 | jmp nosuchtrap 55 | -------------------------------------------------------------------------------- /src/mega65_64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/src/mega65_64x64.png -------------------------------------------------------------------------------- /src/megacartstub.a65: -------------------------------------------------------------------------------- 1 | 2 | .org $0 3 | 4 | .byte "C64 CARTRIDGE " 5 | .byte 0,0,0,$40 6 | .byte $01,$00,$00,$00 7 | .byte $01,$00 ; EXROM, but not GAME 8 | .byte 0,0,0,0,0,0 9 | .byte "MEGA65 MEGACartridge" 10 | 11 | .checkpc $40 12 | .advance $40,$20 13 | 14 | .byte "CHIP",0,0,$20,$10,0,0,0,0,$80,0,$20,0 15 | 16 | .checkpc $50 17 | .advance $50,$00 18 | 19 | .org $8000 20 | 21 | .word c64_cart_reset_entry 22 | .word c64_cart_nmi_entry 23 | .byte $c3,$c2,$cd,"80" 24 | 25 | c64_cart_reset_entry: 26 | sei 27 | jsr $FF84 ; initialise I/O 28 | jsr $ff87 ; Get ready for BASIC 29 | jsr $ff8a ; setup IRQ etc vectors 30 | jsr $FF81 ; initialise screen 31 | jsr $FFCC ; clear IO channel 32 | cli 33 | ldy #0 34 | msgloop: 35 | lda not_mega65,y 36 | beq msgdone 37 | sty $fd 38 | jsr $ffd2 39 | ldy $fd 40 | iny 41 | bne msgloop 42 | msgdone: 43 | jmp msgdone 44 | 45 | c64_cart_nmi_entry: 46 | inc $d021 47 | jmp $ea81 48 | 49 | not_mega65: 50 | .byte 5,13 51 | .byte " THIS CARTRIDGE REQUIRES A MEGA65",13 52 | .byte 13 53 | .byte " PLEASE VISIT MEGA65.ORG",13 54 | .byte 0 55 | 56 | .checkpc $A000 57 | .advance $A000,$FF 58 | 59 | .outfile "bin/megacart.crt" -------------------------------------------------------------------------------- /src/test_fdisk: -------------------------------------------------------------------------------- 1 | #!/bin/sh -f 2 | 3 | mb=500 4 | 5 | if [ "x$1" != "x" ]; then 6 | mb=$1 7 | fi 8 | 9 | dd if=/dev/zero of=sdcard.img bs=1048576 count=$mb 10 | ./fdisk.native 11 | hexdump -C sdcard.img > ${mb}mb_bad.txt 12 | hdiutil attach -imagekey diskimage-class=CRawDiskImage -nomount sdcard.img 13 | fsck_msdos -y /dev/disk2s1 | tee ${mb}mb_fsck.log 14 | hexdump -C sdcard.img > ${mb}mb_fixed.txt 15 | newfs_msdos -v LOUD -F 32 -h 129 -n 2 -r 568 -c 8 -S 512 /dev/disk2s1 16 | hexdump -C sdcard.img > ${mb}mb_newfs.txt 17 | hdiutil detach disk2 18 | diff ${mb}mb_bad.txt ${mb}mb_fixed.txt 19 | -------------------------------------------------------------------------------- /src/tests/Makefile: -------------------------------------------------------------------------------- 1 | CC65= /usr/local/bin/cc65 2 | CL65= /usr/local/bin/cl65 3 | COPTS= -t c64 -O -Or -Oi -Os --cpu 6502 4 | LOPTS= 5 | 6 | %.s: %.c $(HEADERS) $(DATAFILES) 7 | $(CC65) $(COPTS) -o $@ $< 8 | 9 | 10 | 11 | all: vicii.prg 12 | 13 | vicii.prg: Makefile vicii.s 14 | $(CL65) $(COPTS) $(LOPTS) -o vicii.prg vicii.s 15 | 16 | eth_mdio.prg: Makefile eth_mdio.s 17 | $(CL65) $(COPTS) $(LOPTS) -o eth_mdio.prg eth_mdio.s 18 | -------------------------------------------------------------------------------- /src/tests/instructiontiming_asm.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MEGA65/mega65-core/11fcb6d663a98729caf72df8ad07f56f3fa2971a/src/tests/instructiontiming_asm.s -------------------------------------------------------------------------------- /src/tests/test_fdc_equal_flag.a65: -------------------------------------------------------------------------------- 1 | 2 | .outfile "src/tests/test_fdc_equal_flag.prg" 3 | 4 | .word $0801 5 | .org $0801 6 | 7 | .scope 8 | .word _next, 10 ; Next line and current line number 9 | .byte $97, "2,0:", $9e, " 2014", $AA, "65",0 ; POKE 2,0 : SYS 2014+65 10 | _next: .word 0 11 | 12 | .checkpc 2079 13 | .advance 2079 14 | 15 | ; enable FDC controller registers to be visible 16 | lda #$47 17 | sta $d02f 18 | lda #$53 19 | sta $d02f 20 | 21 | ; set FDC track, sector and side register 22 | lda #39 23 | sta $d084 ; set track number 24 | lda #$01 25 | sta $d085 ; set sector number 26 | lda #$00 27 | sta $d086 ; read from first side of the disk 28 | 29 | ; command FDC to read sector 30 | lda #$40 31 | sta $d081 32 | 33 | nop 34 | nop 35 | nop 36 | nop 37 | nop 38 | nop 39 | 40 | 41 | wait_for_read_ready: 42 | ; complain if it failed to read a sector 43 | lda $d082 44 | sta $0404 45 | and #$10 46 | bne failed_could_not_read_sector 47 | 48 | ; wait until read is ready 49 | lda $d083 50 | bpl wait_for_read_ready 51 | 52 | ; read FDC status 53 | lda $d082 54 | ; mask out EQUAL flag bit 55 | and #$20 56 | ; write it onto the screen 57 | sta $0400 58 | 59 | ; read 256 bytes 60 | ldy #$00 61 | waitforabyte: 62 | lda $d082 63 | and #$20 64 | bne waitforabyte 65 | lda $d087 66 | sta $0428,y 67 | iny 68 | bne waitforabyte 69 | inc $0401 70 | 71 | waitforabyte2: 72 | lda $d082 73 | and #$20 74 | bne waitforabyte2 75 | lda $d087 76 | sta $0528,y 77 | iny 78 | bne waitforabyte2 79 | inc $0402 80 | 81 | moo: inc $0427 82 | jmp moo 83 | 84 | ; Now command it to write after filling buffer with known values 85 | lda #$01 86 | sta $d081 ; reset buffer pointer to be sure 87 | 88 | ; $00-$FF then $0F-$00,$1F-$10 etc to $F0 89 | ldy #$00 90 | f001: tya 91 | sta $d087 92 | iny 93 | bne f001 94 | f002: tya 95 | eor #$0f 96 | sta $d087 97 | iny 98 | bne f002 99 | 100 | ; write to track 0 sector 0 101 | lda #$0 102 | sta $d084 103 | sta $d085 104 | sta $d086 105 | 106 | ; now command write 107 | lda #$80 108 | sta $d081 109 | 110 | ; then loop showing FDC status 111 | f003: lda $d082 112 | sta $0628,y 113 | iny 114 | bra f003 115 | 116 | 117 | ; exit when done 118 | rts 119 | 120 | ; make screen colour go funny if an error happened 121 | failed_could_not_read_sector: 122 | inc $d020 123 | jmp failed_could_not_read_sector 124 | 125 | .scend 126 | -------------------------------------------------------------------------------- /src/tests/vicii.cfg: -------------------------------------------------------------------------------- 1 | FEATURES { 2 | STARTADDRESS: default = $0801; 3 | } 4 | SYMBOLS { 5 | __LOADADDR__: type = import; 6 | __EXEHDR__: type = import; 7 | __STACKSIZE__: type = weak, value = $1000; # 4k stack (so that we can probably safely use $0800-$0FFF as 2nd screen) 8 | __HIMEM__: type = weak, value = $D000; 9 | } 10 | MEMORY { 11 | ZP: file = "", define = yes, start = $0002, size = $001A; 12 | LOADADDR: file = %O, start = %S - 2, size = $0002; 13 | HEADER: file = %O, define = yes, start = %S, size = $000D; 14 | MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __HIMEM__ - __HEADER_LAST__; 15 | BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__; 16 | } 17 | SEGMENTS { 18 | ZEROPAGE: load = ZP, type = zp; 19 | LOADADDR: load = LOADADDR, type = ro; 20 | EXEHDR: load = HEADER, type = ro; 21 | STARTUP: load = MAIN, type = ro; 22 | LOWCODE: load = MAIN, type = ro, optional = yes; 23 | CODE: load = MAIN, type = ro; 24 | RODATA: load = MAIN, type = ro; 25 | DATA: load = MAIN, type = rw; 26 | INIT: load = MAIN, type = rw; 27 | ONCE: load = MAIN, type = ro, define = yes; 28 | BSS: load = BSS, type = bss, define = yes; 29 | } 30 | FEATURES { 31 | CONDES: type = constructor, 32 | label = __CONSTRUCTOR_TABLE__, 33 | count = __CONSTRUCTOR_COUNT__, 34 | segment = ONCE; 35 | CONDES: type = destructor, 36 | label = __DESTRUCTOR_TABLE__, 37 | count = __DESTRUCTOR_COUNT__, 38 | segment = RODATA; 39 | CONDES: type = interruptor, 40 | label = __INTERRUPTOR_TABLE__, 41 | count = __INTERRUPTOR_COUNT__, 42 | segment = RODATA, 43 | import = __CALLIRQ__; 44 | } 45 | -------------------------------------------------------------------------------- /src/tests/vicii_asm.s: -------------------------------------------------------------------------------- 1 | .export _irq_handler 2 | .export _install_irq 3 | 4 | _install_irq: 5 | sei 6 | lda #<_irq_handler 7 | sta $0314 8 | lda #>_irq_handler 9 | sta $0315 10 | cli 11 | rts 12 | 13 | _irq_handler: 14 | ;; Upper-case text, screen at $0800 15 | lda #$25 16 | sta $d018 17 | 18 | lda #$01 19 | sta $d020 20 | 21 | ldx #$00 22 | loop: dex 23 | bne loop 24 | 25 | ;; lower case text, screen back at $0400 26 | lda #$17 27 | sta $d018 28 | 29 | lda #$00 30 | sta $d020 31 | 32 | inc $d019 33 | 34 | jmp $ea31 35 | -------------------------------------------------------------------------------- /src/tools/.gitignore: -------------------------------------------------------------------------------- 1 | # 6502 and 65C02 funcation tests, because that has a GPL 3 license 2 | 6502_functional_test.bin 3 | 6502_functional_test.lbl 4 | 65C02_extended_opcodes_test.bin 5 | 65C02_extended_opcodes_test.lbl 6 | -------------------------------------------------------------------------------- /src/tools/bin2c.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) 4 | { 5 | FILE *in = fopen(argv[1], "r"); 6 | char *name = argv[2]; 7 | FILE *out = fopen(argv[3], "w"); 8 | 9 | unsigned char buffer[1024 * 1024]; 10 | 11 | int size = fread(buffer, 1, 1024 * 1024, in); 12 | 13 | fprintf(out, "unsigned int %s_len=%d;\n", name, size); 14 | fprintf(out, "unsigned char %s[]={\n", name); 15 | for (int i = 0; i < size; i++) { 16 | fprintf(out, "0x%02x", buffer[i]); 17 | if (i < (size - 1)) 18 | fprintf(out, ","); 19 | if ((i & 0xf) == 0x0f) 20 | fprintf(out, "\n"); 21 | } 22 | fprintf(out, "};\n"); 23 | 24 | fclose(in); 25 | fclose(out); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /src/tools/bit2mcs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | void error(char *fmt, ...) 7 | { 8 | va_list ap; 9 | 10 | va_start(ap, fmt); 11 | printf("Error: "); 12 | vprintf(fmt, ap); 13 | printf("\n"); 14 | va_end(ap); 15 | exit(1); 16 | } 17 | 18 | int main(int argc, char *argv[]) 19 | { 20 | unsigned int loadAddr = 0; 21 | FILE *infile; 22 | FILE *outfile; 23 | int numBytes, i; 24 | int c; 25 | unsigned char lineData[16]; 26 | unsigned int chksum; 27 | 28 | // loadAddr=0; 29 | 30 | if (argc != 3) { 31 | printf("bit2mcs - Converts XILINX bitstream files to flashable files\n" 32 | "Usage: bit2mcs \nExample: bit2mcs mega65.bit mega65.mcs\n"); 33 | exit(1); 34 | } 35 | 36 | infile = fopen(argv[1], "rb"); 37 | 38 | if (infile == NULL) { 39 | error("cannot open input file %s", argv[2]); 40 | } 41 | fseek(infile, 120, SEEK_SET); 42 | outfile = fopen(argv[2], "wt"); 43 | if (outfile == NULL) { 44 | error("cannot open output file %s", argv[3]); 45 | } 46 | while (1) { 47 | if ((loadAddr & 0xFFFF) == 0) { 48 | fprintf(outfile, ":02000004"); 49 | fprintf(outfile, "%04X", loadAddr >> 16); 50 | chksum = 0x02 + 0x04 + ((loadAddr >> 24) & 0xFF) + ((loadAddr >> 16) & 0xFF); 51 | fprintf(outfile, "%02X\n", (-chksum) & 0xFF); 52 | } 53 | chksum = 0; 54 | for (numBytes = 0; numBytes < 16; numBytes++) { 55 | c = fgetc(infile); 56 | if (c == EOF) { 57 | break; 58 | } 59 | lineData[numBytes] = c; 60 | chksum += c; 61 | } 62 | if (numBytes == 0) { 63 | break; 64 | } 65 | fprintf(outfile, ":%02X%04X00", numBytes, loadAddr & 0xFFFF); 66 | for (i = 0; i < numBytes; i++) { 67 | fprintf(outfile, "%02X", lineData[i]); 68 | } 69 | chksum += numBytes; 70 | chksum += ((loadAddr >> 8) & 0xFF) + ((loadAddr >> 0) & 0xFF); 71 | fprintf(outfile, "%02X\n", (-chksum) & 0xFF); 72 | loadAddr += numBytes; 73 | if (c == EOF) { 74 | break; 75 | } 76 | } 77 | fprintf(outfile, ":00000001FF\n"); 78 | fclose(infile); 79 | fclose(outfile); 80 | return 0; 81 | } 82 | -------------------------------------------------------------------------------- /src/tools/format_banner.c: -------------------------------------------------------------------------------- 1 | /* 2 | Simple program to take multiple lines of input on stdin, 3 | and output them as constant width lines without CR or LF 4 | between them. This is used to make the default banner 5 | message in the matrix mode overlay display. 6 | 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | int main(int argc, char **argv) 15 | { 16 | if (argc != 3) { 17 | fprintf(stderr, "usage: format_banner \n"); 18 | if (argc > 1) 19 | unlink(argv[1]); 20 | exit(-1); 21 | } 22 | 23 | int cols = atoi(argv[2]); 24 | if (cols < 1 || cols > 999) { 25 | fprintf(stderr, "Columns per line should be between 1 and 999.\n"); 26 | unlink(argv[1]); 27 | exit(-2); 28 | } 29 | 30 | FILE *f = fopen(argv[1], "w"); 31 | if (!f) { 32 | perror("fopen"); 33 | fprintf(stderr, "Failed to open output file '%s' for writing.\n", argv[1]); 34 | unlink(argv[1]); 35 | exit(-3); 36 | } 37 | 38 | char line[1024]; 39 | line[0] = 0; 40 | fgets(line, 1024, stdin); 41 | while (line[0]) { 42 | // Trim CR/LF from end of line 43 | for (int i = 0; i < 1024; i++) 44 | if (line[i] == '\r' || line[i] == '\n') 45 | line[i] = 0; 46 | 47 | if (strlen(line) > cols) { 48 | fprintf(stderr, "Line too long (must be <= %d characters, but saw %d characters)\n", cols, (int)strlen(line)); 49 | fprintf(stderr, "The line in question was '%s'\n", line); 50 | unlink(argv[1]); 51 | exit(-4); 52 | } 53 | 54 | // Pad line to correct width 55 | int padding = 0; 56 | for (int i = 0; i < cols; i++) { 57 | if (!line[i]) 58 | padding = 1; 59 | if (padding) 60 | line[i] = ' '; 61 | } 62 | line[cols] = 0; 63 | 64 | // Write to output file 65 | fprintf(f, "%s", line); 66 | 67 | line[0] = 0; 68 | fgets(line, 1024, stdin); 69 | } 70 | 71 | fclose(f); 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /src/tools/hyppotest-opcodes.test: -------------------------------------------------------------------------------- 1 | # These test require a build of the 6502 function and 65c02 extended opcodes tests. 2 | # You can download the bin and lbl files from a recent release at 3 | # https://github.com/jimnicholls/6502_65C02_functional_tests/releases 4 | # These downloads cannot be included in mega65-core directly because that code had a GPL 3 license. 5 | 6 | test "6502 functional test" 7 | log on failure 8 | load 6502_functional_test.bin at $0 9 | loadsymbols 6502_functional_test.lbl at $0 10 | allow stack overflow 11 | allow stack underflow 12 | breakpoint .report_success 13 | jmp .startup 14 | end test 15 | 16 | test "65c02 extended opcode test" 17 | log on failure 18 | load 65C02_extended_opcodes_test.bin at $0 19 | loadsymbols 65C02_extended_opcodes_test.lbl at $0 20 | breakpoint .report_success 21 | jmp .startup 22 | end test 23 | -------------------------------------------------------------------------------- /src/tools/makerom/colourram_template.vhdl: -------------------------------------------------------------------------------- 1 | use WORK.ALL; 2 | 3 | library IEEE; 4 | use IEEE.STD_LOGIC_1164.ALL; 5 | use ieee.numeric_std.all; 6 | use Std.TextIO.all; 7 | use work.debugtools.all; 8 | 9 | ENTITY THEROM IS 10 | PORT ( 11 | clka : IN STD_LOGIC; 12 | ena : IN STD_LOGIC; 13 | wea : IN STD_LOGIC_VECTOR(0 DOWNTO 0); 14 | addra : IN STD_LOGIC_VECTOR(14 DOWNTO 0); 15 | dina : IN STD_LOGIC_VECTOR(7 DOWNTO 0); 16 | douta : OUT STD_LOGIC_VECTOR(7 DOWNTO 0); 17 | clkb : IN STD_LOGIC; 18 | web : IN STD_LOGIC_VECTOR(0 DOWNTO 0); 19 | addrb : IN STD_LOGIC_VECTOR(14 DOWNTO 0); 20 | dinb : IN STD_LOGIC_VECTOR(7 DOWNTO 0); 21 | doutb : OUT STD_LOGIC_VECTOR(7 DOWNTO 0) 22 | ); 23 | END THEROM; 24 | 25 | architecture behavioural of THEROM is 26 | 27 | type ram_t is array (0 to 32767) of std_logic_vector(7 downto 0); 28 | shared variable ram : ram_t := (ROMDATA); 29 | 30 | begin -- behavioural 31 | 32 | process(clka) 33 | begin 34 | 35 | --report "COLOURRAM: A Reading from $" & to_hstring(unsigned(addra)) 36 | -- & " = $" & to_hstring(ram(to_integer(unsigned(addra)))); 37 | if(rising_edge(Clka)) then 38 | if ena='1' then 39 | if(wea="1") then 40 | ram(to_integer(unsigned(addra(14 downto 0)))) := dina; 41 | report "COLOURRAM: A writing to $" & to_hstring(unsigned(addra)) 42 | & " = $" & to_hstring(dina); 43 | douta <= dina; 44 | else 45 | douta <= ram(to_integer(unsigned(addra(14 downto 0)))); 46 | end if; 47 | end if; 48 | end if; 49 | end process; 50 | 51 | process (clkb) 52 | begin 53 | if(rising_edge(Clkb)) then 54 | if(web="1") then 55 | -- ram(to_integer(unsigned(addrb))) <= dinb; 56 | end if; 57 | doutb <= ram(to_integer(unsigned(addrb(14 downto 0)))); 58 | end if; 59 | end process; 60 | 61 | end behavioural; 62 | -------------------------------------------------------------------------------- /src/tools/makerom/makerom: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from os.path import realpath, dirname, join 4 | from sys import argv 5 | 6 | if len(argv) < 4: 7 | print("Usage: %s " % (argv[0],)) 8 | exit(1) 9 | 10 | print("argv={}".format(argv)) 11 | print("argv[0]= the name of this python script") 12 | print("argv[1]= the template vhdl file") 13 | print("argv[2]= the binary data to embedd into the ROM") 14 | print("argv[3]= the name of the output vhdl-file (without extension)") 15 | print("argv[4]= the component name within the output vhdl-file") 16 | 17 | # Read a binary file and use it to make an initialised RAM 18 | 19 | file3 = open(argv[3]+".vhdl", "w") 20 | print('Opened {} for {}'.format(file3.name, file3.mode)) 21 | 22 | # Read in the ROM file 23 | romdata = "" 24 | 25 | file2 = open(argv[2], "rb") 26 | print("Opened {} for {}".format(file2.name, file2.mode)) 27 | 28 | bytes_read = file2.read() 29 | 30 | first = True 31 | c = 0 32 | count = 0 33 | for b in bytes_read: 34 | if first: 35 | first = False 36 | else: 37 | romdata += "," 38 | if c == 8: 39 | c = 0 40 | #if c==0: 41 | # romdata=romdata+"\n -- "+hex(count+0xe000)+"\n " 42 | romdata += 'x"%02X"' % (b,) 43 | count += 1 44 | c += 1 45 | 46 | print("read {} bytes from {}".format(count, file2.name)) 47 | 48 | # Read ROM template file 49 | file1 = open(argv[1], 'r') 50 | print("Opened {} for {}".format(file1.name, file1.mode)) 51 | 52 | lines = file1.readlines() 53 | for line in lines: 54 | line = line.replace("THEROM", argv[4]) 55 | line = line.replace("ROMDATA", romdata) 56 | file3.write(line) 57 | 58 | print("Wrote {}".format(file3.name)) 59 | 60 | # Close the opened files 61 | file3.close() 62 | print("Closed {}".format(file3.name)) 63 | file2.close() 64 | print("Closed {}".format(file2.name)) 65 | file1.close() 66 | print("Closed {}".format(file1.name)) 67 | -------------------------------------------------------------------------------- /src/tools/makerom/rom_template.vhdl: -------------------------------------------------------------------------------- 1 | library IEEE; 2 | use IEEE.STD_LOGIC_1164.ALL; 3 | use ieee.numeric_std.all; 4 | 5 | -- 6 | entity THEROM is 7 | port (Clk : in std_logic; 8 | address : in std_logic_vector(13 downto 0); 9 | address_i : in std_logic_vector(13 downto 0); 10 | -- Yes, we do have a write enable, because we allow modification of ROMs 11 | -- in the running machine, unless purposely disabled. This gives us 12 | -- something like the WOM that the Amiga had. 13 | we : in std_logic; 14 | -- chip select, active low 15 | cs : in std_logic; 16 | data_i : in std_logic_vector(7 downto 0); 17 | data_o : out std_logic_vector(7 downto 0) 18 | ); 19 | end THEROM; 20 | 21 | architecture Behavioral of THEROM is 22 | 23 | -- 16K x 8bit pre-initialised RAM 24 | type ram_t is array (0 to 16383) of std_logic_vector(7 downto 0); 25 | signal ram : ram_t := (ROMDATA); 26 | 27 | begin 28 | 29 | --process for read and write operation. 30 | PROCESS(Clk,cs,ram,address,address_i) 31 | BEGIN 32 | if(rising_edge(Clk)) then 33 | if cs='1' then 34 | if(we='1') then 35 | ram(to_integer(unsigned(address_i))) <= data_i; 36 | end if; 37 | end if; 38 | data_o <= ram(to_integer(unsigned(address))); 39 | end if; 40 | -- if cs='1' then 41 | -- data_o <= ram(to_integer(unsigned(address))); 42 | -- else 43 | -- data_o <= "ZZZZZZZZ"; 44 | -- end if; 45 | END PROCESS; 46 | 47 | end Behavioral; 48 | -------------------------------------------------------------------------------- /src/tools/matrix_banner.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // 5 rows of 50 chars 6 | unsigned char bannertext[50 * 5 + 1]; 7 | 8 | int main(int argc, char **argv) 9 | { 10 | if ((!argv[1]) || (!argv[2])) { 11 | fprintf(stderr, "Usage: %s \n", argv[0]); 12 | exit(-1); 13 | } 14 | FILE *f = fopen(argv[1], "r"); 15 | FILE *o = fopen(argv[2], "w"); 16 | if ((!f) || (!o)) { 17 | fprintf(stderr, "Could not open input and/or output files.\n"); 18 | exit(-1); 19 | } 20 | for (int i = 0; i < 5 * 50; i++) 21 | bannertext[i] = ' '; 22 | bannertext[5 * 50] = 0; 23 | 24 | for (int i = 0; i < 5; i++) { 25 | char line[1024]; 26 | line[0] = 0; 27 | fgets(line, 1024, f); 28 | printf("Processing line #%d : [%s]\n", i, line); 29 | for (int j = 0; (j < 50) && (line[j] >= ' '); j++) { 30 | bannertext[i * 50 + j] = line[j]; 31 | printf("."); 32 | } 33 | printf("\n"); 34 | } 35 | fprintf(o, "%s", bannertext); 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /src/tools/merge-issue.c: -------------------------------------------------------------------------------- 1 | /* 2 | Simple little program to allow the merging of all commits 3 | that are tagged with a particular issue. 4 | 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #define MAX_COMMITS 65536 11 | char *commits[MAX_COMMITS]; 12 | int commit_count = 0; 13 | 14 | void usage(void) 15 | { 16 | fprintf(stderr, "usage: merge-issue \n"); 17 | exit(-1); 18 | } 19 | 20 | int main(int argc, char **argv) 21 | { 22 | if (argc != 3) 23 | usage(); 24 | 25 | int issue = atoi(argv[1]); 26 | char *branch = argv[2]; 27 | 28 | fprintf(stderr, "Fetching list of commits...\n"); 29 | unlink("merge-issue.log"); 30 | char cmd[8192]; 31 | snprintf(cmd, 8192, "git log %s >merge-issue.log", branch); 32 | system(cmd); 33 | 34 | char issuetag[1024]; 35 | snprintf(issuetag, 1024, "#%d", issue); 36 | 37 | fprintf(stderr, "Finding relevant commits...\n"); 38 | FILE *f = fopen("merge-issue.log", "r"); 39 | char line[1024]; 40 | char last_commit[1024]; 41 | char commit_msg[1024]; 42 | line[0] = 0; 43 | fgets(line, 1024, f); 44 | while (line[0]) { 45 | sscanf(line, "commit %[^\n\r]", last_commit); 46 | if (strstr(line, issuetag)) { 47 | printf("%s : %s", last_commit, line); 48 | commits[commit_count++] = strdup(last_commit); 49 | } 50 | 51 | line[0] = 0; 52 | fgets(line, 1024, f); 53 | } 54 | fclose(f); 55 | 56 | fprintf(stderr, "Found %d relevant commits.\n", commit_count); 57 | 58 | for (int i = commit_count - 1; i > -1; i--) { 59 | snprintf(cmd, 8192, "git cherry-pick %s | tee cherry-pick.log", commits[i]); 60 | fprintf(stderr, "%s\n", cmd); 61 | fprintf(stderr, "Press ENTER to apply.\n"); 62 | fgets(line, 1024, stdin); 63 | system(cmd); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/tools/osk_image.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define PNG_DEBUG 3 5 | #include 6 | 7 | unsigned char frame[600][800 * 4]; 8 | 9 | int image_number = 0; 10 | 11 | void write_image(int image_number); 12 | 13 | int main(int argc, char **argv) 14 | { 15 | int x, y, r, g, b; 16 | 17 | char line[1024]; 18 | 19 | printf("Clear frame...\n"); 20 | 21 | for (y = 0; y < 480; y++) 22 | for (x = 0; x < 800 * 4; x++) 23 | frame[y][x] = 0; 24 | 25 | printf("Read pixels...\n"); 26 | 27 | int last_y = -1; 28 | 29 | line[0] = 0; 30 | fgets(line, 1024, stdin); 31 | while (line[0]) { 32 | if (sscanf(line, "%*[^\\.].vhdl:%*[^:]:%*d:%*[^:]:(report note): PIXEL:%d:%d:%x:%x:%x", &x, &y, &r, &g, &b) == 5) { 33 | if (x >= 0 && x < 800 && y >= 0 && y < 600) { 34 | frame[y][x * 4 + 0] = r; 35 | frame[y][x * 4 + 1] = g; 36 | frame[y][x * 4 + 2] = b; 37 | frame[y][x * 4 + 3] = 0xff; 38 | if (y != last_y) { 39 | printf("y=%d\n", y); 40 | last_y = y; 41 | } 42 | } 43 | if (x == 800 && y == 400) { 44 | printf("Writing image %d\n", ++image_number); 45 | write_image(image_number); 46 | } 47 | } 48 | else { 49 | if (strstr(line, "active")) 50 | printf("%s", line); 51 | if (strstr(line, "Xeno")) 52 | printf("%s", line); 53 | if (strstr(line, "y_start_current")) 54 | printf("%s", line); 55 | } 56 | 57 | line[0] = 0; 58 | fgets(line, 1024, stdin); 59 | } 60 | return 0; 61 | } 62 | 63 | void write_image(int image_number) 64 | { 65 | int y; 66 | png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 67 | if (!png) 68 | abort(); 69 | 70 | png_infop info = png_create_info_struct(png); 71 | if (!info) 72 | abort(); 73 | 74 | if (setjmp(png_jmpbuf(png))) 75 | abort(); 76 | 77 | char filename[1024]; 78 | snprintf(filename, 1024, "oskimage-%04d.png", image_number); 79 | FILE *f = fopen(filename, "wb"); 80 | if (!f) 81 | abort(); 82 | 83 | png_init_io(png, f); 84 | 85 | png_set_IHDR( 86 | png, info, 800, 480, 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_DEFAULT); 87 | 88 | png_write_info(png, info); 89 | 90 | for (y = 0; y < 600; y++) { 91 | png_write_row(png, frame[y]); 92 | } 93 | 94 | png_write_end(png, info); 95 | fclose(f); 96 | 97 | return; 98 | } 99 | -------------------------------------------------------------------------------- /src/tools/pngprepare/giftotiles.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv) 6 | { 7 | int gif_error = 0; 8 | GifFileType *gif = NULL; 9 | 10 | gif = DGifOpenFileName(argv[1], &gif_error); 11 | if (!gif) { 12 | fprintf(stderr, "Could not read GIF file '%s'\n", argv[1]); 13 | exit(-1); 14 | } 15 | fprintf(stderr, "Read GIF of %d x %d pixels, %d frames\n", gif->SWidth, gif->SHeight, gif->ImageCount); 16 | if (DGifSlurp(gif) != GIF_OK) { 17 | fprintf(stderr, "DGifSlurp() failed.\n"); 18 | exit(-1); 19 | } 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /src/tools/utilpacker/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | cd ../.. ; make 3 | -------------------------------------------------------------------------------- /src/tools/vhdl-path-finder.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define MAX_LINES 32 7 | char line_history[MAX_LINES][1024]; 8 | int line_numbers[MAX_LINES]; 9 | 10 | int main(int argc, char **argv) 11 | { 12 | if (argc < 3) { 13 | fprintf(stderr, "usage: vhdl-path-finder \n"); 14 | exit(-1); 15 | } 16 | 17 | char *target = argv[1]; 18 | 19 | for (int i = 2; i < argc; i++) { 20 | int line_count = 0; 21 | int n = 0; 22 | FILE *f = fopen(argv[i], "rb"); 23 | if (!f) 24 | continue; 25 | char line[1024]; 26 | line[0] = 0; 27 | fgets(line, 1024, f); 28 | while (line[0]) { 29 | n++; 30 | if (strstr(line, "end if;")) { 31 | if (line_count > 0) { 32 | // Get rid of any elsif statements first 33 | while (line_count && strstr(line_history[line_count - 1], "elsif ")) 34 | line_count--; 35 | // Remove the last statement. 36 | line_count--; 37 | } 38 | else { 39 | fprintf(stderr, "ERROR: 'end if;' without 'if' statement.\n"); 40 | exit(-1); 41 | } 42 | } 43 | else if (strstr(line, "if ")) { 44 | char *s = strstr(line, "if "); 45 | char *comment = strstr(line, "--"); 46 | if ((!comment) || (comment > s)) { 47 | if (line_count < MAX_LINES) { 48 | line_numbers[line_count] = n; 49 | strcpy(line_history[line_count++], line); 50 | } 51 | else { 52 | fprintf(stderr, "ERROR: Too deeply nested if statements.\n"); 53 | exit(-1); 54 | } 55 | } 56 | } 57 | else if (strstr(line, target)) { 58 | printf("---------------------------------------\n"); 59 | for (int j = 0; j < line_count; j++) { 60 | printf("%4d %s", line_numbers[j], line_history[j]); 61 | } 62 | printf("%4d >>> %s", n, line); 63 | } 64 | 65 | line[0] = 0; 66 | fgets(line, 1024, f); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/utilities/c65test02prg.a65: -------------------------------------------------------------------------------- 1 | .outfile "utilities/c65test02prg.prg" 2 | 3 | .word $2000 4 | .org $2000 5 | 6 | .scope 7 | 8 | ; .word _next, 10 ; Next line and current line number 9 | 10 | ; .byte $97 ; POKE 2,0 11 | ; .byte "2,0:" 12 | 13 | .byte $00,$0b ; line number "10" 14 | .byte $20,$0a,$00 ; unsure 15 | .byte $8f ; REM 16 | .byte " C65" ; rem comment 17 | 18 | .byte $00,$19,$20,$14,$00 19 | 20 | .byte $9e, " 8192", $aa, "32" ; SYS 8192+32 21 | 22 | .byte 0,0,0 ; end of BASIC 23 | 24 | _next: .word 0 25 | 26 | .checkpc $2020 27 | .advance $2020 28 | 29 | 30 | ; unsure 31 | lda #$47 32 | sta $d02f 33 | lda #$53 34 | sta $d02f 35 | 36 | ; memory mapping i think 37 | lda #$ff 38 | ldx #$0f 39 | ldy #$00 40 | ldz #$00 41 | map 42 | nop 43 | 44 | ; memory mapping i think 45 | lda #$80 46 | ldx #$8d 47 | ldy #$00 48 | ldz #$00 49 | map 50 | nop 51 | 52 | inc $d020 53 | 54 | brk ; to return back to basic (not RTS) 55 | 56 | .scend 57 | 58 | -------------------------------------------------------------------------------- /src/utilities/cpusim.asm: -------------------------------------------------------------------------------- 1 | !to "src/utilities/cpusim.prg", plain 2 | foop: 3 | lda #$00 4 | clc 5 | adc #$01 6 | sec 7 | sbc #$02 8 | 9 | ;; MAP some SDRAM to $6000-$7FFF : $8000000+$6000 @ $6000 10 | lda #$00 11 | ldx #$80 12 | ldy #$00 13 | ldz #$00 14 | MAP 15 | ldx #$0f 16 | lda #$80 17 | ldy #$00 18 | ldz #$00 19 | MAP 20 | 21 | ;; Enable SDRAM cache line use 22 | lda #$04 23 | sta $d7fe 24 | 25 | ;; Now do some simple accesses 26 | ldx #$0f 27 | loop: 28 | txa 29 | sta $6000,x 30 | dex 31 | bpl loop 32 | 33 | ldx #$00 34 | loop2: 35 | lda $6000,x 36 | inx 37 | cpx #$10 38 | bne loop2 39 | 40 | end: jmp end 41 | -------------------------------------------------------------------------------- /src/utilities/diskmenuc000.a65: -------------------------------------------------------------------------------- 1 | ; 2 | ; Disk menu built to run at $C000 for building into hyppo ROM 3 | ; 4 | 5 | .code 6 | .org $C000 7 | 8 | .include "diskmenu.a65" 9 | 10 | .assert * < saveVect, error, "Code overflows data storage area!" 11 | 12 | ; $CE00 - $CEFF is reserved for hypervisor/filesystem scratch space 13 | ; (see hyppo.a65 for the allocations in this space) 14 | 15 | ;dengland 16 | ; Etherload is obsolete and no longer included. 17 | ; 18 | ; we place a copy of the eth-loader into memory, 19 | ; at location $CF06, but first two bytes of PRG is load address, 20 | ; so location $CF08 is the start of the program 21 | ; SYS $CF08 = SYS 53000 22 | ; 23 | ; .checkpc $CF06 24 | ; .advance $CF06 25 | ; .incbin "../../bin/etherload.prg" 26 | -------------------------------------------------------------------------------- /src/utilities/diskmenuprg.a65: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------- 2 | ;BASIC interface 3 | ;------------------------------------------------------------------------------- 4 | .code 5 | .org $07FF ;start 2 before load address so 6 | ;we can inject it into the binary 7 | 8 | .byte $01, $08 ;load address 9 | 10 | .word _basNext, $000A ;BASIC next addr and this line # 11 | .byte $9E ;SYS command 12 | .asciiz "2061" ;2061 and line end 13 | _basNext: 14 | .word $0000 ;BASIC prog terminator 15 | .assert * = $080D, error, "BASIC Loader incorrect!" 16 | ;------------------------------------------------------------------------------- 17 | 18 | .include "diskmenu.a65" 19 | 20 | .assert * < scratch_fileName, error, "Code overflows dynamic storage area!" -------------------------------------------------------------------------------- /src/utilities/ethertxtest.a65: -------------------------------------------------------------------------------- 1 | ; Ethernet controller test program for the MEGA65 2 | 3 | ; Include C64 BASIC program load header 4 | 5 | .word $0801 6 | .org $0801 7 | 8 | .scope 9 | .word _next, 10 ; Next line and current line number 10 | .byte $97, "2,0:", $9e, " 2014", $AA, "65",0 ; POKE 2,0 : SYS 2014+65 11 | _next: .word 0 12 | 13 | iter1: .byte 0 14 | 15 | .checkpc 2079 16 | .advance 2079 17 | 18 | programentrypoint: 19 | 20 | ; Enable MEGA65 io 21 | lda #$47 22 | sta $d02f 23 | lda #$53 24 | sta $D02f 25 | 26 | ; Map ethernet registers at $6000 - $7FFF 27 | 28 | ; Ethernet controller really lives $FFDE000 - $FFDEFFF, so select $FF megabyte section for MAP LO 29 | lda #$ff 30 | ldx #$0f 31 | ldy #$00 32 | ldz #$00 33 | map 34 | eom 35 | 36 | ; now enable mapping of $DE000-$DFFFF at $6000 37 | ; MAPs are offset based, so we need to subtract $6000 from the target address 38 | ; $DE000 - $6000 = $D8000 39 | lda #$80 40 | ldx #$8d 41 | ldy #$00 42 | ldz #$00 43 | map 44 | eom 45 | 46 | ; Ethernet buffer now visible at $6800 - $6FFF 47 | 48 | ; make sure ethernet transceiver is on and not generating IRQs 49 | ; (we will poll it). 50 | ; also make sure that we acknowledge the last received packet so that the 51 | ; ethernet controller knows it can receive. 52 | lda $d6e1 53 | lsr 54 | and #$02 55 | ora #$01 56 | sta $d6e1 57 | 58 | packetloop: 59 | jsr $ffe4 60 | cmp #$00 61 | beq packetloop 62 | 63 | ; set packet length 64 | lda #packet_length 67 | sta $d6e3 68 | 69 | ; copy packet body 70 | ldx #$00 71 | l1: lda sample_packet,x 72 | sta $6800,x 73 | inx 74 | bne l1 75 | 76 | ; Change single byte in frame 77 | lda $d012 78 | sta $6830 79 | 80 | ; TX packet 81 | lda #$01 82 | sta $d6e4 83 | 84 | inc $d020 85 | 86 | jmp packetloop 87 | 88 | .alias packet_length 66 89 | 90 | sample_packet: 91 | .byte $ff,$ff,$ff,$ff,$ff,$ff,$41,$41,$41,$41,$41,$41,$08,$00,$0f,$10 92 | .byte $11,$12,$13,$14,$15,$16,$17,$18,$19,$1a,$1b,$1c,$1d,$1e,$1f,$20 93 | .byte $21,$22,$23,$24,$25,$26,$27,$28,$29,$2a,$2b,$2c,$2d,$2e,$2f,$30 94 | .byte $31,$32,$33,$34,$00,$01,8,5,12,12,15,32,23,15,18,12 95 | .byte 4,33 96 | 97 | .scend 98 | 99 | .outfile "utilities/ethertxtest.prg" 100 | -------------------------------------------------------------------------------- /src/utilities/mega65_keyboardtest.a65: -------------------------------------------------------------------------------- 1 | ; Simple test program for GMK to test keyboards on manufacture 2 | 3 | .word $0801 4 | .org $0801 5 | .scope 6 | 7 | .word _next, 10 ; Next line and current line number 8 | .byte $9e, "2062",0 ; SYS 2062 9 | _next: .word 0 10 | 11 | iter1: .byte 0 12 | 13 | .checkpc 2062 14 | .advance 2062 15 | 16 | programentrypoint: 17 | 18 | sei 19 | 20 | ; MEGA65 io 21 | lda #$47 22 | sta $d02f 23 | lda #$53 24 | sta $D02f 25 | 26 | ; Fast CPU 27 | lda #65 28 | sta 0 29 | 30 | lda #$00 31 | sta $d020 32 | sta $d021 33 | 34 | ; clrscrn and set colourram to white 35 | sta $d707 36 | .byte $0a, $00 37 | .byte $07 38 | .word 40*25 39 | .word $0020 40 | .byte $00 41 | .word $0400 42 | .byte $00 43 | .word $0000 44 | .byte $0a, $81, $ff, $00 45 | .byte $03 46 | .word 40*25 47 | .word $0001 48 | .byte $00 49 | .word $0000 50 | .byte $08 51 | .word $0000 52 | 53 | ; copy note to screen, just below OSK 54 | ldx #79 55 | txtloop: 56 | lda notetext,x 57 | sta $0748,x 58 | dex 59 | bpl txtloop 60 | 61 | ; activate OSK 62 | lda #$ff 63 | sta $d615 64 | sta $d616 65 | 66 | ; do nothing... 67 | loop: 68 | jmp loop 69 | 70 | notetext: 71 | ; "NOTE: RESTORE WILL NOT WORK CORRECTLY, RIGHT AND UP WILL ALSO LIGHT UP RSHIFT. " 72 | .byte $0E, $0F, $14, $05, $3A, $20, $12, $05, $13, $14, $0F, $12, $05, $20, $17, $09, $0C, $0C, $20, $0E 73 | .byte $0F, $14, $20, $17, $0F, $12, $0B, $20, $03, $0F, $12, $12, $05, $03, $14, $0C, $19, $2C, $20, $20 74 | .byte $12, $09, $07, $08, $14, $20, $01, $0E, $04, $20, $15, $10, $20, $17, $09, $0C, $0C, $20, $01, $0C 75 | .byte $13, $0F, $20, $0C, $09, $07, $08, $14, $20, $15, $10, $20, $12, $13, $08, $09, $06, $14, $2E, $20 76 | 77 | .byte "PROP.M65U.NAME=KEYBOARD TEST" 78 | .byte 0 79 | 80 | 81 | .scend -------------------------------------------------------------------------------- /src/utilities/megaflash/README.md: -------------------------------------------------------------------------------- 1 | 2 | # New MEGAFLASH 3 | 4 | This directory contains the MEGAFLASH utility. It comes in two variants, one is embedded 5 | into the bitstreams initial memory (src/vhdl/shadowram*.vhdl), the other is called 6 | `mflash.prg` and can be run standalone. 7 | 8 | MEGAFLASH plays a vital role in the MEGA65's startup process. HYPPO will call MEGAFLASH 9 | during startup, and MEGAFLASH might reconfigure the system to start a different bitstream 10 | from flash. MEGAFLASH also allows the user to interrupt the boot process, so that they 11 | can change the flash or select a different bitstream manually. 12 | 13 | ## Standalone Mode 14 | 15 | This requires userspace SPI access, which is enabled by setting DIP switch #3 to ON. 16 | 17 | It's primary purpose is for debugging and development. It contains all the possible 18 | flashers and modes, and can work with or without attic ram. 19 | 20 | ## Integrated Mode 21 | 22 | This version is space optimised, as it needs to fit below HYPPO. To archive this, all 23 | the text and strings, as well as some data structures are place in upper memory at the 24 | end of bank 4. `screenbuilder.py` is used to archive this. 25 | 26 | # Building 27 | 28 | The global Makefile has targets for `megaflash-*.prg` (integrated versions, flash chip 29 | specific) and `mflash.prg` (standalone debug version, driver autodetect). 30 | 31 | ## Compiler Defines 32 | 33 | ### High-Level 34 | 35 | **STANDALONE** 36 | : enable standalone mode 37 | 38 | **FLASH_INSPECT** 39 | : add the flash inspector to the code, which will allow reading and erasing flash by hand 40 | 41 | **FIRMWARE_UPGRADE** 42 | : enable flashing of slot 0 for firmware upgrades 43 | 44 | **NO_ATTIC** 45 | : compile without Attic RAM support 46 | 47 | **TAB_FOR_MENU** 48 | : normally holding NO-SCROLL will interrupt boot and bring up the MEGAFLASH menu. With 49 | this enabled you can also use the TAB key instead. 50 | 51 | ### QSPI Driver Low-Level 52 | 53 | **QSPI_VERBOSE** 54 | : enable verbose output for qspi routines 55 | 56 | **QSPI_HW_ASSIST** 57 | : enable hardware assisted (i.e. VHDL integrated) flashing 58 | 59 | **QSPI_NO_BIT_BASH** 60 | : remove all bit bashing code (this enables **QSPI_HW_ASSIST**) 61 | 62 | **QSPI_S25FLXXXL** 63 | : include s25flxxxl driver (wukong pcbs) 64 | 65 | **QSPI_S25FLXXXS** 66 | : include s25flxxxs driver (mega65 pcbs and nexys boards) 67 | -------------------------------------------------------------------------------- /src/utilities/megaflash/crc32accl.h: -------------------------------------------------------------------------------- 1 | #ifndef CRC32ACCL_H 2 | #define CRC32ACCL_H 3 | 4 | #include 5 | 6 | // 4 bytes of zero page that are used for storing the CRC32 sum 7 | #define CRC32_ZP 0x5c 8 | 9 | /* 10 | * make_crc32_tables(uint8_t *t1, uint8_t *t2) 11 | * 12 | * Parameters: 13 | * *t1: a 512 byte size buffer 14 | * *t2: a second 512 byte buffer 15 | * 16 | * Initializes the crc32 tables in a user provided 17 | * 1k of RAM, given as two 512 byte blocks. 18 | * Note: aligning the memory to pages makes a small 19 | * difference. 20 | * 21 | */ 22 | extern void cdecl make_crc32_tables(uint8_t *t1, uint8_t *t2); 23 | 24 | /* 25 | * update_crc32(uint8_t len, uint8_t *buf) 26 | * 27 | * Parameters: 28 | * len: number of bytes in buffer, 0 means all 256! 29 | * *buf: pointer to a 256 byte buffer 30 | * 31 | * Updates a running crc32 checksum from the contents of 32 | * buf. 33 | * 34 | */ 35 | extern void cdecl update_crc32(uint8_t len, uint8_t *buf); 36 | 37 | /* 38 | * init_crc32() 39 | * 40 | * Inititialize CRC32_ZP to $ffffffff. 41 | * 42 | */ 43 | #define init_crc32() *(uint32_t *)CRC32_ZP = 0xffffffffUL 44 | 45 | /* 46 | * get_crc32() 47 | * 48 | * Returns: 49 | * current crc32 checksum as uint32_t 50 | * 51 | * Takes what is in CRC32_ZP and negates it binary. 52 | * 53 | */ 54 | #define get_crc32() ~(*(uint32_t *)CRC32_ZP) 55 | 56 | #endif /* CRC32ACCL_H */ -------------------------------------------------------------------------------- /src/utilities/megaflash/mf_buffers.c: -------------------------------------------------------------------------------- 1 | #include "mf_buffers.h" 2 | 3 | // used by QSPI routines 4 | unsigned char data_buffer[512]; 5 | 6 | // used by SD card routines 7 | unsigned char buffer[512]; 8 | 9 | unsigned char cfi_data[512]; 10 | -------------------------------------------------------------------------------- /src/utilities/megaflash/mf_buffers.h: -------------------------------------------------------------------------------- 1 | #ifndef MF_BUFFERS_H 2 | #define MF_BUFFERS_H 1 3 | 4 | extern unsigned char data_buffer[512]; 5 | extern unsigned char buffer[512]; 6 | extern unsigned char cfi_data[512]; 7 | 8 | #endif // MF_BUFFERS_H -------------------------------------------------------------------------------- /src/utilities/megaflash/mf_utility.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include "mhexes.h" 7 | #include "mf_buffers.h" 8 | 9 | #ifdef STANDALONE 10 | #include "mf_screens_solo.h" 11 | #else 12 | #include "mf_screens.h" 13 | #endif 14 | 15 | uint8_t mfu_slot_mb = 1; 16 | uint8_t mfu_slot_pagemask = (1 << 4) - 1; 17 | uint32_t mfu_slot_size = 1L << 20; 18 | 19 | uint8_t hw_model_id = 0; 20 | char hw_model_name[20] = "Unknown"; 21 | 22 | /*************************************************************************** 23 | 24 | FPGA / Core file / Hardware platform routines 25 | 26 | ***************************************************************************/ 27 | 28 | typedef struct { 29 | uint8_t model_id; 30 | uint8_t slot_mb; 31 | } mega_models_t; 32 | 33 | int8_t mfut_probe_hardware_version(void) 34 | { 35 | uint8_t k = 0; 36 | 37 | hw_model_id = PEEK(0xD629); 38 | 39 | #define MFUT_BUF2MOD(A) (((mega_models_t *)buffer)->A) 40 | 41 | while (k < mf_screens_mega65_target.cursor_y) { 42 | mhx_screen_get_line(&mf_screens_mega65_target, k++, (char *)&buffer); 43 | if (MFUT_BUF2MOD(model_id) == 0) 44 | break; 45 | if (MFUT_BUF2MOD(model_id) == hw_model_id) { 46 | mfu_slot_pagemask = mfu_slot_mb = MFUT_BUF2MOD(slot_mb); 47 | mfu_slot_pagemask <<= 4; 48 | mfu_slot_size = ((uint32_t)mfu_slot_pagemask) << 16; 49 | mfu_slot_pagemask--; 50 | mhx_strncpy(hw_model_name, buffer + sizeof(mega_models_t), 20); 51 | return 0; 52 | } 53 | } 54 | 55 | mhx_strncpy(hw_model_name, buffer + sizeof(mega_models_t), 20); 56 | return -1; 57 | } 58 | 59 | void mfut_reconfig_fpga(uint32_t addr) 60 | { 61 | uint8_t i; 62 | 63 | // Black screen when reconfiguring 64 | POKE(0xD020U, 0); 65 | POKE(0xD011U, 0); 66 | 67 | mega65_io_enable(); 68 | 69 | // Addresses for WBSTAR are shifted by 8 bits 70 | POKE(0xD6C8U, (addr >> 8) & 0xff); 71 | POKE(0xD6C9U, (addr >> 16) & 0xff); 72 | POKE(0xD6CAU, (addr >> 24) & 0xff); 73 | POKE(0xD6CBU, 0x00); 74 | 75 | // Try to reconfigure for some time 76 | for (i = 0; i < 200; i++) { 77 | // Wait a little while, to make sure that the WBSTAR slot in 78 | // the reconfig sequence gets set before we instruct the FPGA 79 | // to reconfigure. 80 | usleep(255); 81 | 82 | // Trigger reconfigure 83 | POKE(0xD6CFU, 0x42); 84 | // visual feedback 85 | POKE(0xD020U, PEEK(0xD020U) & 0x0F); 86 | } 87 | // reconfig failed! 88 | POKE(0xD020U, 0x0C); 89 | while (1); 90 | } 91 | -------------------------------------------------------------------------------- /src/utilities/megaflash/mf_utility.h: -------------------------------------------------------------------------------- 1 | #ifndef MF_UTILITY_H 2 | #define MF_UTILITY_H 1 3 | 4 | extern uint8_t mfu_slot_mb; 5 | extern uint8_t mfu_slot_pagemask; 6 | extern uint32_t mfu_slot_size; 7 | 8 | extern uint8_t hw_model_id; 9 | extern char hw_model_name[]; 10 | 11 | int8_t mfut_probe_hardware_version(void); 12 | 13 | /* 14 | * mfut_reconfig_fpga(addr) 15 | * 16 | * parameters: 17 | * addr: Flash address to reconfigure the FPGA to 18 | * 19 | * reconfigures the FPGA to start loading bitstream from addr 20 | * 21 | * does not return! 22 | * 23 | */ 24 | void mfut_reconfig_fpga(uint32_t addr); 25 | 26 | #endif /* MF_UTILITY_H */ 27 | -------------------------------------------------------------------------------- /src/utilities/megaflash/mhx_bin2scr.h: -------------------------------------------------------------------------------- 1 | #ifndef MHX_BIN2SCR_H 2 | #define MHX_BIN2SCR_H 3 | 4 | #include 5 | 6 | #define MHX_RDX_DEC 0 7 | #define MHX_RDX_BIN 1 8 | #define MHX_RDX_OCT 2 9 | #define MHX_RDX_HEX 3 10 | #define MHX_RDX_UPPER 0x80 11 | extern uint8_t cdecl mhx_bin2scr(uint8_t radix, uint8_t length, uint32_t bin, char *strbuf); 12 | 13 | #endif /* MHX_BIN2SCR_H */ -------------------------------------------------------------------------------- /src/utilities/megaflash/s25flxxxl.h: -------------------------------------------------------------------------------- 1 | #ifndef S25FLXXXL_H 2 | #define S25FLXXXL_H 3 | 4 | extern void * const s25flxxxl; 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /src/utilities/megaflash/s25flxxxs.h: -------------------------------------------------------------------------------- 1 | #ifndef S25FLXXXS_H 2 | #define S25FLXXXS_H 3 | 4 | extern void * const s25flxxxs; 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /src/utilities/sdbitbash.a65: -------------------------------------------------------------------------------- 1 | ; SD card bit-bash test program for the MEGA65 2 | 3 | ; Include C64 BASIC program load header 4 | 5 | .word $0801 6 | .org $0801 7 | 8 | .scope 9 | .word _next, 10 ; Next line and current line number 10 | .byte $97, "2,0:", $9e, " 2014", $AA, "65",0 ; POKE 2,0 : SYS 2014+65 11 | _next: .word 0 12 | 13 | iter1: .byte 0 14 | 15 | .checkpc 2079 16 | .advance 2079 17 | 18 | programentrypoint: 19 | 20 | ; Enable MEGA65 io 21 | lda #$47 22 | sta $d02f 23 | lda #$53 24 | sta $D02f 25 | 26 | ; 50MHz CPU 27 | lda #65 28 | sta 0 29 | 30 | ldy #$00 31 | lda #$20 32 | l4: sta $0400,y 33 | sta $0500,y 34 | sta $0600,y 35 | sta $0700,y 36 | iny 37 | bne l4 38 | 39 | ; enable bitbash mode for SD interface 40 | lda #$20 41 | sta $d60d 42 | 43 | mainloop: 44 | inc $0427 45 | 46 | ; Display current bit bash 47 | lda $d60d 48 | ldy #$00 49 | @bitloop: 50 | pha 51 | and #$80 52 | rol 53 | rol 54 | and #$01 55 | ora #$20 56 | sta $0400,y 57 | pla 58 | asl 59 | iny 60 | cpy #$08 61 | bne @bitloop 62 | 63 | jsr $ffe4 64 | 65 | cmp #$31 66 | bne @not1 67 | lda $d60d 68 | eor #$04 69 | sta $d60d 70 | jmp mainloop 71 | @not1: 72 | cmp #$32 73 | bne @not2 74 | lda $d60d 75 | eor #$08 76 | sta $d60d 77 | jmp mainloop 78 | @not2: 79 | cmp #$33 80 | bne @not3 81 | lda $d60d 82 | eor #$10 83 | sta $d60d 84 | jmp mainloop 85 | @not3: 86 | jmp mainloop 87 | 88 | 89 | .scend 90 | 91 | .outfile "utilities/sdbitbash.prg" 92 | -------------------------------------------------------------------------------- /src/utilities/setsdcardinfo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # check that we have an ARG as $1 4 | if [ "$1" = "" ]; then 5 | echo " " 6 | echo "Usage:" 7 | echo " $0 " 8 | echo " where is /dev/sdc for example." 9 | echo " " 10 | echo " Will (attempt to) format the device, suitable for MEGA65 use" 11 | echo " " 12 | exit 1 13 | fi 14 | 15 | # minimal error checking, ie for block-device, etc 16 | 17 | # output some useful info 18 | echo "using ARG[1]=\"${1}\" and ARG[2]=\"${2}\"." 19 | 20 | # first do a simple check to see if device-base is in mount file, if so, ERROR 21 | if [ `mount | grep $1 | wc -l` -gt 0 ]; then 22 | echo "dev $1 seems mounted -> umount it" 23 | exit 1 24 | else 25 | echo "dev $1 is NOT mounted, good." 26 | fi 27 | 28 | # print a warning here, ie: about to format a device, maybe user can type "y" to proceed 29 | 30 | 31 | echo -e "\n=========================" 32 | echo "zero first 10M of ${1}" 33 | sudo dd if=/dev/zero of=$1 bs=10240 count=1024 34 | 35 | echo -e "\n=========================" 36 | echo "Creating partition..." 37 | # New partition information 38 | # 39 | # basically we want just one partition, first, primary. Settings are below. 40 | # New, Primary, One, , size 41 | # Type, W95 FAT32, 42 | sudo fdisk -c=dos --sector-size 512 $1 <