It is currently Wed Dec 13, 2017 1:37 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Sun Sep 18, 2016 10:34 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
I wrote a few more macros, for the purpose of creating labels for pre-processed tables that already have the data arranged as columns:

Code:
   .macro StartTable _Label0, _Label1, _Label2, _Label3, _Label4, _Label5, _Label6, _Label7, _Label8, _Label9, _Label10, _Label11, _Label12, _Label13, _Label14, _Label15
      CreateTableLabels *, (:+ - *) / .paramcount, _Label0, _Label1, _Label2, _Label3, _Label4, _Label5, _Label6, _Label7, _Label8, _Label9, _Label10, _Label11, _Label12, _Label13, _Label14, _Label15
   .endmacro

   .macro CreateTableLabels _Address, _RowCount, _Label0, _Label1, _Label2, _Label3, _Label4, _Label5, _Label6, _Label7, _Label8, _Label9, _Label10, _Label11, _Label12, _Label13, _Label14, _Label15
      .ifnblank _Label0
         .ident(.string(_Label0)) := _Address
         CreateTableLabels _Address + _RowCount, _RowCount, _Label1, _Label2, _Label3, _Label4, _Label5, _Label6, _Label7, _Label8, _Label9, _Label10, _Label11, _Label12, _Label13, _Label14, _Label15
      .endif
   .endmacro

   .macro EndTable
      :
   .endmacro


Usage example:

Code:
   StartTable TopLeftTile, TopRightTile, BottomLeftTile, BottomRightTile, Attributes, CollisionType
      .incbin "metatiles.bin"
   EndTable


Due to the way that the size of the data is calculated (anonymous label after the data), you obviously can't use anonymous labels inside the block. This is meant for binary files though (otherwise you could just write the labels normally), so this shouldn't be a problem.


Top
 Profile  
 
PostPosted: Sun Sep 18, 2016 11:40 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5895
Location: Canada
I'm having difficulty understanding the purpose of that example. Does it produce something equivalent to this?
Code:
MetaTiles:
.incbin "metatiles.bin"

TopLeftTile     = MetaTiles + 0
TopRightTile    = MetaTiles + 1
BottomLeftTile  = MetaTiles + 2
BottomRightTile = MetaTiles + 3
Attributes      = MetaTiles + 4
CollisionType   = MetaTiles + 5

Edit: or maybe I was confused by the word "columns", it looks more like:
Code:
MetaTiles:
.incbin "metatiles.bin"
MetaTileStride = (* - MetaTiles) / 6

TopLeftTile     = MetaTiles + (0 * MetaTileStride)
TopRightTile    = MetaTiles + (1 * MetaTileStride)
BottomLeftTile  = MetaTiles + (2 * MetaTileStride)
BottomRightTile = MetaTiles + (3 * MetaTileStride)
Attributes      = MetaTiles + (4 * MetaTileStride)
CollisionType   = MetaTiles + (5 * MetaTileStride)

?


Top
 Profile  
 
PostPosted: Sun Sep 18, 2016 11:47 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
Yup, the second one (although the assignments should be done with ":=" - like in the macro - which makes ca65 treat the symbols as labels).

EDIT: As for my naming conventions, I was trying to base everything around "arrays" at first, but that started to get confusing when it wasn't clear if I was talking about the original array of structures or the resulting arrays within the final structure after transformation, so I decided to go with tables instead, that can be viewed either as rows or as columns. The table is always the same, but with the first set of macros I made you create them with rows, and output them as columns, but the table is still a table, a row is still a row and a column is still a column, unlike happens with arrays of structures when they become structures of arrays.


Top
 Profile  
 
PostPosted: Mon Sep 19, 2016 12:02 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5895
Location: Canada
tokumaru wrote:
Yup, the second one (although the assignments should be done with ":=" - like in the macro - which makes ca65 treat the symbols as labels).

What does that mean? In what situation is = not equivalent to := for a label's assignment?


Top
 Profile  
 
PostPosted: Mon Sep 19, 2016 12:11 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
As far as I know, the only difference is that := will cause the symbol to be written to the label file that the assembler can generate, so I use it whenever I want to simulate a regular label. It's just for debugging purposes.

http://cc65.github.io/doc/ca65.html#ss6.1 wrote:
The label assignment operator is almost identical, but causes the symbol to be marked as a label, so it may be handled differently in a debugger


EDIT: When I said the assignments "should" be done like that, I didn't mean "this is the correct thing to do" but "this would be the exact equivalent to what my macros do".


Top
 Profile  
 
PostPosted: Mon Sep 19, 2016 12:32 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5895
Location: Canada
Okay so the difference seems to be entirely in the .dbg output if you use it. (I don't use them; I guess they're for some C64 debugger called "VICE"?) You get "type=equ" vs "type=lab" on the line describing the label.

Other than that it seems that they do exactly the same thing? I always thought that := was just an alias for = to keep familiarity for people who were used to other assemblers that only have :=.


Top
 Profile  
 
PostPosted: Mon Sep 19, 2016 12:53 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
The file you get when using the -Ln option doesn't include symbols created with = at all. I didn't try the .dbg files. But yeah, functionally it doesn't make any difference. But since the assembler does apparently keep track of whether each symbol is a label or not, I'd rather have things that are in fact labels be marked as such, just in case.


Top
 Profile  
 
PostPosted: Mon Sep 19, 2016 1:06 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5895
Location: Canada
Ah, yes it does seem to omit things from the ln if they're made with =. I had never noticed. (Exporting or importing them will cause them to be emitted anyway, though.)

Looking over my game's code, though, seems to be a good thing, though. The only labels I create with = are aliases of other labels, so I don't really want to be generating duplicate symbols for them anyway, and the rest are just constants for immediate use. So... explains why I never noticed that even though I do use the ln debug output a lot.


Top
 Profile  
 
PostPosted: Mon Sep 19, 2016 1:21 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5895
Location: Canada
It occurs to me that I've wished in the past that there was a way to distinguish constants from labels so that warnings/errors could be generated when using # with a label, or not using # with a constant or literal (and providing explicit cast operators to suppress the warnings).

Since the debug information has this already, it could actually be done. I don't often make # typos, but it would be lovely if they could be made virtually impossible with simple checking. Would be much more useful than the half-baked range checking that got implemented. :P


Top
 Profile  
 
PostPosted: Mon Sep 19, 2016 2:08 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2982
Location: Tampere, Finland
rainwarrior wrote:
Okay so the difference seems to be entirely in the .dbg output if you use it. (I don't use them; I guess they're for some C64 debugger called "VICE"?)

The label file (-Ln) is actually the one that was made for VICE. VICE doesn't support the debug files.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Mon Sep 19, 2016 8:45 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5895
Location: Canada
I should have gone to bed instead of trying to read ca65 documentation at 4 am. :P


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: Bregalad and 4 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