listen to a 6502 emulate a 6502 emulating a 6502

A place where you can keep others updated about your NES-related projects through screenshots, videos or information in general.

Moderator: Moderators

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

listen to a 6502 emulate a 6502 emulating a 6502

Post by Memblers » Fri Aug 14, 2020 7:58 am

One of the more absurd programs I've put together, this demo uses fake6502 by miker00lz, compiled with cc65, to emulate a 6502. The emulated 6502 remaps NES internal RAM to $7000 and a portion of $6000+ (that cc65 uses) to $7800. This emulated 6502 boots from the ROM's own reset vector, which in turn causes it to also begin emulating a 6502. But one of the emulated instances soon crashes, because it lacks the self-awareness required to relocate the RAM dynamically.

Audio output is updated (by XOR) with the lower 7-bits of the address during reads, and the data bus during writes.

cc65 version
00~01 - clearing RAM (1kB)
02~11 - code is running (cc65 is loading initialized data)
12~12 - program goes into the weeds
13~29 - BRK dancing
30 - emulated program seemingly rolls over and restarts

edit: updated and added, which includes the demo built with the new vbcc6502 compiler.

vbcc6502 version
00~05 - polling $2002?
06~06 - clearing NES RAM (2kB)
07~13 - loading initialized data
13+ - emulated CPU is stuck in an infinite loop
(16.65 KiB) Downloaded 81 times
(11.04 KiB) Downloaded 90 times

Posts: 1318
Joined: Fri Feb 24, 2012 12:09 pm

Re: listen to a 6502 emulate a 6502 emulating a 6502

Post by nocash » Fri Aug 14, 2020 7:57 pm

Not bad. A possible workaround for the problem might be a Playchoice10-style fix: Emulating an additional Z80 processor, then the emulated Z80 could simply reset the emulated 6502 when sensing the execution of BRK opcodes on the crashed 6502 (you may need expansion RAM for the Z80 memory).
homepage - patreon - you can think of a bit as a bottle that is either half full or half empty

Post Reply