Question: Where do I start with SNES development

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Question: Where do I start with SNES development

Post by dougeff »

How do I integrate the macro pack into my developer environment?
What kind of setup are you used to? Are you on Windows, Linux, etc?

There's not much "integration" involved. You only use the macro pack with ca65 just to build the SPC binary.

You also need some 65816 code to load and use the binary.

You also need another app to make the song data (like OpenMPT). And smconv.exe to convert the .IT file to the actual data.
where can I find the original source of said macro pack?
I think it was originally posted in this forum.
Last edited by dougeff on Thu Jan 05, 2023 9:43 am, edited 1 time in total.
nesdoug.com -- blog/tutorial on programming for the NES
PanderBerns
Posts: 10
Joined: Tue Jan 03, 2023 11:44 pm

Re: Question: Where do I start with SNES development

Post by PanderBerns »

dougeff wrote: Thu Jan 05, 2023 9:39 am What kind of setup are you used to? Are you on Windows, Linux, etc?
I use Windows mostly. I recently got VS Code Installed with the ca65 Macro Assembler Language extension by Cole Campbell installed.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Question: Where do I start with SNES development

Post by dougeff »

I think were using "macro" in 2 different ways.

Possibly a misunderstanding.

The macro pack I mean is just the spc-65c02.asm and spc-ca65.asm files, which helps the ca65 app understand the spc700 specific assembly code.
nesdoug.com -- blog/tutorial on programming for the NES
PanderBerns
Posts: 10
Joined: Tue Jan 03, 2023 11:44 pm

Re: Question: Where do I start with SNES development

Post by PanderBerns »

dougeff wrote: Thu Jan 05, 2023 9:45 am I think were using "macro" in 2 different ways.

Possibly a misunderstanding.
Well is it still possible for me to use this spc700 macro package anyway? Keep in mind I'm mainly using the"ca65 Macro Assembler Language" extension mostly to have proper syntax highlighting for 6502/65816 assembly in the VS Code text editor. I imagine the macro you're talking about isn't really gonna be used in the same way. I still felt like mentioning the extension just to fully clarify what my exact setup was.
PanderBerns
Posts: 10
Joined: Tue Jan 03, 2023 11:44 pm

Re: Question: Where do I start with SNES development

Post by PanderBerns »

dougeff wrote: Thu Jan 05, 2023 9:45 am The macro pack I mean is just the spc-65c02.asm and spc-ca65.asm files, which helps the ca65 app understand the spc700 specific assembly code.
Didn't see this part of the message sorry. So I assume I can just assemble them in the ca65 Assembler, along with files for game code and get a full rom with sound working then.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Question: Where do I start with SNES development

Post by dougeff »

Didn't see this part of the message
I edited my comment as you were replying to it.
nesdoug.com -- blog/tutorial on programming for the NES
PanderBerns
Posts: 10
Joined: Tue Jan 03, 2023 11:44 pm

Re: Question: Where do I start with SNES development

Post by PanderBerns »

dougeff wrote: Thu Jan 05, 2023 10:14 am I edited my comment as you were replying to it.
Ah okay, no worries. Guess its just a matter now of learning the ca65 assembler, as well as learning the language for 65816 and SPC700 of course. Probably a tutorial or two somewhere for those things.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Question: Where do I start with SNES development

Post by Pokun »

Macro is short for "macro instruction" which refers to an instruction that expands into multiple other instructions. You define a snippet of code as a macro and invoke the macro somewhere which the assembler expands into code before assembling it. The #define directive in C is a macro directive but it seems it's more used as a way to define constants in C, while macro in assemblers are typically used as a type of in-line subroutine/procedure/function to make code a bit more compact and readable by hiding part of it inside macro instructions.

That macro pack is a set of macro that essentially turns ca65 into an SPC700 assembler. The downside to this is that I think errors may be a bit incomprehensible compared to a native SPC700 assembler. But there is a severe lack of native SPC700 assemblers out there. Really the only one free alternative today is bass which is powerful but has a weird C-like syntax that are normally not used by assemblers and also heavily relies on its powerful macro capabilities for doing even simple tasks such as reserving space in RAM. Although it was originally made as an SPC700 assembler by the late Near, it is now table driven and needs a table for the instruction set. I made an SPC700 instruction set table here.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Question: Where do I start with SNES development

Post by Oziphantom »

ok, so right at the basics then. So go to https://commodore.bombjack.org/commodore/books.htm and then down to the MACHINE LANGUAGE and ASSEMBLY LANGUAGE and pick a book that speaks to you. Personally I recommend Commodore 64 Assembly Language by Bruce Smith but the Machine Language for the Commodore 64 and other Commodore Computers by Jim Butterfield is also high regarded. But there are a lot of books, find one that speaks to you. When it says use Monitor X/Y or Z ignore that and just use https://skilldrick.github.io/easy6502/ or a VICE x64sc monitor or the build in monitor on C128 via VICEs X128.

Once you have completed a or a couple of those books top to bottom, come back for the next steps.
Garth
Posts: 246
Joined: Wed Nov 30, 2016 4:45 pm
Location: Southern California
Contact:

Re: Question: Where do I start with SNES development

Post by Garth »

I can certainly second creaothceann's recommendation of the "Programming the 65816—Including the 6502, 65C02 and 65802" 6502/65816 programmer's manual by David Eyes and Ron Lichty.  This is definitely the best 65xx programming manual I know of, and a must-have for every 65xx programmer!  It starts with the basics, followed by architecture, the CMOS 65c02's many improvements over the original NMOS 6502 including added instructions and addressing modes and fixing the NMOS's bugs and quirks, and then the natural progression to the 65816; a thorough tutorial, writing applications, then very detailed and diagrammed information on all 34 addressing modes, at least a page of very detailed description for each instruction, with info on every addressing mode available for that instruction, then instruction lists, tables, and groups, of all 255 active op codes, plus more.  469 pages.  From Western Design Center.  (.pdf)  Note: There were many problems with the earlier .pdf version that were not in the original paper manual; but in late March 2015, WDC scanned and OCR'ed the paper manual and posted the new, repaired .pdf.

As for macros: The following is from the front page of the structure-macros section of my website:
  • First, what is an assembly-language macro?

    As you write an assembly-language program, you may see repeating patterns.  If it's exactly the same all the time, you can make it a subroutine.  That incurs a 12-clock performance penalty for the subroutine call (JSR) and return (RTS), but program memory is saved because the code for the subroutine is not repeated over and over.

    There will be other times however where the repeating pattern is the same but internal details are not, so you can't just use a JSR.  The differences from one occurrence to another might be an operand, a string or other data, an address, a condition, etc..  It would be helpful to be able to tell the assembler, "Do this sequence here; except when you get down to this part, substitute-in such-and-such," or, "under such-and-such condition, assemble this alternate code."  That's where it's time for a macro.  "White Flame" on the 6502.org forum wrote, "Macros are assembly-time function calls, whose return value is source code."

    The repeating, possibly messy-looking sequences that clutter your code can be replaced with a macro call that takes a single line each time, optionally with parameters.  Since you write the macro (or at least you can edit it if you want to, even if someone else wrote it), you have complete control of every bit of machine code that gets laid down.  After the internal details have been ironed out, you shouldn't have to keep being bothered with them.  If you can hide them with macros, you can see the big picture more clearly, have better control of the project, have fewer bugs, and become more productive without losing any performance or taking more memory.

    A macro may replace a piece of assembly-language code as short as a line or two, to give more clarity to what is being done there.  An example of a single-line macro is where you want to replace the 65816's cryptic REP and SEP instructions:

    Code: Select all

    INDEX_16: MACRO               ; Make index registers X & Y to be 16-bit.
              REP    #00010000B
     ;        NOP                 ; NOP was necessary for early versions
              ENDM                ; of '802/'816 >4MHz.
     ;-------------------
    
    INDEX_8:  MACRO               ; Make index registers X & Y to be 8-bit.
              SEP    #00010000B
     ;        NOP                 ; NOP was necessary for early versions
              ENDM                ; of '802/'816 >4MHz.
     ;-------------------
    INDEX_16 above is far more clear than REP #00010000B which it replaces, yet it lays down exactly the same machine code, C2 10, which takes 3 clocks' execution time at runtime.
http://WilsonMinesCo.com/ lots of 6502 resources
Post Reply