asar icon indicating copy to clipboard operation
asar copied to clipboard

SPC block management

Open p4plus2 opened this issue 4 years ago • 0 comments
trafficstars

Currently we have arch spc700-inline but this feature is pretty crusty and basically a giant hack. As part of the deprecation project I would like to create a better alternative.

Design goals:

  1. Concise syntax that indicates a start and end segment
  2. Support multiple engine types
  3. In a perfect world, allowing custom formatting

So taking these goals in mind solving the first goal is trivial if we start with

spcblock $0500
;code
endspcblock

This is at least consistent with other asar features in naming and works well to identify each block.

Now to support multiple engines we can extend it to something like

spcblock $0500 nspc 
;code
endspcblock

For the initial iteration we can simply support npc, others can be added over time easy enough.

But making custom formats isn't entirely trivial. my proposal is as follows

spcblock $0500 custom my_format_macro
;code
endspcblock

macro my_format_macro(size, aram_dest, ...)
	dw size
	dw aram_dest
	!a = 0
	while !a < sizeof(...)
		db <!a>
		!a #= !a+1
	endwhile
endmacro

The logic being that we can assemble a block as if it was norom (since these aram blocks are position independent anyways), then pass the size of data, requested dest, and a byte array to a variadic macro. This is a pretty wild idea, but it allows one to transform the spc data for any sort of upload format they need.

This issue was sort of just typed as ideas and thoughts came to mine, so feel free to shred this apart now.

p4plus2 avatar Mar 30 '21 12:03 p4plus2