Jump to content
IGNORED

Macro Issue


Mikes360

Recommended Posts

Hi Guys,

 

I have created a little macro to pad my graphics with zero bytes and I would like to use it in the following way.

 

Here is the macro:

	MAC ZERO_PAD 
.COUNT SET {1}
	ECHO "### ZERO_PAD ", [.COUNT]d
	REPEAT .COUNT 
		.byte #0
	REPEND
	ENDM

And here is a example of how I would like to use it:

    ZERO_PAD PLAYER_HEIGHT - 5

PlayerStopped
    .byte #%00000000
    .byte #%00000000
    .byte #%00100100
    .byte #%01111110
    .byte #%00101100
    .byte #%00101000
    .byte #%00101000 ;--
    .byte #%00111000
    .byte #%00110000
    .byte #%10110010
    .byte #%01111100
    .byte #%00110000 ;--
    .byte #%00111000
    .byte #%01111000
    .byte #%00111000
    .byte #%00111000
PLAYER_HEIGHT = (* - PlayerStopped)
	echo "PLAYER_HEIGHT = ", [PLAYER_HEIGHT]d

I know the issue is with the fact I am using PLAYER_HEIGHT before it is defined but I though the assembler might be cleaver enough to work this out via multiple passes.

 

Is this something that should work? I know if I use the ZERO_PAD macro after PLAYER_HEIGHT is defined it then works.

 

Thanks,

Mike

 

Link to comment
Share on other sites

Thanks if I add a check in to the macro it won't try again the second time around so it never actually inserts the zeros I have decided to do this a bit more manually with a bit of validation to make sure I don't mess up the tables down the line

;============================================================================== 
;                               R A I L - D A T A
;============================================================================== 

RAIL_START = 80
RAIL_HEIGHT = 23

RailTable2 SUBROUTINE
    ZERO_PAD PLAYFIELD_START - RAIL_START - RAIL_HEIGHT  
.start
    .byte #%00000000
    .byte #%00000010
    .byte #%00000010
    .byte #%00000010
    .byte #%00000010

    .byte #%00000010
    .byte #%00000010
    .byte #%00000010
    .byte #%00000010
    .byte #%00000010

    .byte #%00000010
    .byte #%00000010
    .byte #%00000010
    .byte #%00000010
    .byte #%00000010

    .byte #%00000010
    .byte #%00000010
    .byte #%00000010
    .byte #%00000010
    .byte #%00000010

    .byte #%00000010
    .byte #%00000010
    .byte #%00000010
    ;----- 
    IF (* - .start) != RAIL_HEIGHT
        ECHO "Rail table not the same as its defined height", [(* - .start)]d
        ERR
    ENDIF
    ;-----
    ZERO_PAD RAIL_START
Edited by Mikes360
Link to comment
Share on other sites

Actually I just tired it again and its not what I thought its failing to assemble the code altogether

 

When I try the following

Test 
    ZERO_PAD TEST_HEIGHT - 1
    .byte #%00000010
    .byte #%00000010
    .byte #%00000010
    .byte #%00000010
    .byte #%00000010
TEST_HEIGHT = (* - Test)  

I get this in my output

    116  c20a				   Test
      0  c20a					      ZERO_PAD	TEST_HEIGHT - 1
      1  c20a					      IF	TEST_HEIGHT - 1 > 0
 ### ZERO_PAD  4
      2  c20a					      ECHO	"### ZERO_PAD ", [TEST_HEIGHT - 1]d
      3  c20a		       00 00 00 00	      ds	TEST_HEIGHT - 1, 0
      4  c20e					      ENDIF
    118  c20e		       02		      .byte.b	#%00000010
    119  c20f		       02		      .byte.b	#%00000010
    120  c210		       02		      .byte.b	#%00000010
    121  c211		       02		      .byte.b	#%00000010
    122  c212		       02		      .byte.b	#%00000010
Graphics.asm (123): error: EQU: Value mismatch.
    123  c212		       00 09	   TEST_HEIGHT =	(* - Test)
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...