It is currently Wed Jul 26, 2017 7:38 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Thu Mar 09, 2017 10:53 am 
Offline

Joined: Mon Apr 04, 2016 3:19 am
Posts: 3
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! :D


Top
 Profile  
 
PostPosted: Thu Mar 09, 2017 12:58 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1641
Location: DIGDUG
.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.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Thu Mar 09, 2017 1:44 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 9798
Location: Rio de Janeiro - Brazil
.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.


Top
 Profile  
 
PostPosted: Thu Mar 09, 2017 4:33 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 18674
Location: NE Indiana, USA (NTSC)
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.

My Python script to convert NESASM to ca65, which I used to rearrange PRG ROM of LAN Master and Super PakPak in the first two volumes of Action 53, converts .bank commands to .segment commands.


Top
 Profile  
 
PostPosted: Thu Mar 09, 2017 5:38 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 9798
Location: Rio de Janeiro - Brazil
Yes, in ca65 I obviously use these built-in features. Can't beat ca65 when it comes to stuff like this.


Top
 Profile  
 
PostPosted: Thu Mar 09, 2017 10:45 pm 
Offline
User avatar

Joined: Wed Apr 07, 2010 1:14 am
Posts: 463
Location: Iran
What mapper does it use?
Can you share the source code?


Top
 Profile  
 
PostPosted: Mon Mar 20, 2017 12:34 pm 
Offline

Joined: Mon Apr 04, 2016 3:19 am
Posts: 3
FARID wrote:
What mapper does it use?
Can you share the source code?


The code is captain southbird's dissassembly of SMB3, located here if you are interested in having a look.


Top
 Profile  
 
PostPosted: Mon Mar 20, 2017 2:29 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1641
Location: DIGDUG
Thanks for that link. I was looking for a SMB3 disassembled.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Tue Mar 21, 2017 7:27 pm 
Offline
User avatar

Joined: Thu Jan 19, 2006 5:08 pm
Posts: 743
Location: Shelton, Washington.
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!

_________________
AKA SmilyMZX/AtariHacker.


Top
 Profile  
 
PostPosted: Wed Mar 22, 2017 9:33 am 
Offline

Joined: Mon Apr 04, 2016 3:19 am
Posts: 3
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group