Jump to content
IGNORED

Updating BOUNDARY in macro.h


DEBRO

Recommended Posts

Hi there,

 

I'd like to make a suggestion for an update to the BOUNDARY macro.

 

The comments read to place data to a certain position inside a page however it doesn't work for me.

 

As an example, I'm reverse engineering Barnstorming. There is a place in the code (i.e. $F3EF) where I need to push code 3 bytes into the next page. I send BOUNDARY 3 to the macro and it pushes to $F3F0 instead of $F403 because the mod of $F0 and 0 is 0.

 

I'd like to define a constant for the filler byte as well. Currently this macro defaults to a filler byte of $00 but as I'm discovering with Barnstorming, you may want to define your filler byte differently. Barnstorming fills empty bytes with $EA.

 

I'd also like to add a global variable (i.e FREE_BYTES) so it can be accumulated through out the assembly process. This will allow you to print out the free bytes remaining in the ROM or BANK (i.e. echo "***", (FREE_BYTES)d, "BYTES OF ROM FREE").

 

Below is my proposed update. Please let me know your thoughts.

;-------------------------------------------------------
; BOUNDARY byte#
; Original author: Dennis Debro (borrowed from Bob Smith / Thomas Jentzsch)
;
; Push data to a certain position inside a page and keep count of how
; many free bytes the programmer will have.
;
; eg: BOUNDARY 5    ; position at byte #5 in page

   IFNCONST BOUNDARY_FILL_BYTE

BOUNDARY_FILL_BYTE	= $00

   ENDIF

.FREE_BYTES SET 0
FREE_BYTES SET 0
.BYTES_TO_SKIP SET 0

   MAC BOUNDARY
      IF <. > {1}

.BYTES_TO_SKIP SET (256 - <.) + {1}

      ELSE

.BYTES_TO_SKIP SET (256 - <.) - (256 - {1})

      ENDIF

      REPEAT .BYTES_TO_SKIP

.FREE_BYTES SET .FREE_BYTES + 1
FREE_BYTES SET FREE_BYTES + 1

         .byte BOUNDARY_FILL_BYTE

      REPEND

   ENDM

  • Like 1
Link to comment
Share on other sites

If you want to define a fill parameter, I would prefer two versions of the macro, one with and one without boundary fill byte as parameter.

 

Also we could incorporate my free space macros:

ECHO_FREE SET 1     ; 1 = echo free space enabled
FREE_TOTAL SET 0    ; use only once

  MAC OUT_FREE
FREE_GAP$ SET - .
    {1} {2}
FREE_GAP$  SET FREE_GAP$  + .
FREE_BANK  SET FREE_BANK  + FREE_GAP$ ; has to be set to 0 for each bank
FREE_TOTAL SET FREE_TOTAL + FREE_GAP$
   IF ECHO_FREE && FREE_GAP$ > 0
    ECHO "@", ., ": Gap:", [FREE_GAP$]d, "; Bank:", [FREE_BANK]d, "; Total:", [FREE_TOTAL]d, ";", {3}, {2}, {4}
   ENDIF
  ENDM

  MAC ALIGN_FREE_LBL
    LIST OFF
    OUT_FREE ALIGN, {1}, "ALIGN", {2}
    LIST ON
  ENDM

  MAC ALIGN_FREE
    LIST OFF
    ALIGN_FREE_LBL {1}, ""
  ENDM

  MAC COND_ALIGN_FREE_LBL ; space required, alignment, "label"
    LIST OFF
   IF (>(. + {1} - 1)) > (>.)
    ALIGN_FREE_LBL {2}, {3}
   ENDIF
    LIST ON
  ENDM

  MAC COND_ALIGN_FREE ; space required, alignment
    LIST OFF
    COND_ALIGN_FREE_LBL {1}, {2}, ""
  ENDM

  MAC RORG_FREE_LBL
    LIST OFF
    OUT_FREE RORG, {1}, "RORG", {2}
    LIST ON
  ENDM

  MAC RORG_FREE
    LIST OFF
    RORG_FREE_LBL {1}, ""
  ENDM
Link to comment
Share on other sites

Looking at that BOUNDARY macro makes you wish for an assembler/linker that takes care of code and data placement for you, observing such constraints as "align 256 offset PLAYER_HEIGHT" or "must not cross a page boundary but otherwise can be anywhere" or "this conditional branch must cross a page boundary", without having to fiddle around manually, doesn't it? ;)

 

(Almost there...)

Link to comment
Share on other sites

  • 1 month later...

Not too much activity with this one. I guess I maybe the only one using the BOUNDARY macro.

 

I like your suggestion of making another one and passing in the fill parameter. I got no response (though I hadn't followed up either) so I didn't place it in macro.h. Instead I'll just use it in the code I use.

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...