[cc65] How to properly use a .union

From: Payton Byrd <plbyrd1gmail.com>
Date: 2013-01-22 06:30:21
Hello,

I have a scenario where I want to be able to define a font in a file and
then overlay a struct on top of the loaded file such that I can access the
values of the file as struct values.  To that end I've created the
following code, which compiles:

.struct font
	Baseline	.byte
	TotalWidth	.word
	Height		.byte
	IndexPtr	.word
	FontDataPtr	.word
.endstruct

.union Ormand
	Font .tag font

.endunion

fontRowLength = _ormand+font::TotalWidth
fontIndex = _ormand + _ormand+font::IndexPtr
fontData = _ormand + _ormand+font::FontDataPtr

.rodata
_ormand: .tag Ormand
	.incbin "..\res\ormand.geosfont"


The problem I'm having is that the values I retrieve from the
fontRowLength, fontIndex, and fontData variables do not reflect the data in
the file.  What am I doing wrong here?  I've searched google (including the
mailing list) and found no answer.

-- 
Payton Byrd
<http://www.paytonbyrd.com>
<http://it.toolbox.com/blogs/paytonbyrd>

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Jan 22 06:30:57 2013

This archive was generated by hypermail 2.1.8 : 2013-01-22 06:31:01 CET