Sonic and Sega Retro Message Board: SpritePiece.asm for AS based disassemblies - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
Page 1 of 1
    Locked
    Locked Forum

SpritePiece.asm for AS based disassemblies Use this for MapMacros support on AS disassemblies

#1 User is offline kram1024 

Posted 27 August 2017 - 01:53 PM

  • Researcher / Hacker
  • Posts: 63
  • Joined: 02-March 04
  • Gender:Male
  • Location:at home, duh
  • Project:Part of the new Team Revamped; Kraminator Special Series disassemblies; Sonic 3 Sound Driver porting guides; KENS 1.5; smps studio; various non-sonic related things
  • Wiki edits:542
I am planning to fork the main git tree for some totally new branches, but until then you can use this:
; macro to declare a mappings table (taken from Sonic 2 Hg disassembly)
mappingsTable macro {INTLABEL}
__LABEL__ label *
current_mappings_table = __LABEL__
    endm

; macro to declare an entry in a mappings table (taken from Sonic 2 Hg disassembly)
mappingsTableEntry macro ptr
	dc.ATTRIBUTE ptr-current_mappings_table
    endm

spriteHeader macro {INTLABEL}
__LABEL__ label *
	if SonicMappingsVer=1
	dc.b ((__LABEL___End-__LABEL__-1)/5)
	elseif SonicMappingsVer=2
	dc.w ((__LABEL___End-__LABEL__-2)/8)
	else
	dc.w ((__LABEL___End-__LABEL__-2)/6)
	endif
    endm

spritePiece macro xpos,ypos,width,height,tile,xflip,yflip,pal,pri
	if SonicMappingsVer=1
	dc.b	ypos
	dc.b	(((width-1)&3)<<2)|((height-1)&3)
	dc.b	((pri&1)<<7)|((pal&3)<<5)|((yflip&1)<<4)|((xflip&1)<<3)|((tile&$700)>>8)
	dc.b	tile&$FF
	dc.b	xpos
	elseif SonicMappingsVer=2
	dc.w	((ypos&$FF)<<8)|(((width-1)&3)<<2)|((height-1)&3)
	dc.w	((pri&1)<<15)|((pal&3)<<13)|((yflip&1)<<12)|((xflip&1)<<11)|(tile&$7FF)
	dc.w	((pri&1)<<15)|((pal&3)<<13)|((yflip&1)<<12)|((xflip&1)<<11)|((tile>>1)&$7FF)
	dc.w	xpos
	else
	dc.w	((ypos&$FF)<<8)|(((width-1)&3)<<2)|((height-1)&3)
	dc.w	((pri&1)<<15)|((pal&3)<<13)|((yflip&1)<<12)|((xflip&1)<<11)|(tile&$7FF)
	dc.w	xpos
	endif
	endm

spritePiece2P macro xpos,ypos,width,height,tile,xflip,yflip,pal,pri,tile2,xflip2,yflip2,pal2,pri2
	if SonicMappingsVer=1
	dc.b	ypos
	dc.b	(((width-1)&3)<<2)|((height-1)&3)
	dc.b	((pri&1)<<7)|((pal&3)<<5)|((yflip&1)<<4)|((xflip&1)<<3)|((tile&$700)>>8)
	dc.b	tile&$FF
	dc.b	xpos
	elseif SonicMappingsVer=2
	dc.w	((ypos&$FF)<<8)|(((width-1)&3)<<2)|((height-1)&3)
	dc.w	((pri&1)<<15)|((pal&3)<<13)|((yflip&1)<<12)|((xflip&1)<<11)|(tile&$7FF)
	dc.w	((pri2&1)<<15)|((pal2&3)<<13)|((yflip2&1)<<12)|((xflip2&1)<<11)|(tile2&$7FF)
	dc.w	xpos
	else
	dc.w	((ypos&$FF)<<8)|(((width-1)&3)<<2)|((height-1)&3)
	dc.w	((pri&1)<<15)|((pal&3)<<13)|((yflip&1)<<12)|((xflip&1)<<11)|(tile&$7FF)
	dc.w	xpos
	endif
	endm

dplcHeader macro {INTLABEL}
__LABEL__ label *
	if SonicMappingsVer=1
	dc.b ((__LABEL___End-__LABEL__-1)/2)
	elseif SonicMappingsVer=2
	dc.w ((__LABEL___End-__LABEL__-2)/2)
	else
	dc.w ((__LABEL___End-__LABEL__-4)/2)
	endif
    endm

dplcEntry macro tiles,offset
	if SonicMappingsVer=3
	dc.w	((offset&$FFF)<<4)|((tiles-1)&$F)
	else
	dc.w	(((tiles-1)&$F)<<12)|(offset&$FFF)
	endif
	endm

; I don't know why, but S3K uses Sonic 2's DPLC format for players, and its own for everything else
; So to avoid having to set and reset SonicMappingsVer I'll just make special macros
s3kPlayerDplcHeader macro {INTLABEL}
__LABEL__ label *
	dc.w ((__LABEL___End-__LABEL__-2)/2)
    endm

s3kPlayerDplcEntry macro tiles,offset
	dc.w	(((tiles-1)&$F)<<12)|(offset&$FFF)
	endm



just note that the format of macro mappings is unchanged from the asm68k version, this is just for asw based disassemblies only.
This post has been edited by kram1024: 27 August 2017 - 01:57 PM

#2 User is offline MainMemory 

Posted 27 August 2017 - 02:45 PM

  • Every day's the same old thing... Same place, different day...
  • Posts: 3973
  • Joined: 14-August 09
  • Gender:Not Telling
  • Project:SonLVL
  • Wiki edits:1,339
Um. There's already a version of SpritePiece.asm for AS, in fact, it was the original, the ASM68K version was made later. Plus, IIRC my conversion program comes with both files included.

#3 User is offline kram1024 

Posted 27 August 2017 - 04:03 PM

  • Researcher / Hacker
  • Posts: 63
  • Joined: 02-March 04
  • Gender:Male
  • Location:at home, duh
  • Project:Part of the new Team Revamped; Kraminator Special Series disassemblies; Sonic 3 Sound Driver porting guides; KENS 1.5; smps studio; various non-sonic related things
  • Wiki edits:542
Well, the fork is in progress (s1disasm-MapMacrosAS), by the way, thanks for letting me know about that file's existance, I can't believe how identical my version and yours are though, I guess I got the conversion right.

Other branches I intend to add are ProjectSonic1TwoEightAS, MusicMacrosAS, and Unified (All branches as one) for sonic1 disasm, will do similar things for the s2disasm.

MusicMacrosAS will use Flamewing's asm music format btw
This post has been edited by kram1024: 27 August 2017 - 04:08 PM

#4 User is offline MainMemory 

Posted 27 August 2017 - 04:07 PM

  • Every day's the same old thing... Same place, different day...
  • Posts: 3973
  • Joined: 14-August 09
  • Gender:Not Telling
  • Project:SonLVL
  • Wiki edits:1,339
You know, this is going to be an absolute nightmare to maintain.

#5 User is offline kram1024 

Posted 27 August 2017 - 04:22 PM

  • Researcher / Hacker
  • Posts: 63
  • Joined: 02-March 04
  • Gender:Male
  • Location:at home, duh
  • Project:Part of the new Team Revamped; Kraminator Special Series disassemblies; Sonic 3 Sound Driver porting guides; KENS 1.5; smps studio; various non-sonic related things
  • Wiki edits:542

View PostMainMemory, on 27 August 2017 - 04:07 PM, said:

You know, this is going to be an absolute nightmare to maintain.


Not as much as you think. I will just maintain the fork, thus unofficial disassemblies, retro can maintain the official branches on official retro disassemblies. The real nightmare is initial merge, and once that is done, I just pull in upstream changes from official branches, i.e. MapMacrosAS just needs MapMacros changes from upstream and AS changes from upstream, I can use diff patches if needed and merge in .reject lumps if they come up. I have a lot of time on my hands.

As a matter of fact, having these branches in my opinion actually can be helpful, i.e. you want MapMacros but do not have Windows and still want to hack the z80 sound driver too, MapMacrosAS would be perfect for you.
This post has been edited by kram1024: 27 August 2017 - 04:29 PM

#6 User is offline MainMemory 

Posted 27 August 2017 - 04:50 PM

  • Every day's the same old thing... Same place, different day...
  • Posts: 3973
  • Joined: 14-August 09
  • Gender:Not Telling
  • Project:SonLVL
  • Wiki edits:1,339
You are aware that practically nobody uses MapMacros, right?

#7 User is offline kram1024 

Posted 27 August 2017 - 05:22 PM

  • Researcher / Hacker
  • Posts: 63
  • Joined: 02-March 04
  • Gender:Male
  • Location:at home, duh
  • Project:Part of the new Team Revamped; Kraminator Special Series disassemblies; Sonic 3 Sound Driver porting guides; KENS 1.5; smps studio; various non-sonic related things
  • Wiki edits:542

View PostMainMemory, on 27 August 2017 - 04:50 PM, said:

You are aware that practically nobody uses MapMacros, right?


Even still, another issue is corrected by this: some disassemblies use asw and others use asm68k which means syntax issues but if all used as or all used asm68k, no issues, mine will all use asw.

Another I intend to fix later, is symbol name conflicts, i.e. a symbol called one thing in sonic1 disasm, and another in sonic2 disasm. No more mess trying to port an object. Thus your strawman argument is meaningless in this context, besides, if nobody uses the branch, then why does it exist? I say at least enough people use it to warrant its existence and the small number would likely be because it doesn't play nice with a lot of hack projects. On the other hand if a change was made that did make it play a lot more nicely, then it might get used more.

#8 User is offline MainMemory 

Posted 27 August 2017 - 09:04 PM

  • Every day's the same old thing... Same place, different day...
  • Posts: 3973
  • Joined: 14-August 09
  • Gender:Not Telling
  • Project:SonLVL
  • Wiki edits:1,339
It exists because I made it and use it, and nobody is bothered enough by its existence to remove it. If there was a time when programs supported the macros, I would probably petition for the branch to be merged into master, because there wouldn't be any reason not to.

How, exactly, are you going to "fix" symbol name conflicts?

#9 User is offline kram1024 

Posted 27 August 2017 - 09:46 PM

  • Researcher / Hacker
  • Posts: 63
  • Joined: 02-March 04
  • Gender:Male
  • Location:at home, duh
  • Project:Part of the new Team Revamped; Kraminator Special Series disassemblies; Sonic 3 Sound Driver porting guides; KENS 1.5; smps studio; various non-sonic related things
  • Wiki edits:542

View PostMainMemory, on 27 August 2017 - 09:04 PM, said:

It exists because I made it and use it, and nobody is bothered enough by its existence to remove it. If there was a time when programs supported the macros, I would probably petition for the branch to be merged into master, because there wouldn't be any reason not to.

How, exactly, are you going to "fix" symbol name conflicts?


I see, oh and how the conflicts will be fixed is by naming all symbols which point to identical code that serves the same purpose in one disasm, the same thing in the other, oh and by identical, I mean has to be close enough to tell that it is the same sub, function, or method. Alternatively, it can be similar code that works way different but still fulfills the same role, i.e. the sound driver init method.

The result, as long as the function, sub, or, method being requested exists it will work since the name is the same, no more need to hunt around the code, it is either there, or it isn't and needs porting in your hack.

We get rid of the meaningless work so that productivity can go towards more impressive things, such as a new custom boss.

On another note, by your logic, I should drop all but the unified branch since it is everything added except things best done by the end user, though it is simpler if I pull in the AS branch official changes, merge them into the rest, merge other branch changes that don't break any branches or violate naming rules or strict choice of assembler, then merge in everything to unified.
This post has been edited by kram1024: 27 August 2017 - 11:19 PM

#10 User is offline MainMemory 

Posted 28 August 2017 - 12:50 AM

  • Every day's the same old thing... Same place, different day...
  • Posts: 3973
  • Joined: 14-August 09
  • Gender:Not Telling
  • Project:SonLVL
  • Wiki edits:1,339
Okay, which labels are you going to use? The ones from Sonic 1, or the ones from Sonic 2?

Page 1 of 1
    Locked
    Locked Forum

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users