Skip to content

Commit f11bc48

Browse files
committed
DSL was a bad idea lets just use JS
1 parent a73b604 commit f11bc48

8 files changed

Lines changed: 45 additions & 32 deletions

File tree

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
</div>
55
<br>
66

7-
Flex 2 is a multi-purpose art and mapping editor for the Sega Megadrive. The original Flex was a web app, which gave it several limitations. A full rewrite for desktop opens up the ability to use real project files, as well as various other improvements.
8-
9-
Much inspiration has come from the tools SonMapEd, SpritePlotter, and SonikSprite.
7+
Flex 2 is a multi-purpose sprite editor for the Sega Megadrive
108

119
# [download](https://github.com/kirjavascript/Flex2/releases)
1210

TODO

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ checkbox
2121
buffer is deprecated on save
2222
==
2323
CUSTOM FORMATS
24-
parser combinators
2524
specify mapping definition files or presets
2625
disable optimizations
2726
==

app/components/art/tile.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { Component } from 'react';
22
import { environment } from '#store/environment';
33
import { observer } from 'mobx-react';
4-
import SVARS from '!!sass-variables-loader!#styles/variables.scss';
54

65
@observer
76
export class Tile extends Component {

app/formats/lang/docs.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,25 @@ top left right down TLRD
2828
// (offset #$0) in File menu default
2929

3030
; sonic 1 mapping
31-
(header dc.b)
31+
(offset-table dc.b)
3232
(mapping TTTTTTTT 0000 WW HH P CC Y X AAAAAAAAAAA LLLLLLLL)
3333

34-
; TODO - two player data
34+
; sonic 2 mapping
3535

3636
; sonic 1 dplc
3737
(offset-table db.b)
38+
(dplc-header LLLL)
3839
(dplc NNNN AAAA AAAA AAAA)
3940

4041
; sonic 2/3&k dplc
4142
(offset-table dc.w)
42-
(dplc (length dc.w) (def NNNN AAAA AAAA AAAA))
43+
(dplc-header LLLLLLLL)
44+
(dplc NNNN AAAA AAAA AAAA)
4345

4446
; sonic 2/3&k non-player dplc
4547
(offset-table dc.w)
46-
(dplc (sub.w #$1 (length dc.w)) (def AAAA AAAA AAAA NNNN))
48+
(dplc-header (sub #1 LLLL))
49+
(dplc AAAA AAAA AAAA NNNN)
4750

4851
(loop (length) (dplc XXXX))
4952

app/formats/lang/output.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { environment } from '#store/environment';
2+
3+
// BIN/ASM

app/formats/lang/parse.js

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,8 @@ const whitespace = rawWhitespace.map(() => whitespaceSymbol);
2929
const parser = recursiveParser(() => many(choice ([
3030
whitespace,
3131
comment,
32-
// sexpr,
33-
// parseNumber,
34-
// parseBool,
35-
// parseNull,
36-
// parseString,
37-
// parseArray,
38-
// parseObject,
39-
// parseString,
4032
info,
4133
dplc,
42-
add,
4334
]))).map(items => items.filter(d => d !== whitespaceSymbol));
4435

4536
const param = (param) => composeParsers([param, whitespace]);
@@ -76,8 +67,6 @@ const number = choice([
7667
]).map(([, hex]) => +`0x${hex}`),
7768
]);
7869

79-
// spread
80-
8170
const tokenList = {
8271
'T': 'top',
8372
'L': 'left',
@@ -103,7 +92,7 @@ const definition = recursiveParser(() => many(choice([
10392
reverse,
10493
])));
10594

106-
// operation
95+
10796

10897
const add = sexpr(() => [
10998
str('add'),
@@ -121,20 +110,20 @@ const dplc = sexpr(() => [
121110
sepBy(whitespace)(definition),
122111
]).map(([, expr]) => ({ type: 'dplc', expr }));
123112

113+
// definition list
114+
// operation
115+
// size
124116

125117

126118

127119

128-
// ASM & binary out first
120+
// ASM & binary out first (tedmediate format)
121+
//
122+
// read / write
123+
//
129124
// be able to parse from bits to byte / word / long
130125
// then do operations
131126
// definition
132-
// add sub reverse
133-
134-
// const join = seperator => array => array.join(seperator);
135-
// const escapedQuote = sequenceOf ([ str ('\\'), anyOfString (`"'`) ]).map(x => x.join(''));
136-
137-
138127

139128
// const parseString = sequenceOf([
140129
// char('"'),
@@ -143,9 +132,12 @@ const dplc = sexpr(() => [
143132
// ]).map(([,x]) => ({string:x}));
144133

145134
const input = `
146-
( info ) ; this is a comment
147-
( dplc YXYA (reverse (add #$1 AAA)))
148-
( dplc AAAA AAAA (add #3 AAA) )
135+
(offset-table dc.b)
136+
(mapping-header LLLL)
137+
(mapping TTTTTTTT 0000 WW HH P CC Y X AAAAAAAAAAA LLLLLLLL)
138+
;(info) ; this is a comment
139+
;( dplc YXYA (reverse (add #$1 AAA)))
140+
;( dplc AAAA AAAA (add #3 AAA) )
149141
`;
150142

151143
// whitespace symbol

app/formats/scripts/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// arbitrary code warning
2+
3+
info();
4+
offsetTable(dc.b);
5+
mappingHeader(() => byte(Symbol('length')))
6+
mapping((sprite, i) => [
7+
byte(sprite.top),
8+
nybble(0),
9+
bits(2, sprite.width - 1),
10+
bits(2, sprite.height - 1),
11+
bits(1, sprite.priority),
12+
bits(2, sprite.palette),
13+
bits(1, sprite.yflip),
14+
bits(1, sprite.xflip),
15+
bits(11, sprite.offset),
16+
word(sprite.left),
17+
]);
18+
19+
// need an external scrtipts folder copied to the root on bundle

app/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ document.addEventListener('drop', (e) => {
2525
}, false);
2626

2727
console.log('todo: remove');
28-
require('#formats/lang/parse');
28+
require('#formats/scripts/index.js');

0 commit comments

Comments
 (0)