ca83: Assemble SM83 code with ca65

Discussion of programming and development for the original Game Boy and Game Boy Color.
Post Reply
tepples
Posts: 21941
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

ca83: Assemble SM83 code with ca65

Post by tepples » Thu Sep 26, 2019 10:34 pm

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.
Attachments
ca83-wip.zip
(25.26 KiB) Downloaded 128 times

lidnariq
Posts: 9290
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: ca83: Assemble SM83 code with ca65

Post by lidnariq » Fri Sep 27, 2019 12:22 am

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.

tepples
Posts: 21941
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: ca83: Assemble SM83 code with ca65

Post by tepples » Sat Nov 09, 2019 5:24 pm

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)
Attachments
ca83-0.03.zip
(31.47 KiB) Downloaded 91 times

Post Reply