nesxidy

Moderator: Moderators

Post Reply
User avatar
Memblers
Site Admin
Posts: 4044
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

nesxidy

Post by Memblers »

This is far from complete, and not really playable, thought I would dump it out here anyways in case anyone is interested in the technical side of it. It was fun as hell to make, but I don't know if/when I'll ever have the time to get back to it.
https://github.com/Memblers/nesxidy

(description copied from README.md)

-----

nesxidy V0.6 Alpha

Copyright ©2020 Joseph Parsell

additional credits:
Fake6502 by Mike Chambers, interpreted emulator
vbcc by Volker Barthelmann, C compiler used for development
lazyNES by Matthias Bock, NES library for vbcc

what it is

nesxidy is an experimental emulator that runs on the NES, which emulates a number of arcade games Exidy made on their 6502-based board. In this Alpha version, the emulation is extremely slow and the games are not fully playable. That could change in future versions.
partial support

Side Track (1979)
Targ (1980)
Spectar (1980)

how to use

Install vbcc for 6502 - http://www.compilers.de/vbcc.html
place (unzipped) ROM files into their respective ROM folders - https://www.mamedev.org/roms/
Modify config.h and dynamos-asm.s to select the game to include (a better selection system could be added later)
run w.bat to build
run in NES emulator

why is this

This emulator is a demonstration of DynaMOS, dynamic recompiler targeting the MOS Technology 6502 CPU as the host system. In this case, another 6502 is the guest system, as well. The reason one can't simply run 6502 code from one machine on different 6502 machine is because the memory map may be completely different. As it is a full-blown recompiler, much of the framework (with a significant amount of additional work) could be reused to host another CPU.

how the hell

Every single instruction must be evaluated and replaced with equivalent sequences, every single memory access examined and remapped, and all of it reassembled, to suit the target system. For any instructions that can't be recompiled, such as a branch or jump to a destination that hasn't been recompiled yet, or any unsupported instructions, control is handed over to an interpreter emulator (Fake6502). Handling an interpreted instructions may take several hundred times longer than the native equivalent, but as more of the emulated program has been run, more branch destinations have become known, and can be assembled into a native 6502 branch.

minimum system requirements

NMOS 6502 or compatible CPU
about 8kB of RAM, plus additional 4kB scratch RAM
512kB NOR Flash, SST39SF040 For NES: mapper 30 variant, 512kB Flash, 8kB PRG-RAM, 32kB CHR-RAM, 4-screen nametable.

emulation features

Supports up to 64kB of emulated RAM/ROM
6502 disassembler output to screen

technical details

The 512kB of Flash memory is reserved as such:

32kB emulation program
32kB emulated ROM
64kB program counter flags and bank numbers
128kB program counter jump table
240kB cache blocks
16kB cache block map

This allows for 960 cache blocks, of 256 bytes each. The program counter jump table allows for a virtual code space covering every possible program counter position for the emulated CPU. The cache blocks may contain only 2 or 3 instructions, initially. As the program counter jump table is populated, cache blocks will be more likely to contain longer sequences of instructions, and possibly entire subroutines.

To be added: Once the 960 cache blocks are full, an optimization pass can occur that will consolidate the code into a smaller number of cache blocks, eliminating the many jump instructions between blocks, and freeing up more entries in the cache map.

known issues

coin input not accepted in Targ, Spectar
sprites incorrect/disabled. Can't see the killer train in Side Track, can't see the player in Spectar and Targ
IRQ emulation is currently disabled
Spectar hangs

to do / wish list

possible next steps

finalize FlashROM cache support
preserve cache across power cycles
second optimization pass
NES emulator
debug breakpoints and single-step disassembly
code/data flag for detection of self-modifying code
cleaner separation of 6502-output-specific parts from the recompiler logic
additional CPU support. Chip-8, 8080, Z80, LR35902..?
partial TMS9918 emulation (CreatiVision)

version history

V0.6A - experimental support for new cache block format in FlashROM. Much slower emulation, as the new system is unoptimized and the old system is still being used at the same time. First public release.
V0.5 - changed cartridge hardware to use mapper 30 with FlashROM and WRAM.
V0.4 - added cache linking stage.
V0.3 - DynaMOS system added. Speed approx 1.5 seconds per frame, hamstrung by limited RAM for cache.
V0.2 - added Exidy I/O hardware emulation. Speed approx 2 seconds per frame.
V0.1 - interpreter-only emulator.

For personal use only. Do not distribute any copyrighted ROM files with this emulator without specific permission.
Attachments
recomp.png
sidetrack1.png
sidetrack1.png (9.06 KiB) Viewed 5441 times
sidetrack2.png
targ1.png
targ1.png (9.34 KiB) Viewed 5441 times
targ2.png
targ2.png (8.37 KiB) Viewed 5441 times
spectar6.png
spectar4.png
spectar4.png (9.43 KiB) Viewed 5441 times
User avatar
dink
Posts: 157
Joined: Sun Jan 12, 2020 8:42 pm

Re: nesxidy

Post by dink »

what you did here is really quite technically awesome!! :)
User avatar
Goose2k
Posts: 320
Joined: Wed May 13, 2020 8:31 am
Contact:

Re: nesxidy

Post by Goose2k »

dink wrote: Sun Feb 28, 2021 6:26 pm what you did here is really quite technically awesome!! :)
The best kind of awesome.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: nesxidy

Post by calima »

Wrong subforum? The compo requires A53 compatibility, but this requires mapper 30.
scott_the_phd
Posts: 7
Joined: Mon Oct 08, 2018 12:43 pm

Re: nesxidy

Post by scott_the_phd »

calima wrote: Mon Mar 01, 2021 12:50 amThe compo requires A53 compatibility, but this requires mapper 30.
Only for Category 1, anything can be submitted for Category 2. http://forums.nesdev.com/viewtopic.php?f=36&t=21635
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: nesxidy

Post by calima »

Oh indeed, it was only if aiming for the multicart for cat 2.
User avatar
Memblers
Site Admin
Posts: 4044
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: nesxidy

Post by Memblers »

Thanks for checking it out.

To be clear, it can't go on any multicart, the way it is now. While the ROMs are freely downloadable, they're not public domain, and have the caveat that only mame.net can distribute them. The copyright holder has since died, so there's no simple way to ask for permission.

It was a little frustrating towards the end where I left off development. I had added support for branches in native code, and this gave it a HUGE speed boost. But there was some kind of bug somewhere, so the program would go off the rails and do bad stuff. I tried a lot of debugging to no avail (this type of program, running on NES especially poses debugging challenges for sure - one really needs to log output), unfortunately. I doubt anyone else is crazy enough to pick up this project, but that's where it was at.
Post Reply