Converting from NESASM to ASM6, some questions
Moderator: Moderators
Converting from NESASM to ASM6, some questions
I'm converting a rather large codebase from NESASM to ASM6, but I've run into a few problems:
1. Since ASM6 doesn't have the concept of banks, it also doesn't seem have the super useful BANK() function. Is there any way I can achieve the same effect or do I have to hardcode in the values?
2. While ASM6 has macros, it doesn't seem to have user-defined functions (unless I've just missed the syntax somewhere). You can't use macros as expressions, the compiler yells at you for trying. Any advice on how to deal with this?
Thanks in advance!
EDIT:
The conversion is now complete! It can be found here:
https://github.com/Drakim/smb3
1. Since ASM6 doesn't have the concept of banks, it also doesn't seem have the super useful BANK() function. Is there any way I can achieve the same effect or do I have to hardcode in the values?
2. While ASM6 has macros, it doesn't seem to have user-defined functions (unless I've just missed the syntax somewhere). You can't use macros as expressions, the compiler yells at you for trying. Any advice on how to deal with this?
Thanks in advance!
EDIT:
The conversion is now complete! It can be found here:
https://github.com/Drakim/smb3
Last edited by Drakim on Sun Nov 05, 2017 8:48 am, edited 1 time in total.
Re: Converting from NESASM to ASM6, some questions
.bank sucks. Be glad to be rid of it.
Link, again, to Tokumaru asm6 templates...
viewtopic.php?f=10&t=6160
I've also used .pad instead of .org, I think.
Question #2. I don't know.
Link, again, to Tokumaru asm6 templates...
viewtopic.php?f=10&t=6160
I've also used .pad instead of .org, I think.
Question #2. I don't know.
nesdoug.com -- blog/tutorial on programming for the NES
Re: Converting from NESASM to ASM6, some questions
.bank does indeed suck, but bank() is really useful when building tables to index stuff on different banks, or for cross-bank function calls. AFAIK, there's no equivalent in ASM6.
What I did in ASM6 was keep track of the current bank in a symbol, that I'd manually increment (or have a macro do it) for each bank. Then, whenever I knew I'd need to know the bank of a label, I'd write MyLabel_Bank = CurrentBank (or something like that) near the label, so I could use that symbol whenever I needed that label's bank. Not perfect, but definitely better than hardcoding bank numbers, since you can still move code around without breaking anything.
What I did in ASM6 was keep track of the current bank in a symbol, that I'd manually increment (or have a macro do it) for each bank. Then, whenever I knew I'd need to know the bank of a label, I'd write MyLabel_Bank = CurrentBank (or something like that) near the label, so I could use that symbol whenever I needed that label's bank. Not perfect, but definitely better than hardcoding bank numbers, since you can still move code around without breaking anything.
Re: Converting from NESASM to ASM6, some questions
And in ca65, if anyone's interested:
- .segment sets which segment you're in. The linker script associates each segment with a memory area, and each memory area can span multiple banks, a single bank, or part of a bank. (See linker scripts in the ld65 manual.) Each memory area also has an arbitrary integer value associated with it, set with the memory area's bank attribute.
- <.bank(some_address) reads the value of the bank attribute. The < is because the value is not known at assembly time to fit in 8 bits.
Re: Converting from NESASM to ASM6, some questions
Yes, in ca65 I obviously use these built-in features. Can't beat ca65 when it comes to stuff like this.
Re: Converting from NESASM to ASM6, some questions
What mapper does it use?
Can you share the source code?
Can you share the source code?
Re: Converting from NESASM to ASM6, some questions
The code is captain southbird's dissassembly of SMB3, located here if you are interested in having a look.FARID wrote:What mapper does it use?
Can you share the source code?
Re: Converting from NESASM to ASM6, some questions
Thanks for that link. I was looking for a SMB3 disassembled.
nesdoug.com -- blog/tutorial on programming for the NES
- Hamtaro126
- Posts: 818
- Joined: Thu Jan 19, 2006 5:08 pm
Re: Converting from NESASM to ASM6, some questions
If you are working on an ASM6 or CC65 version of SMB3DIS:
-Convert Macro Formatting
-Convert .FUNC to something like .DB/.DW, or make it a .MACRO
-Convert all VADDR to .DBYT (CA65 compatibility)
-ASM6: Rename VADDR macro to .DBYT
-CA65: Set .BANK(label) to ^label (or label>>16)
-ASM6: Set .BANK(label) manually
-Set .LOW(label) to <label
-Set .HIGH(label) to >label
-Make sure labels end with a ":" symbol
-Move equate defines (for data) still in some "PRG0xx.ASM" files into a the original include file "SMB3.ASM"
-Remove ".bank"s in "SMB3.ASM", replace with (.Segment "BANKxx") In CA65
-CA65: Create "SMB3.CFG" for bank assembly configuration
-Finish off by testing both packages with thier respective assemblers
-Make ASM6README and CC65README text files, Credit Southbird
-Distribute on RHDN and Github, tell people it is a fork of the original!
-Convert Macro Formatting
-Convert .FUNC to something like .DB/.DW, or make it a .MACRO
-Convert all VADDR to .DBYT (CA65 compatibility)
-ASM6: Rename VADDR macro to .DBYT
-CA65: Set .BANK(label) to ^label (or label>>16)
-ASM6: Set .BANK(label) manually
-Set .LOW(label) to <label
-Set .HIGH(label) to >label
-Make sure labels end with a ":" symbol
-Move equate defines (for data) still in some "PRG0xx.ASM" files into a the original include file "SMB3.ASM"
-Remove ".bank"s in "SMB3.ASM", replace with (.Segment "BANKxx") In CA65
-CA65: Create "SMB3.CFG" for bank assembly configuration
-Finish off by testing both packages with thier respective assemblers
-Make ASM6README and CC65README text files, Credit Southbird
-Distribute on RHDN and Github, tell people it is a fork of the original!
AKA SmilyMZX/AtariHacker.
Re: Converting from NESASM to ASM6, some questions
Thanks for the advice. I've decided to put this work a bit off, but I'll definitely publish it once I get around to it.
Re: Converting from NESASM to ASM6, some questions
Hey, I'm back to working on this. However, I got a question.
Captain Southbird's disassembly in NESASM includes the CHR ROM like this:
I tried googling around for various tools, and found stuff like yy-chr, TileMolester, Tile Layer Pro, etc.
But from what I see, none of them understands this "pcx" format.
Also, there are 128 files in total.
Is there some command line utility I can use to convert pcx -> CHR? Or at least combine some tools to go pcx -> bmp -> CHR?
I really don't wanna do this by hand.
EDIT: I found a clever solution right after posting this!
All I had to do was use the nesasm assembler itself as my pcx -> chr converter. It adds the iNES header, but that's easy for me to cut away.
Captain Southbird's disassembly in NESASM includes the CHR ROM like this:
But from what I can see, ASM6 doesn't have support for pcx files so I have to use the INCBIN directive instead. From what I understand, this means I gotta convert the graphics from this pcx format to raw CHR data that the NES PPU can understand..incchr "CHR/chr000.pcx"
.incchr "CHR/chr001.pcx"
.incchr "CHR/chr002.pcx"
.incchr "CHR/chr003.pcx"
...
I tried googling around for various tools, and found stuff like yy-chr, TileMolester, Tile Layer Pro, etc.
But from what I see, none of them understands this "pcx" format.
Also, there are 128 files in total.
Is there some command line utility I can use to convert pcx -> CHR? Or at least combine some tools to go pcx -> bmp -> CHR?
I really don't wanna do this by hand.
EDIT: I found a clever solution right after posting this!
All I had to do was use the nesasm assembler itself as my pcx -> chr converter. It adds the iNES header, but that's easy for me to cut away.
Re: Converting from NESASM to ASM6, some questions
Can GIMP (GNU Image Manipulation Program) open PCX? Can ImageMagick or netpbm or other popular command-line conversion tools?
pilbmp2nes.py, included in my NES and Super NES project templates, converts any indexed image format recognized by Pillow (Python Imaging Library) to several consoles' CHR formats. This appears to include PCX.
pilbmp2nes.py, included in my NES and Super NES project templates, converts any indexed image format recognized by Pillow (Python Imaging Library) to several consoles' CHR formats. This appears to include PCX.
Re: Converting from NESASM to ASM6, some questions
Just explicitly answering the rhetorical question:tepples wrote:Can ImageMagick or netpbm or other popular command-line conversion tools?
Imagemagick: convert source.sourceformat destination.destinationformat
Netpbm: pcxtoppm
Re: Converting from NESASM to ASM6, some questions
NESASM does have a raw mode to omit the iNES header, so you need not to do that separately, I should think. I don't know whether or not GIMP can open PCX. My "Farbfeld Utilities" does not currently include PCX, but does have the ability to read and write NES/Famicom .CHR format (although it currently does not have the generalized plane map setting of pilbmp2nes.py, but it probably should be in future). Pillow seem not including farbfeld, although if you wanted to implement it, to ensure it is working if the picture is from stdin; otherwise there isn't much point to implement it.
(Free Hero Mesh - FOSS puzzle game engine)
Re: Converting from NESASM to ASM6, some questions
GIMP opens and saves PCX files just fine.