Page 1 of 1

ca83: Assemble SM83 code with ca65

Posted: Thu Sep 26, 2019 10:34 pm
by tepples
Years ago, blargg and I explored the concept of implementing uncommon ISAs using macro packs for ca65 .setcpu "none", in reimplemented 6502 and spca65. Now I have applied it to the Z80-like architecture of the Game Boy CPU. This is a very rough proof of concept, but it assembles a ROM that successfully executes in bgb and on my Game Boy. The only piece of RGBDS left is RGBFIX, used to write the internal header, which I plan to eventually replace.

"But why?"
Say you have a project for Super Game Boy that uses custom native code, anywhere from minor patches to Space Invaders-style full takeover. This would let you develop the Game Boy and Super NES parts using one assembler for all three instruction sets (SM83, 65816, SPC700), so as not to need to install RGBDS or WLA DX or work around some of their limits and bugs. Then the Super NES side would treat the Game Boy as a storage server, requesting 4 KiB sectors and waiting for the GB-side code to do the equivalent of DATA_TRN.

The tech would also generalize to the Zilog Z80, which has been used alongside a 2A03 on the Donkey Kong 3 and Punch-Out!! arcade system boards. The PlayChoice also uses a Z80 and 2A03, and now I'm curious as to whether custom Z80 code could be used to make the PlayChoice coin model act more like Vs. System where you buy lives instead of play time.

Re: ca83: Assemble SM83 code with ca65

Posted: Fri Sep 27, 2019 12:22 am
by lidnariq
tepples wrote:The PlayChoice also uses a Z80 and 2A03, and now I'm curious as to whether custom Z80 code could be used to make the PlayChoice coin model act more like Vs. System where you buy lives instead of play time.
nocash's everynes wrote:There is no intended CPU-to-CPU communication support. However, with some trickery, it should be possible. [...] For NES-to-Z80 transfers one could enable/disable NES NMIs to transfer 1 bit per frame. For Z80-to-NES transfers one could eventually issue specially timed CPU or PPU Reset pulses.
Still, a proof of concept should be doable, by having the 2A03 count how long between two reset pulses (and if it's in the right range, treating that as a valid packet containing some number of bits.)

Both the Z80 and 2A03 are running off quartz clock sources (8MHz for the Z80, standard 21.5MHz for the NES), so precisely timed code should be reasonably reliable.

Re: ca83: Assemble SM83 code with ca65

Posted: Sat Nov 09, 2019 5:24 pm
by tepples
I've updated ca83
  • Describe syntax choices
  • Add hlt and djnz macros
  • Rename to sm83isa.mac to allow use of .macpack
  • Add gbheader.py so that rgbfix need not be installed
  • Add bgb debug information (requested by NovaSquirrel)