AMS6 Include Across Folders

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
User avatar
Lucradan
Posts: 101
Joined: Wed Sep 21, 2016 12:08 pm

AMS6 Include Across Folders

Post by Lucradan »

I want to better organize my game assets so I placed them into directories. However, I cant seem to get ASM6 to access the files. Any advice?

Here is what I was hoping ASM6 would let me do...

Code: Select all

DAT.TITLE.Background.Tiles:
  incbin "/TILE/TITLE.chr"
DAT.TITLE.Background.Nametable:
  incbin "/TILE/TITLE.nam"
DAT.TITLE.Background.Palette:
  incbin "/TILE/TITLE.pal" 
DAT.TITLE.Sprites.Palette:
  incbin "/TILE/TITLE_SPRITES.pal"  
DAT.TITLE.Sprites.Tiles:
  incbin "/TILE/TITLE_SPRITES.chr"
  
DAT.CUTSCENE1.Background.Tiles:
  incbin "/CUTSCENE1/CUTSCENE1.chr"
DAT.CUTSCENE1.Background.Nametable:
  incbin "/CUTSCENE1/CUTSCENE1.nam"  
DAT.CUTSCENE1.Background.Palette:
  incbin "/CUTSCENE1/CUTSCENE1.pal"  
DAT.CUTSCENE1.Sprites.Palette:
  incbin "/CUTSCENE1/CUTSCENE1_SPRITES.pal"  
DAT.CUTSCENE1.Sprites.Tiles:
  incbin "/CUTSCENE1/CUTSCENE1_SPRITES.chr"

DAT.Scroll.Tiles:
  incbin "/CUTSCENE1/TILES_Scroll.chr" 
  
DAT.Font.Tiles:
  incbin "/FONTS/Font.chr"
User avatar
loopy
Posts: 405
Joined: Sun Sep 19, 2004 10:52 pm
Location: UT

Re: AMS6 Include Across Folders

Post by loopy »

Try removing the first slash, e.g. "TILE/TITLE.chr"
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: AMS6 Include Across Folders

Post by unregistered »

Do what loopy said (he made asm6!! Thank you so much loopy!! :D ) and reverse your slashes. Webpage urls use "/"; but, directory paths use "\", at least in Windows OS, what we use.
(was blessed to figure this out after opening command prompt :mrgreen: :))

Also, my sister created our "nametable" files with .db statements so we must use .incsrc for those. :)
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: AMS6 Include Across Folders

Post by dougeff »

To quote wikipedia...

"Contrary to popular belief, the Windows system API accepts slash, and thus all the above Unix examples should work. But many applications on Windows interpret a slash for other purposes or treat it as an invalid character, and thus require you to enter backslash — notably the cmd.exe shell"

That being said, I think I use forward slashes even on Windows, except in the command line.
nesdoug.com -- blog/tutorial on programming for the NES
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: AMS6 Include Across Folders

Post by Pokun »

I also use normal slashes wherever I can as backslash is a pain to enter (AltGr). I'm pretty sure I use slash in ASM6 include statements without problems.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: AMS6 Include Across Folders

Post by unregistered »

Lucradan, sorry, like dougeff and Pokun said, normal slashes / do work just fine in ASM6. But, after being blessed with discovering that Command Prompt uses backslashes \ and changing all of the normal slashes, for directory paths, to backslashes in our game, its random spastic color flickering (normal/bright/normal) was reduced greatly. :mrgreen: :) However, I forgot that and just checked my code and found a bunch of "\"s and made a mistake. :oops: :(
User avatar
Lucradan
Posts: 101
Joined: Wed Sep 21, 2016 12:08 pm

Re: AMS6 Include Across Folders

Post by Lucradan »

Removing the first slash fixed the problem, thanks.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: AMS6 Include Across Folders

Post by Pokun »

Good to hear.
unregistered wrote:after being blessed with discovering that Command Prompt uses backslashes \ and changing all of the normal slashes, for directory paths, to backslashes in our game, its random spastic color flickering (normal/bright/normal) was reduced greatly. :mrgreen: :) However, I forgot that and just checked my code and found a bunch of "\"s and made a mistake. :oops: :(
The Unix world uses normal slashes in directory paths while AFAIK only DOS/Windows are using backslashes (slash was already used for options to commands instead of a dash like in Unix). Modern programs may accept both though as someone already mentioned, but the command prompt probably don't.
I highly doubt what type of slash you used has anything to do with any glitches in your game unless there's some serious bug in asm6.
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: AMS6 Include Across Folders

Post by Dwedit »

The first slash indicates a rooted path.

So let's say your project directory was C:\development\myproject\source, and you included /data/something.h. The first slash turns the path back to C:\, then it looks in C:\data, which fails.

You can also put a dot before the slash, that will also fix the path.

Forward vs Backslash isn't an issue here, Windows accepts both as long as you aren't at the cmd prompt.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: AMS6 Include Across Folders

Post by tokumaru »

Yeah, the problem is that a path starting with a slash or backslash is relative to the root, in this case, the root of the drive where your project is. If you start the path with a folder's name, then that's relative to the current path.

A single dot means "the current path", which's why it could also have fixed your problem (e.g. incbin "./TILE/TITLE.chr"). If you use two dots, that means "the parent path", which you can use to reference folders that come before the one you're in. For example, if you're currently in "c:\my-name\projects\platformer" you can use "..\..\asm6\asm6.exe" to call "c:\my-name\asm6\asm6.exe", but without using an absolute path, meaning you can even move "my-name" and everything it contains to some other folder/drive and the references will keep working.
Post Reply