notaz's Mega Everdrive doc $Id: megaednotes.txt 963 2014-09-22 23:47:51Z notaz $ mostly based on Krikzz's sources and forum posts General info ------------ As it is usual on Genesis/MD, where on-cart hardware is accessible by the 68000 at A130xx, the Mega-ED has it's registers in that range. The functions of those registers depend on currently active mapper. Typical SDRAM memory map ------------------------ 000000-DFFFFF - ROM/user program RAM E00000-EFFFFF - sram and savestate data F00000-FFFFFF - OS code OS mapper --------- Most of the hardware is accessible from this mapper, which includes: - SD card access over SPI with optional DMA - USB access with optional DMA for fast transfers from PC - 16MB of SDRAM is accessible - Audio DAC with optional buffering support - Possibility to switch to other mappers Note that the SDK recommends to use OS functions instead of accessing hardware registers directly. This is supposedly because FPGA firmware can change with OS updates, and register functions along with it, but OS functions will stay. A pointer to OS function table is placed at 0x1A0 of the OS code bank, see edos.h for the function table. Not all functionality is acessible by only using the OS functions though. The OS mapper is automatically activated if the ROM image is loaded that has "SEGA EVERDRIVE" at 0x100 of the ROM image, or it can be activated explicitly when uploading the ROM over USB. Registers: A13000 SPI_PORT SPI data port. SPI is used to access SD card Writing sends 8bit/16bit data over SPI, reading receives? Normally a write is done, then wait for STATE_PORT.SPI ready, then a read A13002 SPI_CFG_PORT SPI configuraton. ???????? ?6?43210 0: SS - chip select, 0 means active 1: FULL_SPEED - clearing this uses slow SPI speed for SD card init 2: SPI16 - switches between 16bit and 8bit SPI mode 3: AREAD - autoread, allows reads from SPI_PORT without writes? 4: DISK - SD card slot select (1=microSD) 6: FIFO_RST - ? A13004 ROM_CFG_PORT Unused? A13006 REG_MAP_PORT DRAM map to MD ROM space (000000-3FFFFF) 33332222 11110000 0: 1MiB SDRAM bank to map to 000000-0FFFFF 1: 1MiB SDRAM bank to map to 100000-1FFFFF 2: 1MiB SDRAM bank to map to 200000-2FFFFF 3: 1MiB SDRAM bank to map to 300000-3FFFFF A13008 REG_FIRM FPGA (?) Firmware version A1300A FIFO_PORT USB serial FIFO port? A1300C STATE_PORT SPI and USB state ???????? ????3210 0: SPI ready 1: FIFO write ready 2: FIFO read ready 3: DMA ready? A1300E REG_DAC Stereo dac. 8bit for each channel, 0xLLRR. Any writing to this port enables dac output, any reading from this port disables dac output. See also: REG_DAC_CFG A13010 REG_MAPPER Mapper number, takes effect immediately Locks out A130xx OS registers, changes their function. KEY_REG Seems to be still available, in MD mode at least ???c???8 ?654?mmm m: 0 - OS - OS mode 1 - MD - A130xx acts as SEGA mapper, sram save only? 2 - SSF - A130xx acts as SEGA mapper used in SSF 3 - CD 4 - SMS 5 - 10M 6 - 32X 4: SRAM_OFF 5: SRAM_ON 6: SRAM_3M_ON 8: SNAP_SAVE_ON c: MKEY A13012 REG_BANK_SRC When not 0, maps something at 0x100000?? A13014 DMA_ADDR Destination address / 512. This is SDRAM address, MD RAM can't be used A13016 ??? Unused? A13018 REG_DMA_LEN Transfer byte length / 512 A1301A REG_DMA_CFG Starts DMA. Should be done from MD RAM as cart space becomes unreadable? 0 - RAM? Not used 1 - SPI 2 - USB A1301E REG_MKEY_CFG When MKEY bit is set in REG_MAPPER, this overrides MD version register bits 7,6?? ???????? ??????rr r: new region register value A13020 REG_DAC_CFG Audio DAC control. Can be used to stream audio from FPGA internal 2x2K buffer to the DAC, also to allow DMA of data from SD/USB to that 2x2K buffer. The DAC runs at 21972Hz (45MHz / 2048) f??????? ?????210 0: dac_on 1: dac_source: 0 - REG_DAC, 1 - 2x2K buffer inside FPGA 2: dma_buff_we_on: makes any DMA to also update the internal 2x2K buffer f: refleccts which half of dma buffer currently is playing, basically it shows bit10 of buffer address counter A13028 REG_SPD Unused? A13040 KEY_REG Writing "magic" values here performs various functions. Used by the ingame menu. Available in MD mapper (and elsewhere?). 0x1234 - maps SDRAM bank 0x0E to 0x100000? 0xABCD - resets back to OS (like pressing reset button?) 0x0000 - returns back to normal mapper state