asar
asar copied to clipboard
Add Built in Defines for the Current Time/Date
As a small suggestion, perhaps Asar could have a few built in defines that contain the current time/date that asar began to assemble a file? Besides being an automatic method for assembling an accurate build date in a ROM, it would also be a quality of life improvement for anyone making a patch intended to have randomized elements in a patch each time it's applied. As an example, I have made a patch that acts as a randomizer for Jurassic Park 1, but you have to manually change the seed rather than it automatically changing.
!assembler_time
is now valid in asar2. This feature will not be backported.
and if you want to be really crazy heres a fun macro
macro to_date_internal(time, ...)
!seconds #= <time>
!minutes #= floor(!seconds/60)
!seconds #= !seconds-(!minutes*60)
!hours #= floor(!minutes/60)
!minutes #= !minutes-(!hours*60)
!days #= floor(!hours/24)
!hours #= !hours-(!days*24)
!year #= 1970
!weekday #= 4
!continue #= 1
!month #= 0
while !continue
!is_leap #= !year%4==0&&(!year%100!=0||!year%400==0)
if !days >= select(!is_leap, 366, 365)
!weekday #= !weekday+select(!is_leap, 2, 1)
!days #= !days-select(!is_leap, 366, 365)
if !weekday >= 7
!weekday #= !weekday-7
endif
!year #= !year+1
else
!weekday #= !weekday+!days
!weekday #= !weekday%7
!month #= 0
!continue2 #= 1
while !month < 12 && !continue2
!dim #= <!month>
if !month == 1 && !is_leap
!dim #= !dim+1
endif
if !days >= !dim
!days #= !days-!dim
else
!continue2 #= 0
endif
!month #= !month+1
endwhile
!continue #= 0
endif
endwhile
print "seconds ", dec(!seconds)
print "minutes ", dec(!minutes)
print "hours ", dec(!hours)
print "day ", dec(!days+1)
print "month ", dec(!month)
print "year ", dec(!year)
print "weekday ", dec(!weekday+1)
print ""
endmacro
macro to_date(time)
%to_date_internal(<time>, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
endmacro
%to_date(1)
%to_date(1643664061)
%to_date(!assembler_time)