Skip to content

Commit 4c68ea2

Browse files
author
Foerster-H
committed
Moved x16-tokens to a better location
1 parent dbd30c3 commit 4c68ea2

File tree

3 files changed

+118
-109
lines changed

3 files changed

+118
-109
lines changed

dist/basicv2.jar

1.38 KB
Binary file not shown.

src/main/java/com/sixtyfour/extensions/x16/X16Extensions.java

Lines changed: 115 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -37,104 +37,129 @@
3737
*/
3838
public class X16Extensions implements BasicExtension {
3939

40-
private final static List<Command> COMMANDS = Collections.unmodifiableList(new ArrayList<Command>() {
41-
private static final long serialVersionUID = 1L;
42-
{
43-
this.add(new Vpoke());
44-
this.add(new Dos());
45-
this.add(new Mon());
46-
this.add(new Vload());
47-
this.add(new Xload());
48-
this.add(new Geos());
49-
this.add(new Old());
50-
this.add(new Screen());
51-
this.add(new Mouse());
52-
this.add(new Pset());
53-
this.add(new Line());
54-
this.add(new Frame());
55-
this.add(new Rect());
56-
this.add(new Char());
57-
}
58-
});
59-
60-
private final static List<Function> FUNCTIONS = Collections.unmodifiableList(new ArrayList<Function>() {
61-
private static final long serialVersionUID = 1L;
62-
{
63-
this.add(new Vpeek());
64-
}
65-
});
66-
67-
private final static List<Variable> VARS = Collections.unmodifiableList(new ArrayList<Variable>() {
68-
private static final long serialVersionUID = 1L;
69-
{
70-
this.add(new Mx());
71-
this.add(new My());
72-
this.add(new Mb());
73-
}
74-
});
75-
76-
@Override
77-
public List<Command> getCommands() {
78-
return COMMANDS;
40+
private final static List<Command> COMMANDS = Collections.unmodifiableList(new ArrayList<Command>() {
41+
private static final long serialVersionUID = 1L;
42+
{
43+
this.add(new Vpoke());
44+
this.add(new Dos());
45+
this.add(new Mon());
46+
this.add(new Vload());
47+
this.add(new Xload());
48+
this.add(new Geos());
49+
this.add(new Old());
50+
this.add(new Screen());
51+
this.add(new Mouse());
52+
this.add(new Pset());
53+
this.add(new Line());
54+
this.add(new Frame());
55+
this.add(new Rect());
56+
this.add(new Char());
7957
}
58+
});
8059

81-
@Override
82-
public List<Function> getFunctions() {
83-
return FUNCTIONS;
60+
private final static List<Function> FUNCTIONS = Collections.unmodifiableList(new ArrayList<Function>() {
61+
private static final long serialVersionUID = 1L;
62+
{
63+
this.add(new Vpeek());
8464
}
65+
});
8566

86-
@Override
87-
public void reset(Machine machine) {
88-
//
67+
private final static List<Variable> VARS = Collections.unmodifiableList(new ArrayList<Variable>() {
68+
private static final long serialVersionUID = 1L;
69+
{
70+
this.add(new Mx());
71+
this.add(new My());
72+
this.add(new Mb());
8973
}
74+
});
9075

91-
@Override
92-
public List<String> getAdditionalIncludes() {
93-
return new ArrayList<String>() {
94-
private static final long serialVersionUID = 1L;
95-
{
96-
this.add("x16");
97-
}
98-
};
99-
}
76+
@Override
77+
public List<Command> getCommands() {
78+
return COMMANDS;
79+
}
10080

101-
@Override
102-
public Map<String, Integer> getLabel2Constant() {
103-
return new HashMap<String, Integer>() {
104-
private static final long serialVersionUID = 1L;
105-
{
106-
this.put("VERAREG", Integer.parseInt("9F20", 16));
107-
this.put("VERAHI", Integer.parseInt("9F22", 16));
108-
this.put("VERAMID", Integer.parseInt("9F21", 16));
109-
this.put("VERALO", Integer.parseInt("9F20", 16));
110-
this.put("VERADAT", Integer.parseInt("9F23", 16));
111-
this.put("VERABNK", Integer.parseInt("9F61", 16));
112-
this.put("ROMSELECT", Integer.parseInt("9F60", 16));
113-
}
114-
};
115-
}
81+
@Override
82+
public List<Function> getFunctions() {
83+
return FUNCTIONS;
84+
}
11685

117-
@Override
118-
public List<Variable> getSystemVariables() {
119-
return VARS;
120-
}
86+
@Override
87+
public void reset(Machine machine) {
88+
//
89+
}
12190

122-
@Override
123-
public boolean adjustMemoryConfig(Machine machine, MemoryConfig config) {
124-
if (config.getStringEnd() != -1) {
125-
// if it has been set from the outside, then don't modify it
126-
return false;
127-
}
128-
List<Command> coms = machine.getCommandList();
129-
for (Command com : coms) {
130-
// GEOS graphics commands write into BASIC memory (at least in r34). So we have
131-
// to limit it here.
132-
if (com.isCommand("LINE") || com.isCommand("PSET") || com.isCommand("CHAR") || com.isCommand("RECT")
133-
|| com.isCommand("FRAME")) {
134-
config.setStringEnd(0x8000);
135-
return true;
136-
}
137-
}
138-
return false;
91+
@Override
92+
public List<String> getAdditionalIncludes() {
93+
return new ArrayList<String>() {
94+
private static final long serialVersionUID = 1L;
95+
{
96+
this.add("x16");
97+
}
98+
};
99+
}
100+
101+
@Override
102+
public Map<String, Integer> getLabel2Constant() {
103+
return new HashMap<String, Integer>() {
104+
private static final long serialVersionUID = 1L;
105+
{
106+
this.put("VERAREG", Integer.parseInt("9F20", 16));
107+
this.put("VERAHI", Integer.parseInt("9F22", 16));
108+
this.put("VERAMID", Integer.parseInt("9F21", 16));
109+
this.put("VERALO", Integer.parseInt("9F20", 16));
110+
this.put("VERADAT", Integer.parseInt("9F23", 16));
111+
this.put("VERABNK", Integer.parseInt("9F61", 16));
112+
this.put("ROMSELECT", Integer.parseInt("9F60", 16));
113+
}
114+
};
115+
}
116+
117+
@Override
118+
public List<Variable> getSystemVariables() {
119+
return VARS;
120+
}
121+
122+
@Override
123+
public boolean adjustMemoryConfig(Machine machine, MemoryConfig config) {
124+
if (config.getStringEnd() != -1) {
125+
// if it has been set from the outside, then don't modify it
126+
return false;
139127
}
128+
List<Command> coms = machine.getCommandList();
129+
for (Command com : coms) {
130+
// GEOS graphics commands write into BASIC memory (at least in r34).
131+
// So we have
132+
// to limit it here.
133+
if (com.isCommand("LINE") || com.isCommand("PSET") || com.isCommand("CHAR") || com.isCommand("RECT")
134+
|| com.isCommand("FRAME")) {
135+
config.setStringEnd(0x8000);
136+
return true;
137+
}
138+
}
139+
return false;
140+
}
141+
142+
public static Map<Integer, String> getTokens() {
143+
return new HashMap<Integer, String>() {
144+
private static final long serialVersionUID = 1L;
145+
{
146+
this.put(0xCE86, "SCREEN");
147+
this.put(0xCE87, "PSET");
148+
this.put(0xCE8A, "RECT");
149+
this.put(0xCE88, "LINE");
150+
this.put(0xCE89, "FRAME");
151+
this.put(0xCE8B, "CHAR");
152+
this.put(0xCE8C, "MOUSE");
153+
this.put(0xCE8E, "MX");
154+
this.put(0xCE8F, "MY");
155+
this.put(0xCE90, "MB");
156+
this.put(0xCE84, "VPOKE");
157+
this.put(0xCE8D, "VPEEK");
158+
this.put(0xCE81, "DOS");
159+
this.put(0xCE80, "MON");
160+
this.put(0xCE82, "OLD");
161+
this.put(0xCE83, "GEOS");
162+
}
163+
};
164+
}
140165
}

src/main/java/com/sixtyfour/parser/cbmnative/UnTokenizer.java

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.Locale;
77
import java.util.Map;
88

9+
import com.sixtyfour.extensions.x16.X16Extensions;
910
import com.sixtyfour.parser.assembly.ControlCodes;
1011

1112
/**
@@ -96,25 +97,8 @@ public class UnTokenizer {
9697
this.put(202, "MID$");
9798
this.put(203, "GO");
9899

99-
// X16-Extensions go here...this isn't really a good solution, it
100-
// would be better to make the extension itself fill this, but
101-
// I can't be bothered right now...
102-
this.put(0xCE86, "SCREEN");
103-
this.put(0xCE87, "PSET");
104-
this.put(0xCE8A, "RECT");
105-
this.put(0xCE88, "LINE");
106-
this.put(0xCE89, "FRAME");
107-
this.put(0xCE8B, "CHAR");
108-
this.put(0xCE8C, "MOUSE");
109-
this.put(0xCE8E, "MX");
110-
this.put(0xCE8F, "MY");
111-
this.put(0xCE90, "MB");
112-
this.put(0xCE84, "VPOKE");
113-
this.put(0xCE8D, "VPEEK");
114-
this.put(0xCE81, "DOS");
115-
this.put(0xCE80, "MON");
116-
this.put(0xCE82, "OLD");
117-
this.put(0xCE83, "GEOS");
100+
// Add X16-Tokens to the mix...
101+
this.putAll(X16Extensions.getTokens());
118102
}
119103
};
120104

0 commit comments

Comments
 (0)