Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
cahirwpz committed Apr 4, 2023
2 parents f565532 + 88834b8 commit 08c816c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
4 changes: 2 additions & 2 deletions intro/data/intro.sync
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ $293A 5
$2A00 2
$2A02 9 # lifeforms
$2A0E 2
$2912 2
$2916 2
$2A12 2
$2A16 2
$2A18 5
$2A1A 2
$2A1C 5
Expand Down
13 changes: 13 additions & 0 deletions lib/libmisc/sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ void TrackInit(TrackT *track) {
track->type = TRACK_LINEAR;
track->pending = true;

{
short prevFrame = -1;
TrackKeyT *curr;

for (curr = track->data; curr->frame != END_KEY; curr++) {
if (curr->frame < 0)
continue;
if (prevFrame >= 0)
curr->frame += prevFrame;
prevFrame = curr->frame;
}
}

TrackAdvance(track, track->data);
}

Expand Down
18 changes: 15 additions & 3 deletions tools/sync2c/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,27 @@ func parseFrame(token string) (frame int64, err error) {
}
}

if prevFrame >= 0 {
delta := frame - prevFrame
if delta < 0 {
return 0, &parseError{
"frame numbers must be specified in ascending order"}
}
prevFrame = frame
frame = delta
} else {
prevFrame = frame
}

return frame, err
}

func parseValue(token string) (value int64, err error) {
return strconv.ParseInt(token, 0, 16)
}

var prevFrame int64

func parseTrack(tokens []string, track *Track) (err error) {
var frame, value int64

Expand All @@ -117,9 +131,6 @@ func parseTrack(tokens []string, track *Track) (err error) {
if value, err = parseValue(tokens[1]); err != nil {
return err
}
if track.First != nil && track.First.Key > int(frame) {
return &parseError{"frame numbers must be specified in ascending order"}
}

if len(tokens) == 3 && tokens[2][0] == '!' {
typ := tokens[2][1:]
Expand Down Expand Up @@ -179,6 +190,7 @@ func parseSyncFile(path string) []Track {

// Create new track
if tokens[0] == "@track" {
prevFrame = -1
track = &Track{RawName: tokens[1]}
continue
}
Expand Down

0 comments on commit 08c816c

Please sign in to comment.