1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-26 18:29:54 +00:00

Changed pointer and directive parsing to distinguish directives applied to pointers and directives applied to variables. Fixed all example-code to reflect this. Closes #271

This commit is contained in:
jespergravgaard 2020-03-29 20:22:16 +02:00
parent 838b8f4d26
commit a579ab491a
432 changed files with 2341 additions and 908 deletions

View File

@ -61,6 +61,8 @@ public class VariableBuilder {
variable.setVolatile(this.isVolatile()); variable.setVolatile(this.isVolatile());
variable.setExport(this.isExport()); variable.setExport(this.isExport());
variable.setPermanent(this.isPermanent()); variable.setPermanent(this.isPermanent());
variable.setToNoModify(this.isToNoModify());
variable.setToVolatile(this.isToVolatile());
variable.setOptimize(this.isOptimize()); variable.setOptimize(this.isOptimize());
variable.setRegister(this.getRegister()); variable.setRegister(this.getRegister());
if(variable.getRegister() instanceof Registers.RegisterMainMem) { if(variable.getRegister() instanceof Registers.RegisterMainMem) {

View File

@ -68,6 +68,12 @@ public class Variable implements Symbol {
/** Specifies that the variable must always live in memory to be available for any multi-threaded accees (eg. in interrupts). (volatile keyword) [Only Variables] */ /** Specifies that the variable must always live in memory to be available for any multi-threaded accees (eg. in interrupts). (volatile keyword) [Only Variables] */
private boolean isVolatile; private boolean isVolatile;
/** Specifies that the variable points to a volatile. (volatile* keyword) */
private boolean isToVolatile;
/** Specifies that the variable points to a a nomodify. (const* keyword) */
private boolean isToNoModify;
/** Specifies that the variable must always be added to the output ASM even if it is never used anywhere. (export keyword) */ /** Specifies that the variable must always be added to the output ASM even if it is never used anywhere. (export keyword) */
private boolean export; private boolean export;
@ -188,6 +194,8 @@ public class Variable implements Symbol {
version.setNoModify(phiMaster.isNoModify()); version.setNoModify(phiMaster.isNoModify());
version.setRegister(phiMaster.getRegister()); version.setRegister(phiMaster.getRegister());
version.setVolatile(phiMaster.isVolatile()); version.setVolatile(phiMaster.isVolatile());
version.setToNoModify(phiMaster.isToNoModify());
version.setToVolatile(phiMaster.isToVolatile());
version.setPermanent(phiMaster.isPermanent()); version.setPermanent(phiMaster.isPermanent());
version.setExport(phiMaster.isExport()); version.setExport(phiMaster.isExport());
version.setComments(phiMaster.getComments()); version.setComments(phiMaster.getComments());
@ -232,6 +240,8 @@ public class Variable implements Symbol {
constVar.setNoModify(variable.isNoModify()); constVar.setNoModify(variable.isNoModify());
constVar.setRegister(variable.getRegister()); constVar.setRegister(variable.getRegister());
constVar.setVolatile(variable.isVolatile()); constVar.setVolatile(variable.isVolatile());
constVar.setToNoModify(variable.isToNoModify());
constVar.setToVolatile(variable.isToVolatile());
constVar.setPermanent(variable.isPermanent()); constVar.setPermanent(variable.isPermanent());
constVar.setExport(variable.isExport()); constVar.setExport(variable.isExport());
constVar.setComments(variable.getComments()); constVar.setComments(variable.getComments());
@ -252,6 +262,8 @@ public class Variable implements Symbol {
copy.setNoModify(original.isNoModify()); copy.setNoModify(original.isNoModify());
copy.setPermanent(original.isPermanent()); copy.setPermanent(original.isPermanent());
copy.setVolatile(original.isVolatile()); copy.setVolatile(original.isVolatile());
copy.setToNoModify(original.isToNoModify());
copy.setToVolatile(original.isToVolatile());
copy.setExport(original.isExport()); copy.setExport(original.isExport());
copy.setRegister(original.getRegister()); copy.setRegister(original.getRegister());
copy.setComments(original.getComments()); copy.setComments(original.getComments());
@ -282,6 +294,8 @@ public class Variable implements Symbol {
} }
memberVariable.setVolatile(structVar.isVolatile()); memberVariable.setVolatile(structVar.isVolatile());
memberVariable.setNoModify(structVar.isNoModify()); memberVariable.setNoModify(structVar.isNoModify());
memberVariable.setToNoModify(structVar.isToNoModify());
memberVariable.setToVolatile(structVar.isToVolatile());
memberVariable.setExport(structVar.isExport()); memberVariable.setExport(structVar.isExport());
memberVariable.setPermanent(structVar.isPermanent()); memberVariable.setPermanent(structVar.isPermanent());
return memberVariable; return memberVariable;
@ -479,14 +493,6 @@ public class Variable implements Symbol {
this.noModify = noModify; this.noModify = noModify;
} }
public boolean isPermanent() {
return permanent;
}
public void setPermanent(boolean permanent) {
this.permanent = permanent;
}
public boolean isVolatile() { public boolean isVolatile() {
return isVolatile; return isVolatile;
} }
@ -495,6 +501,30 @@ public class Variable implements Symbol {
this.isVolatile = aVolatile; this.isVolatile = aVolatile;
} }
public boolean isToNoModify() {
return isToNoModify;
}
public void setToNoModify(boolean toNoModify) {
isToNoModify = toNoModify;
}
public boolean isToVolatile() {
return isToVolatile;
}
public void setToVolatile(boolean toVolatile) {
isToVolatile = toVolatile;
}
public boolean isPermanent() {
return permanent;
}
public void setPermanent(boolean permanent) {
this.permanent = permanent;
}
public boolean isExport() { public boolean isExport() {
return export; return export;
} }
@ -582,6 +612,10 @@ public class Variable implements Symbol {
return new StringBuilder() return new StringBuilder()
.append("(") .append("(")
.append(isKindConstant() ? "const " : "") .append(isKindConstant() ? "const " : "")
//.append(isNoModify() ? "nomodify " : "")
//.append(isVolatile() ? "volatile " : "")
//.append(isToNoModify() ? "to_nomodify " : "")
//.append(isToVolatile() ? "to_volatile " : "")
.append(getType().getTypeName()) .append(getType().getTypeName())
.append(isKindIntermediate() ? "~" : "") .append(isKindIntermediate() ? "~" : "")
.append(") ") .append(") ")

View File

@ -536,119 +536,207 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
/** State specifying that we are currently populating struct members. */ /** State specifying that we are currently populating struct members. */
private boolean structMember = false; private boolean structMember = false;
/** Holds the declared type (type level). */ /** Holds directives that are not part of the type-spec (all other than const & volatile) when descending into a Variable Declaration. (type level) */
private SymbolType type = null; private List<Directive> declDirectives = null;
/** Holds the information about whether the declared variable is an array and the size of the array if it is (type level). */
private ArraySpec arraySpec;
/** Holds the declared directives when descending into a Variable Declaration. (type level) */
private List<Directive> directives = null;
/** Holds the declared comments when descending into a Variable Declaration. (type level) */ /** Holds the declared comments when descending into a Variable Declaration. (type level) */
private List<Comment> comments = null; private List<Comment> declComments = null;
/** The declared type (type level) */
/** Holds the type when diving into a single variable. (variable level) */ private VariableDeclType declType;
private SymbolType varType = null; /** The declared type (variable level) */
/** Holds the array information for a single variable. (variable level) */ private VariableDeclType varDeclType;
private ArraySpec varArraySpec;
/** Holds the declared directives for a single variable. (variable level) */
private List<Directive> varDirectives = null;
/** /**
* Exits the type layer (clears everyting except struct information) * Exits the type layer (clears everything except struct information)
*/ */
void exitType() { void exitType() {
exitVar(); this.declDirectives = null;
this.type = null; this.declComments = null;
this.directives = null; this.declType = null;
this.arraySpec = null; this.varDeclType = null;
this.comments = null;
} }
/** /**
* Exits the variable layer (clears variable information) * Exits the variable layer (clears variable information)
*/ */
void exitVar() { void exitVar() {
this.varType = null; this.varDeclType = null;
this.varArraySpec = null; }
this.varDirectives = null;
/** The declared type of a variable. Combines SymbolType, type directives (const, volatile) and ArraySpec. It holds advanced type information like <p><code>char volatile * const * [42]</code> */
static class VariableDeclType {
/** The type. */
SymbolType type;
/** The array specification (non-null if it is an array, also holds size) */
ArraySpec arraySpec;
/** Const / Volatile Directives if applied to the type */
List<Directive> typeDirectives;
/** If the type is SymbolTypePointer this holds the declaration type of the elements. */
VariableDeclType elementDeclType;
public VariableDeclType(SymbolType type) {
this.type = type;
this.typeDirectives = new ArrayList<>();
}
public SymbolType getType() {
return type;
}
public ArraySpec getArraySpec() {
return arraySpec;
}
public List<Directive> getTypeDirectives() {
return typeDirectives;
}
public void setTypeDirectives(List<Directive> directives) {
this.typeDirectives = directives;
}
public void setElementDeclType(VariableDeclType elementDeclType) {
this.elementDeclType = elementDeclType;
}
public void setArraySpec(ArraySpec arraySpec) {
this.arraySpec = arraySpec;
}
public VariableDeclType getElementDeclType() {
return elementDeclType;
}
}
VariableDeclType getEffectiveDeclType() {
return varDeclType != null ? varDeclType : declType;
} }
SymbolType getEffectiveType() { SymbolType getEffectiveType() {
return varType != null ? varType : type; if(varDeclType != null)
return varDeclType.getType();
if(declType != null)
return declType.getType();
return null;
} }
ArraySpec getEffectiveArraySpec() { ArraySpec getEffectiveArraySpec() {
return varArraySpec != null ? varArraySpec : arraySpec; return varDeclType != null ? varDeclType.getArraySpec() : declType.getArraySpec();
}
/**
* Set type-level directives. Splits directives into type-directives (const, volatile) and general directives (all other).
*
* @param directives The directives
*/
void setDeclDirectives(List<Directive> directives) {
this.declDirectives = new ArrayList<>();
for(Directive directive : directives) {
if(directive instanceof Directive.Const || directive instanceof Directive.Volatile) {
// Type directive
this.declType.getTypeDirectives().add(directive);
} else {
// general directive
this.declDirectives.add(directive);
}
}
} }
List<Directive> getEffectiveDirectives() { List<Directive> getEffectiveDirectives() {
final ArrayList<Directive> dirs = new ArrayList<>(); final ArrayList<Directive> dirs = new ArrayList<>();
if(directives != null) // Add all general directives
dirs.addAll(directives); dirs.addAll(declDirectives);
if(varDirectives != null) // Add type-directives
dirs.addAll(varDirectives); final VariableDeclType effectiveDeclType = getEffectiveDeclType();
dirs.addAll(effectiveDeclType.getTypeDirectives());
// Convert element directives
final VariableDeclType elementDeclType = effectiveDeclType.getElementDeclType();
if(elementDeclType != null) {
for(Directive elementTypeDirective : elementDeclType.getTypeDirectives()) {
if(elementTypeDirective instanceof Directive.Const) {
dirs.add(new Directive.ToConst());
} else if(elementTypeDirective instanceof Directive.Volatile) {
dirs.add(new Directive.ToVolatile());
}
}
// Produce error on any deeper directives
VariableDeclType deepDeclType = elementDeclType.getElementDeclType();
while(deepDeclType != null) {
if(!deepDeclType.getTypeDirectives().isEmpty()) {
throw new CompileError("Deep const/volatile not supported.");
}
deepDeclType = deepDeclType.getElementDeclType();
}
}
return dirs; return dirs;
} }
public List<Comment> getComments() { public List<Comment> getDeclComments() {
return comments; return declComments;
} }
boolean isStructMember() { boolean isStructMember() {
return structMember; return structMember;
} }
public void setType(SymbolType type) { public VariableDeclType getDeclType() {
this.type = type; return declType;
} }
void setArraySpec(ArraySpec arraySpec) { public void setDeclType(SymbolType type) {
this.arraySpec = arraySpec; this.declType = new VariableDeclType(type);
} }
void setDirectives(List<Directive> directives) { public void setVarDeclType(VariableDeclType varDeclType) {
this.directives = directives; this.varDeclType = varDeclType;
} }
public void setComments(List<Comment> comments) { public VariableDeclType getVarDeclType() {
this.comments = comments; return varDeclType;
}
public void setDeclComments(List<Comment> declComments) {
this.declComments = declComments;
} }
void setStructMember(boolean structMember) { void setStructMember(boolean structMember) {
this.structMember = structMember; this.structMember = structMember;
} }
void setVarArraySpec(ArraySpec varArraySpec) {
this.varArraySpec = varArraySpec;
}
void setVarType(SymbolType varType) {
this.varType = varType;
}
} }
private VariableDeclaration varDecl = new VariableDeclaration(); private VariableDeclaration varDecl = new VariableDeclaration();
@Override @Override
public Object visitDeclPointer(KickCParser.DeclPointerContext ctx) { public Object visitDeclPointer(KickCParser.DeclPointerContext ctx) {
if(!ctx.directive().isEmpty()) { // Detect char * const * x;
throw new InternalError("Not implemented!"); //if(varDecl.getDeclDirectives()!=null && !varDecl.getDeclDirectives().isEmpty()) {
} // throw new CompileError("Pointer directives (const/volatile) not supported between pointers.", new StatementSource(ctx.getParent().getParent()));
varDecl.setVarType(new SymbolTypePointer(varDecl.getEffectiveType())); //};
// Create a var-level declaration type
final VariableDeclaration.VariableDeclType elementDeclType = varDecl.getEffectiveDeclType();
VariableDeclaration.VariableDeclType pointerDeclType = new VariableDeclaration.VariableDeclType(new SymbolTypePointer(elementDeclType.getType()));
pointerDeclType.setElementDeclType(elementDeclType);
final List<Directive> typeDirectives = getDirectives(ctx.directive());
pointerDeclType.setTypeDirectives(typeDirectives);
varDecl.setVarDeclType(pointerDeclType);
return null; return null;
} }
@Override @Override
public Object visitDeclArray(KickCParser.DeclArrayContext ctx) { public Object visitDeclArray(KickCParser.DeclArrayContext ctx) {
// Handle array type declaration by updating the declared type and the array spec // Handle array type declaration by updating the declared type and the array spec
SymbolType elementType = varDecl.getEffectiveType(); ArraySpec arraySpec;
if(ctx.expr() != null) { if(ctx.expr() != null) {
RValue sizeVal = (RValue) visit(ctx.expr()); RValue sizeVal = (RValue) visit(ctx.expr());
varDecl.setVarArraySpec(new ArraySpec((ConstantValue) sizeVal)); arraySpec = new ArraySpec((ConstantValue) sizeVal);
varDecl.setVarType(new SymbolTypePointer(elementType));
} else { } else {
varDecl.setVarArraySpec(new ArraySpec()); arraySpec = new ArraySpec();
varDecl.setVarType(new SymbolTypePointer(elementType));
} }
final VariableDeclaration.VariableDeclType elementDeclType = varDecl.getEffectiveDeclType();
VariableDeclaration.VariableDeclType arrayDeclType = new VariableDeclaration.VariableDeclType(new SymbolTypePointer(elementDeclType.getType()));
arrayDeclType.setElementDeclType(elementDeclType);
arrayDeclType.setArraySpec(arraySpec);
varDecl.setVarDeclType(arrayDeclType);
return null; return null;
} }
@ -662,9 +750,9 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
public Object visitDeclType(KickCParser.DeclTypeContext ctx) { public Object visitDeclType(KickCParser.DeclTypeContext ctx) {
List<KickCParser.DirectiveContext> directive = ctx.directive(); List<KickCParser.DirectiveContext> directive = ctx.directive();
varDecl.exitType(); varDecl.exitType();
varDecl.setType((SymbolType) visit(ctx.type())); varDecl.setDeclType((SymbolType) visit(ctx.type()));
varDecl.setDirectives(getDirectives(directive)); varDecl.setDeclDirectives(getDirectives(directive));
varDecl.setComments(getCommentsSymbol(ctx.getParent())); varDecl.setDeclComments(getCommentsSymbol(ctx.getParent()));
return null; return null;
} }
@ -713,9 +801,9 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
ConstantValue constInitValue = getConstInitValue(initValue, initializer, statementSource); ConstantValue constInitValue = getConstInitValue(initValue, initializer, statementSource);
variable.setInitValue(constInitValue); variable.setInitValue(constInitValue);
// Add comments to constant // Add comments to constant
variable.setComments(ensureUnusedComments(varDecl.getComments())); variable.setComments(ensureUnusedComments(varDecl.getDeclComments()));
} else if(!variable.isKindConstant() && !varDecl.isStructMember()) { } else if(!variable.isKindConstant() && !varDecl.isStructMember()) {
Statement initStmt = new StatementAssignment(variable.getVariableRef(), initValue, true, statementSource, ensureUnusedComments(varDecl.getComments())); Statement initStmt = new StatementAssignment(variable.getVariableRef(), initValue, true, statementSource, ensureUnusedComments(varDecl.getDeclComments()));
sequence.addStatement(initStmt); sequence.addStatement(initStmt);
} }
if(initializer != null) if(initializer != null)
@ -781,7 +869,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
// Set constant value // Set constant value
variable.setInitValue(getConstInitValue(constantArrayKickAsm, null, statementSource)); variable.setInitValue(getConstInitValue(constantArrayKickAsm, null, statementSource));
// Add comments to constant // Add comments to constant
variable.setComments(ensureUnusedComments(varDecl.getComments())); variable.setComments(ensureUnusedComments(varDecl.getDeclComments()));
varDecl.exitVar(); varDecl.exitVar();
return null; return null;
} }
@ -1287,6 +1375,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
throw new CompileError("Error! Loop variable not declared " + varName, statementSource); throw new CompileError("Error! Loop variable not declared " + varName, statementSource);
} }
} }
boolean initialAssignment = (varDecl.getEffectiveType() != null);
varDecl.exitType(); varDecl.exitType();
KickCParser.StmtForContext stmtForCtx = (KickCParser.StmtForContext) ctx.getParent(); KickCParser.StmtForContext stmtForCtx = (KickCParser.StmtForContext) ctx.getParent();
KickCParser.ExprContext rangeFirstCtx = ctx.expr(0); KickCParser.ExprContext rangeFirstCtx = ctx.expr(0);
@ -1298,7 +1387,6 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
if(rangeFirstValue instanceof ConstantInteger) ((ConstantInteger) rangeFirstValue).setType(varType); if(rangeFirstValue instanceof ConstantInteger) ((ConstantInteger) rangeFirstValue).setType(varType);
if(rangeLastValue instanceof ConstantInteger) ((ConstantInteger) rangeLastValue).setType(varType); if(rangeLastValue instanceof ConstantInteger) ((ConstantInteger) rangeLastValue).setType(varType);
} }
boolean initialAssignment = (varDecl.getEffectiveType() != null);
Statement stmtInit = new StatementAssignment((LValue) lValue.getRef(), rangeFirstValue, initialAssignment, statementSource, Comment.NO_COMMENTS); Statement stmtInit = new StatementAssignment((LValue) lValue.getRef(), rangeFirstValue, initialAssignment, statementSource, Comment.NO_COMMENTS);
sequence.addStatement(stmtInit); sequence.addStatement(stmtInit);
// Add label // Add label
@ -1636,13 +1724,14 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
} }
@Override @Override
public Object visitTypeNamedRef(KickCParser.TypeNamedRefContext ctx) { public SymbolType visitTypeNamedRef(KickCParser.TypeNamedRefContext ctx) {
Scope typeDefScope = program.getScope().getTypeDefScope(); Scope typeDefScope = program.getScope().getTypeDefScope();
Variable typeDefVariable = typeDefScope.getVariable(ctx.getText()); Variable typeDefVariable = typeDefScope.getVariable(ctx.getText());
if(typeDefVariable != null) { if(typeDefVariable != null) {
if(typeDefVariable.getArraySpec()!=null) if(typeDefVariable.getArraySpec() != null)
// TODO: Handle typedef array of array correctly // TODO: Handle typedef array of array correctly
varDecl.setArraySpec(typeDefVariable.getArraySpec()); //varDecl.getDeclType().setArraySpec(typeDefVariable.getArraySpec());
throw new InternalError("Typedef with arrays not supported!");
return typeDefVariable.getType(); return typeDefVariable.getType();
} }
throw new CompileError("Unknown type " + ctx.getText(), new StatementSource(ctx)); throw new CompileError("Unknown type " + ctx.getText(), new StatementSource(ctx));
@ -1678,11 +1767,13 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
SymbolType elementType = (SymbolType) visit(ctx.type()); SymbolType elementType = (SymbolType) visit(ctx.type());
if(ctx.expr() != null) { if(ctx.expr() != null) {
RValue sizeVal = (RValue) visit(ctx.expr()); RValue sizeVal = (RValue) visit(ctx.expr());
varDecl.setArraySpec(new ArraySpec((ConstantValue) sizeVal)); //varDecl.getDeclType().setArraySpec(new ArraySpec((ConstantValue) sizeVal));
return new SymbolTypePointer(elementType); //return new SymbolTypePointer(elementType);
throw new InternalError("Array types not supported!");
} else { } else {
varDecl.setArraySpec(new ArraySpec()); //varDecl.getDeclType().setArraySpec(new ArraySpec());
return new SymbolTypePointer(elementType); //return new SymbolTypePointer(elementType);
throw new InternalError("Array types not supported!");
} }
} else { } else {
throw new CompileError("ERROR! Non-standard array declaration. Allow using commandline option -Warraytype", new StatementSource(ctx)); throw new CompileError("ERROR! Non-standard array declaration. Allow using commandline option -Warraytype", new StatementSource(ctx));

View File

@ -3,8 +3,8 @@
// See http://www.pagetable.com/c64rom/c64rom_sc.html // See http://www.pagetable.com/c64rom/c64rom_sc.html
// Zeropage addresses used to hold lo/hi-bytes of addresses of float numbers in MEM // Zeropage addresses used to hold lo/hi-bytes of addresses of float numbers in MEM
const char* memLo = 0xfe; char* const memLo = 0xfe;
const char* memHi = 0xff; char* const memHi = 0xff;
// Prepare MEM pointers for operations using MEM // Prepare MEM pointers for operations using MEM
inline void prepareMEM(unsigned int mem) { inline void prepareMEM(unsigned int mem) {

View File

@ -1,12 +1,12 @@
// Commodore 64 Registers and Constants // Commodore 64 Registers and Constants
// Processor port data direction register // Processor port data direction register
const byte* PROCPORT_DDR = $00; byte* const PROCPORT_DDR = $00;
// Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
const byte PROCPORT_DDR_MEMORY_MASK = %00000111; const byte PROCPORT_DDR_MEMORY_MASK = %00000111;
// Processor Port Register controlling RAM/ROM configuration and the datasette // Processor Port Register controlling RAM/ROM configuration and the datasette
const byte* PROCPORT = $01; byte* const PROCPORT = $01;
// RAM in all three areas $A000, $D000, $E000 // RAM in all three areas $A000, $D000, $E000
const byte PROCPORT_RAM_ALL = %00000000; const byte PROCPORT_RAM_ALL = %00000000;
// RAM in $A000, $E000 I/O in $D000 // RAM in $A000, $E000 I/O in $D000
@ -19,7 +19,7 @@ const byte PROCPORT_KERNEL_IO = %00000110;
const byte PROCPORT_BASIC_KERNEL_IO = %00000111; const byte PROCPORT_BASIC_KERNEL_IO = %00000111;
// The address of the CHARGEN character set // The address of the CHARGEN character set
const byte* CHARGEN = $d000; byte* const CHARGEN = $d000;
// Positions of the border (in sprite positions) // Positions of the border (in sprite positions)
const byte BORDER_XPOS_LEFT=24; const byte BORDER_XPOS_LEFT=24;
@ -30,48 +30,48 @@ const byte BORDER_YPOS_BOTTOM=250;
// The offset of the sprite pointers from the screen start address // The offset of the sprite pointers from the screen start address
const word SPRITE_PTRS = $3f8; const word SPRITE_PTRS = $3f8;
const byte* SPRITES_XPOS = $d000; byte* const SPRITES_XPOS = $d000;
const byte* SPRITES_YPOS = $d001; byte* const SPRITES_YPOS = $d001;
const byte* SPRITES_XMSB = $d010; byte* const SPRITES_XMSB = $d010;
const byte* RASTER = $d012; byte* const RASTER = $d012;
const byte* SPRITES_ENABLE = $d015; byte* const SPRITES_ENABLE = $d015;
const byte* SPRITES_EXPAND_Y = $d017; byte* const SPRITES_EXPAND_Y = $d017;
const byte* SPRITES_PRIORITY = $d01b; byte* const SPRITES_PRIORITY = $d01b;
const byte* SPRITES_MC = $d01c; byte* const SPRITES_MC = $d01c;
const byte* SPRITES_EXPAND_X = $d01d; byte* const SPRITES_EXPAND_X = $d01d;
const byte* BORDERCOL = $d020; byte* const BORDERCOL = $d020;
const byte* BGCOL = $d021; byte* const BGCOL = $d021;
const byte* BGCOL1 = $d021; byte* const BGCOL1 = $d021;
const byte* BGCOL2 = $d022; byte* const BGCOL2 = $d022;
const byte* BGCOL3 = $d023; byte* const BGCOL3 = $d023;
const byte* BGCOL4 = $d024; byte* const BGCOL4 = $d024;
const byte* SPRITES_MC1 = $d025; byte* const SPRITES_MC1 = $d025;
const byte* SPRITES_MC2 = $d026; byte* const SPRITES_MC2 = $d026;
const byte* SPRITES_COLS = $d027; byte* const SPRITES_COLS = $d027;
const byte* VIC_CONTROL = $d011; byte* const VIC_CONTROL = $d011;
const byte* D011 = $d011; byte* const D011 = $d011;
const byte VIC_RST8 = %10000000; const byte VIC_RST8 = %10000000;
const byte VIC_ECM = %01000000; const byte VIC_ECM = %01000000;
const byte VIC_BMM = %00100000; const byte VIC_BMM = %00100000;
const byte VIC_DEN = %00010000; const byte VIC_DEN = %00010000;
const byte VIC_RSEL = %00001000; const byte VIC_RSEL = %00001000;
const byte* VIC_CONTROL2 = $d016; byte* const VIC_CONTROL2 = $d016;
const byte* D016 = $d016; byte* const D016 = $d016;
const byte VIC_MCM = %00010000; const byte VIC_MCM = %00010000;
const byte VIC_CSEL = %00001000; const byte VIC_CSEL = %00001000;
const byte* D018 = $d018; byte* const D018 = $d018;
const byte* VIC_MEMORY = $d018; byte* const VIC_MEMORY = $d018;
const byte* LIGHTPEN_X = $d013; byte* const LIGHTPEN_X = $d013;
const byte* LIGHTPEN_Y = $d014; byte* const LIGHTPEN_Y = $d014;
// VIC II IRQ Status Register // VIC II IRQ Status Register
const byte* IRQ_STATUS = $d019; byte* const IRQ_STATUS = $d019;
// VIC II IRQ Enable Register // VIC II IRQ Enable Register
const byte* IRQ_ENABLE = $d01a; byte* const IRQ_ENABLE = $d01a;
// Bits for the IRQ Status/Enable Registers // Bits for the IRQ Status/Enable Registers
const byte IRQ_RASTER = %00000001; const byte IRQ_RASTER = %00000001;
const byte IRQ_COLLISION_BG = %00000010; const byte IRQ_COLLISION_BG = %00000010;
@ -79,67 +79,67 @@ const byte IRQ_COLLISION_SPRITE = %00000100;
const byte IRQ_LIGHTPEN = %00001000; const byte IRQ_LIGHTPEN = %00001000;
// Color Ram // Color Ram
const byte* COLS = $d800; byte* const COLS = $d800;
// CIA#1 Port A: keyboard matrix columns and joystick #2 // CIA#1 Port A: keyboard matrix columns and joystick #2
const byte* CIA1_PORT_A = $dc00; byte* const CIA1_PORT_A = $dc00;
// CIA#1 Port B: keyboard matrix rows and joystick #1. // CIA#1 Port B: keyboard matrix rows and joystick #1.
const byte* CIA1_PORT_B = $dc01; byte* const CIA1_PORT_B = $dc01;
// CIA #1 Port A data direction register. // CIA #1 Port A data direction register.
const byte* CIA1_PORT_A_DDR = $dc02; byte* const CIA1_PORT_A_DDR = $dc02;
// CIA #1 Port B data direction register. // CIA #1 Port B data direction register.
const byte* CIA1_PORT_B_DDR = $dc03; byte* const CIA1_PORT_B_DDR = $dc03;
// CIA #1 Timer A Value // CIA #1 Timer A Value
const word* CIA1_TIMER_A = $dc04; word* const CIA1_TIMER_A = $dc04;
// CIA #1 Timer B Value // CIA #1 Timer B Value
const word* CIA1_TIMER_B = $dc06; word* const CIA1_TIMER_B = $dc06;
// CIA #1 Time-of-day real-time-clock tenth seconds (BCD) // CIA #1 Time-of-day real-time-clock tenth seconds (BCD)
const byte* CIA1_TOD_10THS = $dc08; byte* const CIA1_TOD_10THS = $dc08;
// CIA #1 Time-of-day real-time-clock seconds (BCD) // CIA #1 Time-of-day real-time-clock seconds (BCD)
const byte* CIA1_TOD_SEC = $dc09; byte* const CIA1_TOD_SEC = $dc09;
// CIA #1 Time-of-day real-time-clock minutes (BCD) // CIA #1 Time-of-day real-time-clock minutes (BCD)
const byte* CIA1_TOD_MIN = $dc0a; byte* const CIA1_TOD_MIN = $dc0a;
// CIA #1 Time-of-day real-time-clock hours (BCD) // CIA #1 Time-of-day real-time-clock hours (BCD)
const byte* CIA1_TOD_HOURS = $dc0b; byte* const CIA1_TOD_HOURS = $dc0b;
// CIA #1 Serial Shift Register // CIA #1 Serial Shift Register
const byte* CIA1_SERIAL_SHIFT_OUT = $dc0c; byte* const CIA1_SERIAL_SHIFT_OUT = $dc0c;
// CIA#1 Interrupt Status & Control Register // CIA#1 Interrupt Status & Control Register
const byte* CIA1_INTERRUPT = $dc0d; byte* const CIA1_INTERRUPT = $dc0d;
// CIA#1 Timer A Control Register // CIA#1 Timer A Control Register
const byte* CIA1_TIMER_A_CONTROL = $dc0e; byte* const CIA1_TIMER_A_CONTROL = $dc0e;
// CIA#1 Timer B Control Register // CIA#1 Timer B Control Register
const byte* CIA1_TIMER_B_CONTROL = $dc0f; byte* const CIA1_TIMER_B_CONTROL = $dc0f;
// CIA#2 Port A: Serial bus, RS-232, VIC memory bank // CIA#2 Port A: Serial bus, RS-232, VIC memory bank
const byte* CIA2_PORT_A = $dd00; byte* const CIA2_PORT_A = $dd00;
// CIA#2 Port B: RS-232 // CIA#2 Port B: RS-232
const byte* CIA2_PORT_B = $dd01; byte* const CIA2_PORT_B = $dd01;
// CIA #2 Port A data direction register. // CIA #2 Port A data direction register.
const byte* CIA2_PORT_A_DDR = $dd02; byte* const CIA2_PORT_A_DDR = $dd02;
// CIA #2 Port B data direction register. // CIA #2 Port B data direction register.
const byte* CIA2_PORT_B_DDR = $dd03; byte* const CIA2_PORT_B_DDR = $dd03;
// CIA #2 Timer A+B Value (32-bit) // CIA #2 Timer A+B Value (32-bit)
const dword* CIA2_TIMER_AB = $dd04; dword* const CIA2_TIMER_AB = $dd04;
// CIA #2 Timer A Value (16-bit) // CIA #2 Timer A Value (16-bit)
const word* CIA2_TIMER_A = $dd04; word* const CIA2_TIMER_A = $dd04;
// CIA #2 Timer B Value (16-bit) // CIA #2 Timer B Value (16-bit)
const word* CIA2_TIMER_B = $dd06; word* const CIA2_TIMER_B = $dd06;
// CIA #2 Time-of-day real-time-clock tenth seconds (BCD) // CIA #2 Time-of-day real-time-clock tenth seconds (BCD)
const byte* CIA2_TOD_10THS = $dd08; byte* const CIA2_TOD_10THS = $dd08;
// CIA #2 Time-of-day real-time-clock seconds (BCD) // CIA #2 Time-of-day real-time-clock seconds (BCD)
const byte* CIA2_TOD_SEC = $dd09; byte* const CIA2_TOD_SEC = $dd09;
// CIA #2 Time-of-day real-time-clock minutes (BCD) // CIA #2 Time-of-day real-time-clock minutes (BCD)
const byte* CIA2_TOD_MIN = $dd0a; byte* const CIA2_TOD_MIN = $dd0a;
// CIA #2 Time-of-day real-time-clock hours (BCD) // CIA #2 Time-of-day real-time-clock hours (BCD)
const byte* CIA2_TOD_HOURS = $dd0b; byte* const CIA2_TOD_HOURS = $dd0b;
// CIA #2 Serial Shift Register // CIA #2 Serial Shift Register
const byte* CIA2_SERIAL_SHIFT_OUT = $dd0c; byte* const CIA2_SERIAL_SHIFT_OUT = $dd0c;
// CIA #2 Interrupt Status & Control Register // CIA #2 Interrupt Status & Control Register
const byte* CIA2_INTERRUPT = $dd0d; byte* const CIA2_INTERRUPT = $dd0d;
// CIA #2 Timer A Control Register // CIA #2 Timer A Control Register
const byte* CIA2_TIMER_A_CONTROL = $dd0e; byte* const CIA2_TIMER_A_CONTROL = $dd0e;
// CIA #2 Timer B Control Register // CIA #2 Timer B Control Register
const byte* CIA2_TIMER_B_CONTROL = $dd0f; byte* const CIA2_TIMER_B_CONTROL = $dd0f;
// Value that disables all CIA interrupts when stored to the CIA Interrupt registers // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
const byte CIA_INTERRUPT_CLEAR = $7f; const byte CIA_INTERRUPT_CLEAR = $7f;
@ -178,15 +178,15 @@ const byte CIA_TIMER_CONTROL_B_TOD_CLOCK_SET = 0b00000000;
const byte CIA_TIMER_CONTROL_B_TOD_ALARM_SET = 0b10000000; const byte CIA_TIMER_CONTROL_B_TOD_ALARM_SET = 0b10000000;
// The vector used when the KERNAL serves IRQ interrupts // The vector used when the KERNAL serves IRQ interrupts
const void()** KERNEL_IRQ = $0314; void()** const KERNEL_IRQ = $0314;
// The vector used when the KERNAL serves NMI interrupts // The vector used when the KERNAL serves NMI interrupts
const void()** KERNEL_NMI = $0318; void()** const KERNEL_NMI = $0318;
// The vector used when the HARDWARE serves IRQ interrupts // The vector used when the HARDWARE serves IRQ interrupts
const void()** HARDWARE_IRQ = $fffe; void()** const HARDWARE_IRQ = $fffe;
// The SID volume // The SID volume
const byte* SID_VOLUME = $d418; byte* const SID_VOLUME = $d418;
// The colors of the C64 // The colors of the C64

View File

@ -7,12 +7,12 @@
import "c64.kc" import "c64.kc"
// Feature enables or disables the extra C64 DTV features // Feature enables or disables the extra C64 DTV features
const byte* DTV_FEATURE = $d03f; byte* const DTV_FEATURE = $d03f;
const byte DTV_FEATURE_ENABLE = 1; const byte DTV_FEATURE_ENABLE = 1;
const byte DTV_FEATURE_DISABLE_TIL_RESET = 2; const byte DTV_FEATURE_DISABLE_TIL_RESET = 2;
// Controls the graphics modes of the C64 DTV // Controls the graphics modes of the C64 DTV
const byte* DTV_CONTROL = $d03c; byte* const DTV_CONTROL = $d03c;
const byte DTV_LINEAR = $01; const byte DTV_LINEAR = $01;
const byte DTV_BORDER_OFF = $02; const byte DTV_BORDER_OFF = $02;
const byte DTV_HIGHCOLOR = $04; const byte DTV_HIGHCOLOR = $04;
@ -22,43 +22,43 @@ const byte DTV_BADLINE_OFF = $20;
const byte DTV_CHUNKY = $40; const byte DTV_CHUNKY = $40;
// Defines colors for the 16 first colors ($00-$0f) // Defines colors for the 16 first colors ($00-$0f)
const byte* DTV_PALETTE = $d200; byte* const DTV_PALETTE = $d200;
// Default vallues for the palette // Default vallues for the palette
byte DTV_PALETTE_DEFAULT[16] = { $00, $0f, $36, $be, $58, $db, $86, $ff, $29, $26, $3b, $05, $07, $df, $9a, $0a }; byte DTV_PALETTE_DEFAULT[16] = { $00, $0f, $36, $be, $58, $db, $86, $ff, $29, $26, $3b, $05, $07, $df, $9a, $0a };
// Linear Graphics Plane A Counter Control // Linear Graphics Plane A Counter Control
const byte* DTV_PLANEA_START_LO = $d03a; byte* const DTV_PLANEA_START_LO = $d03a;
const byte* DTV_PLANEA_START_MI = $d03b; byte* const DTV_PLANEA_START_MI = $d03b;
const byte* DTV_PLANEA_START_HI = $d045; byte* const DTV_PLANEA_START_HI = $d045;
const byte* DTV_PLANEA_STEP = $d046; byte* const DTV_PLANEA_STEP = $d046;
const byte* DTV_PLANEA_MODULO_LO = $d038; byte* const DTV_PLANEA_MODULO_LO = $d038;
const byte* DTV_PLANEA_MODULO_HI = $d039; byte* const DTV_PLANEA_MODULO_HI = $d039;
// Linear Graphics Plane B Counter Control // Linear Graphics Plane B Counter Control
const byte* DTV_PLANEB_START_LO = $d049; byte* const DTV_PLANEB_START_LO = $d049;
const byte* DTV_PLANEB_START_MI = $d04a; byte* const DTV_PLANEB_START_MI = $d04a;
const byte* DTV_PLANEB_START_HI = $d04b; byte* const DTV_PLANEB_START_HI = $d04b;
const byte* DTV_PLANEB_STEP = $d04c; byte* const DTV_PLANEB_STEP = $d04c;
const byte* DTV_PLANEB_MODULO_LO = $d047; byte* const DTV_PLANEB_MODULO_LO = $d047;
const byte* DTV_PLANEB_MODULO_HI = $d048; byte* const DTV_PLANEB_MODULO_HI = $d048;
// Select memory bank where sprite data is fetched from (bits 5:0) - source only (J) // Select memory bank where sprite data is fetched from (bits 5:0) - source only (J)
// Memory address of Sprite RAM is SpriteBank*$10000 // Memory address of Sprite RAM is SpriteBank*$10000
const byte* DTV_SPRITE_BANK = $d04d; byte* const DTV_SPRITE_BANK = $d04d;
// Select memory bank where color data is fetched from (bits 11:0) // Select memory bank where color data is fetched from (bits 11:0)
// Memory address of Color RAM is ColorBank*$400 // Memory address of Color RAM is ColorBank*$400
const byte* DTV_COLOR_BANK_LO = $d036; byte* const DTV_COLOR_BANK_LO = $d036;
const byte* DTV_COLOR_BANK_HI = $d037; byte* const DTV_COLOR_BANK_HI = $d037;
const dword DTV_COLOR_BANK_DEFAULT = $1d800; const dword DTV_COLOR_BANK_DEFAULT = $1d800;
// Selects memory bank for normal VIC color mode and lower data for high color modes. (bits 5:0) // Selects memory bank for normal VIC color mode and lower data for high color modes. (bits 5:0)
// Memory address of VIC Graphics is GraphicsBank*$10000 // Memory address of VIC Graphics is GraphicsBank*$10000
const byte* DTV_GRAPHICS_VIC_BANK = $d03d; byte* const DTV_GRAPHICS_VIC_BANK = $d03d;
// Selects memory bank for upper data for high color modes. (bits 5:0) - source only (H) // Selects memory bank for upper data for high color modes. (bits 5:0) - source only (H)
const byte* DTV_GRAPHICS_HICOL_BANK = $d03e; byte* const DTV_GRAPHICS_HICOL_BANK = $d03e;
// Set the memory pointed to by CPU BANK 1 SEGMENT ($4000-$7fff) // Set the memory pointed to by CPU BANK 1 SEGMENT ($4000-$7fff)
// This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff // This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff
@ -78,46 +78,46 @@ void dtvSetCpuBankSegment1(byte cpuBankIdx) {
} }
// Blitter Source A Start // Blitter Source A Start
const byte* DTV_BLITTER_SRCA_LO = $d320; byte* const DTV_BLITTER_SRCA_LO = $d320;
const byte* DTV_BLITTER_SRCA_MI = $d321; byte* const DTV_BLITTER_SRCA_MI = $d321;
const byte* DTV_BLITTER_SRCA_HI = $d322; byte* const DTV_BLITTER_SRCA_HI = $d322;
// Blitter Source A Modulo // Blitter Source A Modulo
const byte* DTV_BLITTER_SRCA_MOD_LO = $d323; byte* const DTV_BLITTER_SRCA_MOD_LO = $d323;
const byte* DTV_BLITTER_SRCA_MOD_HI = $d324; byte* const DTV_BLITTER_SRCA_MOD_HI = $d324;
// Blitter Source A Line Length // Blitter Source A Line Length
const byte* DTV_BLITTER_SRCA_LIN_LO = $d325; byte* const DTV_BLITTER_SRCA_LIN_LO = $d325;
const byte* DTV_BLITTER_SRCA_LIN_HI = $d326; byte* const DTV_BLITTER_SRCA_LIN_HI = $d326;
// Blitter Source A Step ([7:4] integral part, [3:0] fractional part) // Blitter Source A Step ([7:4] integral part, [3:0] fractional part)
const byte* DTV_BLITTER_SRCA_STEP = $d327; byte* const DTV_BLITTER_SRCA_STEP = $d327;
// Blitter Source B Start // Blitter Source B Start
const byte* DTV_BLITTER_SRCB_LO = $d328; byte* const DTV_BLITTER_SRCB_LO = $d328;
const byte* DTV_BLITTER_SRCB_MI = $d329; byte* const DTV_BLITTER_SRCB_MI = $d329;
const byte* DTV_BLITTER_SRCB_HI = $d32a; byte* const DTV_BLITTER_SRCB_HI = $d32a;
// Blitter Source B Modulo // Blitter Source B Modulo
const byte* DTV_BLITTER_SRCB_MOD_LO = $d32b; byte* const DTV_BLITTER_SRCB_MOD_LO = $d32b;
const byte* DTV_BLITTER_SRCB_MOD_HI = $d32c; byte* const DTV_BLITTER_SRCB_MOD_HI = $d32c;
// Blitter Source B Line Length // Blitter Source B Line Length
const byte* DTV_BLITTER_SRCB_LIN_LO = $d32d; byte* const DTV_BLITTER_SRCB_LIN_LO = $d32d;
const byte* DTV_BLITTER_SRCB_LIN_HI = $d32e; byte* const DTV_BLITTER_SRCB_LIN_HI = $d32e;
// Blitter Source B Step ([7:4] integral part, [3:0] fractional part) // Blitter Source B Step ([7:4] integral part, [3:0] fractional part)
const byte* DTV_BLITTER_SRCB_STEP = $d32f; byte* const DTV_BLITTER_SRCB_STEP = $d32f;
// Blitter Destination Start // Blitter Destination Start
const byte* DTV_BLITTER_DEST_LO = $d330; byte* const DTV_BLITTER_DEST_LO = $d330;
const byte* DTV_BLITTER_DEST_MI = $d331; byte* const DTV_BLITTER_DEST_MI = $d331;
const byte* DTV_BLITTER_DEST_HI = $d332; byte* const DTV_BLITTER_DEST_HI = $d332;
// Blitter Source B Modulo // Blitter Source B Modulo
const byte* DTV_BLITTER_DEST_MOD_LO = $d333; byte* const DTV_BLITTER_DEST_MOD_LO = $d333;
const byte* DTV_BLITTER_DEST_MOD_HI = $d334; byte* const DTV_BLITTER_DEST_MOD_HI = $d334;
// Blitter Source B Line Length // Blitter Source B Line Length
const byte* DTV_BLITTER_DEST_LIN_LO = $d335; byte* const DTV_BLITTER_DEST_LIN_LO = $d335;
const byte* DTV_BLITTER_DEST_LIN_HI = $d336; byte* const DTV_BLITTER_DEST_LIN_HI = $d336;
// Blitter Source B Step ([7:4] integral part, [3:0] fractional part) // Blitter Source B Step ([7:4] integral part, [3:0] fractional part)
const byte* DTV_BLITTER_DEST_STEP = $d337; byte* const DTV_BLITTER_DEST_STEP = $d337;
// Blitter Blit Length // Blitter Blit Length
const byte* DTV_BLITTER_LEN_LO = $d338; byte* const DTV_BLITTER_LEN_LO = $d338;
const byte* DTV_BLITTER_LEN_HI = $d339; byte* const DTV_BLITTER_LEN_HI = $d339;
// Blitter Control // Blitter Control
const byte* DTV_BLITTER_CONTROL = $d33a; byte* const DTV_BLITTER_CONTROL = $d33a;
// Bit[0] Force Start Strobe when set // Bit[0] Force Start Strobe when set
const byte DTV_BLIT_FORCE_START = %00000001; const byte DTV_BLIT_FORCE_START = %00000001;
// Bit[1] Source A Direction Positive when set // Bit[1] Source A Direction Positive when set
@ -135,7 +135,7 @@ const byte DTV_BLIT_VBLANK = %01000000;
// Bit[7] Blitter IRQ Enable when set // Bit[7] Blitter IRQ Enable when set
const byte DTV_BLIT_IRQ_EN = %10000000; const byte DTV_BLIT_IRQ_EN = %10000000;
// Blitter Transparency // Blitter Transparency
const byte* DTV_BLITTER_TRANSPARANCY = $d33b; byte* const DTV_BLITTER_TRANSPARANCY = $d33b;
// Bit[0] Disable Channel B. // Bit[0] Disable Channel B.
// (data into b port of ALU is forced to %00000000. ALU functions as normal) // (data into b port of ALU is forced to %00000000. ALU functions as normal)
const byte DTV_BLIT_DISABLE_B = %00000001; const byte DTV_BLIT_DISABLE_B = %00000001;
@ -169,7 +169,7 @@ const byte DTV_BLIT_XNOR = %00101000;
const byte DTV_BLIT_ADD = %00110000; const byte DTV_BLIT_ADD = %00110000;
const byte DTV_BLIT_SUB = %00111000; const byte DTV_BLIT_SUB = %00111000;
// Blitter Control 2 // Blitter Control 2
const byte* DTV_BLITTER_CONTROL2 = $d33f; byte* const DTV_BLITTER_CONTROL2 = $d33f;
// Bit[0] Clear Blitter IRQ // Bit[0] Clear Blitter IRQ
const byte DTV_BLIT_CLEAR_IRQ = %00000001; const byte DTV_BLIT_CLEAR_IRQ = %00000001;
// Bit[1] Source A Continue // Bit[1] Source A Continue

View File

@ -48,7 +48,7 @@ void mulf_init() {
// Prepare for fast multiply with an unsigned byte to a word result // Prepare for fast multiply with an unsigned byte to a word result
void mulf8u_prepare(byte a) { void mulf8u_prepare(byte a) {
const byte* memA = $fd; byte* const memA = $fd;
*memA = a; *memA = a;
asm { asm {
lda memA lda memA
@ -63,8 +63,8 @@ void mulf8u_prepare(byte a) {
// Calculate fast multiply with a prepared unsigned byte to a word result // Calculate fast multiply with a prepared unsigned byte to a word result
// The prepared number is set by calling mulf8u_prepare(byte a) // The prepared number is set by calling mulf8u_prepare(byte a)
word mulf8u_prepared(byte b) { word mulf8u_prepared(byte b) {
const byte* resL = $fe; byte* const resL = $fe;
const byte* memB = $ff; byte* const memB = $ff;
*memB = b; *memB = b;
asm { asm {
ldx memB ldx memB
@ -97,7 +97,7 @@ inline void mulf8s_prepare(signed byte a) {
// Calculate fast multiply with a prepared unsigned byte to a word result // Calculate fast multiply with a prepared unsigned byte to a word result
// The prepared number is set by calling mulf8s_prepare(byte a) // The prepared number is set by calling mulf8s_prepare(byte a)
signed word mulf8s_prepared(signed byte b) { signed word mulf8s_prepared(signed byte b) {
const signed byte* memA = $fd; signed byte* const memA = $fd;
word m = mulf8u_prepared((byte) b); word m = mulf8u_prepared((byte) b);
if(*memA<0) { if(*memA<0) {
>m = (>m)-(byte)b; >m = (>m)-(byte)b;
@ -117,9 +117,9 @@ signed word mulf8s(signed byte a, signed byte b) {
// Fast multiply two unsigned words to a double word result // Fast multiply two unsigned words to a double word result
// Done in assembler to utilize fast addition A+X // Done in assembler to utilize fast addition A+X
dword mulf16u(word a, word b) { dword mulf16u(word a, word b) {
const word* memA = $f8; word* const memA = $f8;
const word* memB = $fa; word* const memB = $fa;
const dword* memR = $fc; dword* const memR = $fc;
*memA = a; *memA = a;
*memB = b; *memB = b;
asm { asm {

View File

@ -942,10 +942,10 @@ public class TestPrograms {
compileAndCompare("enum-0"); compileAndCompare("enum-0");
} }
@Test //@Test
public void testTypedef3() throws IOException, URISyntaxException { //public void testTypedef3() throws IOException, URISyntaxException {
compileAndCompare("typedef-3"); // compileAndCompare("typedef-3");
} //}
@Test @Test
public void testTypedef2() throws IOException, URISyntaxException { public void testTypedef2() throws IOException, URISyntaxException {
@ -1777,6 +1777,21 @@ public class TestPrograms {
compileAndCompare("sandbox"); compileAndCompare("sandbox");
} }
@Test
public void testPointerConstDeep() throws IOException, URISyntaxException {
assertError("pointer-const-deep", "Deep const/volatile not supported");
}
@Test
public void testPointerConstTypedef() throws IOException, URISyntaxException {
compileAndCompare("pointer-const-typedef");
}
@Test
public void testPointerConst() throws IOException, URISyntaxException {
compileAndCompare("pointer-const");
}
@Test @Test
public void testPointerCast4() throws IOException, URISyntaxException { public void testPointerCast4() throws IOException, URISyntaxException {
compileAndCompare("pointer-cast-4"); compileAndCompare("pointer-cast-4");

View File

@ -1,7 +1,7 @@
// Test that address vars are turned into load/store and located at hardcoded addresses // Test that address vars are turned into load/store and located at hardcoded addresses
// Hard-coded zero-page address - global variable // Hard-coded zero-page address - global variable
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
char __address(0x02) i = 3; char __address(0x02) i = 3;

View File

@ -1,7 +1,7 @@
// Test that address vars are turned into load/store and located at hardcoded addresses // Test that address vars are turned into load/store and located at hardcoded addresses
// Hard-coded zero-page address - local variable // Hard-coded zero-page address - local variable
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
void main() { void main() {

View File

@ -1,7 +1,7 @@
// Test that address vars are turned into load/store and located at hardcoded addresses // Test that address vars are turned into load/store and located at hardcoded addresses
// Hard-coded mainmem-page address - global variable // Hard-coded mainmem-page address - global variable
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
char __address(0x2000) i = 3; char __address(0x2000) i = 3;

View File

@ -1,7 +1,7 @@
// Test that address vars are turned into load/store and located at hardcoded addresses // Test that address vars are turned into load/store and located at hardcoded addresses
// Hard-coded mainmem address - local variable // Hard-coded mainmem address - local variable
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
void main() { void main() {
char __address(0x2000) i = 3; char __address(0x2000) i = 3;

View File

@ -7,7 +7,7 @@ void main() {
print('l'); print('l');
} }
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
volatile char __address(0x03) idx; volatile char __address(0x03) idx;

View File

@ -7,7 +7,7 @@ void main() {
print('l'); print('l');
} }
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
volatile char __address(0x3000) idx; volatile char __address(0x3000) idx;

View File

@ -3,8 +3,8 @@
byte val = 0; byte val = 0;
void main() { void main() {
const byte* SCREEN1 = 0x0400; byte* const SCREEN1 = 0x0400;
const byte* SCREEN2 = SCREEN1+40; byte* const SCREEN2 = SCREEN1+40;
byte idx = 0; byte idx = 0;
SCREEN1[idx] = val; SCREEN1[idx] = val;
SCREEN2[idx++] = '.'; SCREEN2[idx++] = '.';

View File

@ -11,7 +11,7 @@ void main() {
} }
const int* SCREEN = 0x0400; int* const SCREEN = 0x0400;
char idx = 0; char idx = 0;
void print(int* p) { void print(int* p) {

View File

@ -3,7 +3,7 @@
char msg1[16] ="camelot"; char msg1[16] ="camelot";
char msg2[16] = { 'c', 'm', 'l' }; char msg2[16] = { 'c', 'm', 'l' };
const char* SCREEN = 0x400; char* const SCREEN = 0x400;
void main() { void main() {
for(char i=0;msg1[i];i++) for(char i=0;msg1[i];i++)

View File

@ -2,7 +2,7 @@
char[16] msg ="camelot"; char[16] msg ="camelot";
const char* SCREEN = 0x400; char* const SCREEN = 0x400;
void main() { void main() {
for(char i=0;msg[i];i++) for(char i=0;msg[i];i++)

View File

@ -1,7 +1,7 @@
// Test using an ASM mnemonic as a C symbol names // Test using an ASM mnemonic as a C symbol names
// Works if the C-lexer and the ASM-lexer are separated properly // Works if the C-lexer and the ASM-lexer are separated properly
const char* lda = 0x0400; char* const lda = 0x0400;
void main() { void main() {
char jmp = 1; char jmp = 1;

View File

@ -6,7 +6,7 @@ void main() {
} }
} }
const char* BGCOL = 0xd020; char* const BGCOL = 0xd020;
// Function only used inside the inline asm // Function only used inside the inline asm
void init() { void init() {

View File

@ -1,2 +1,2 @@
const char* BGCOL = 0xd021; char* const BGCOL = 0xd021;
const char BLACK = 0x00; const char BLACK = 0x00;

View File

@ -1,8 +1,8 @@
import "c64" import "c64"
const byte* SCREEN = $400; byte* const SCREEN = $400;
const byte* BITMAP = $2000; byte* const BITMAP = $2000;
const byte* COLORS = $d800; byte* const COLORS = $d800;
byte bitmask[] = { 128, 64, 32, 16, 8, 4, 2, 1 }; byte bitmask[] = { 128, 64, 32, 16, 8, 4, 2, 1 };

View File

@ -4,9 +4,9 @@
import "c64" import "c64"
const byte* SCREEN = $400; byte* const SCREEN = $400;
const byte* BITMAP = $2000; byte* const BITMAP = $2000;
const byte* COLORS = $d800; byte* const COLORS = $d800;
byte bitmask[] = { 128, 64, 32, 16, 8, 4, 2, 1 }; byte bitmask[] = { 128, 64, 32, 16, 8, 4, 2, 1 };

View File

@ -4,8 +4,8 @@
import "c64.kc" import "c64.kc"
import "bitmap-draw.kc" import "bitmap-draw.kc"
const byte* SCREEN = $400; byte* const SCREEN = $400;
const byte* BITMAP = $2000; byte* const BITMAP = $2000;
byte next=0; byte next=0;

View File

@ -4,8 +4,8 @@
import "c64.kc" import "c64.kc"
import "bitmap2.kc" import "bitmap2.kc"
const byte* SCREEN = $400; byte* const SCREEN = $400;
const byte* BITMAP = $2000; byte* const BITMAP = $2000;
word next=0; word next=0;

View File

@ -16,7 +16,7 @@ byte* COLS = $d800;
byte* SCREEN = $400; byte* SCREEN = $400;
const byte* BITMAP = $2000; byte* const BITMAP = $2000;
void main() { void main() {
*BGCOL = 0; *BGCOL = 0;

View File

@ -1,7 +1,7 @@
// Test that bitwise NOT (~) is handled correctly // Test that bitwise NOT (~) is handled correctly
void main() { void main() {
const char* screen = 0x0400; char* const screen = 0x0400;
char b = ~0x10; char b = ~0x10;
*screen = b; *screen = b;
} }

View File

@ -1,6 +1,6 @@
// A Minimal test of boolean constants. // A Minimal test of boolean constants.
const byte* SCREEN = $400; byte* const SCREEN = $400;
void main() { void main() {
bool_const_if(); bool_const_if();

View File

@ -1,7 +1,7 @@
// A test of boolean conditions using && || and ! // A test of boolean conditions using && || and !
void main() { void main() {
const char* screen = 0x400; char* const screen = 0x400;
for( char i : 0..20) { for( char i : 0..20) {
if( (i<10) && ((i&1)==0) ) { if( (i<10) && ((i&1)==0) ) {
screen[i] = '*'; screen[i] = '*';

View File

@ -8,7 +8,7 @@ void main() {
} }
void bool_and() { void bool_and() {
const byte* screen = $400; byte* const screen = $400;
for( byte i : 0..20) { for( byte i : 0..20) {
if( (i<10) && ((i&1)==0) ) { if( (i<10) && ((i&1)==0) ) {
screen[i] = '*'; screen[i] = '*';
@ -19,7 +19,7 @@ void bool_and() {
} }
void bool_or() { void bool_or() {
const byte* screen = $428; byte* const screen = $428;
for( byte i : 0..20) { for( byte i : 0..20) {
if( (i<10) || ((i&1)==0) ) { if( (i<10) || ((i&1)==0) ) {
screen[i] = '*'; screen[i] = '*';
@ -30,7 +30,7 @@ void bool_or() {
} }
void bool_not() { void bool_not() {
const byte* screen = $450; byte* const screen = $450;
for( byte i : 0..20) { for( byte i : 0..20) {
if( !((i<10) || (i&1)==0)) { if( !((i<10) || (i&1)==0)) {
screen[i] = '*'; screen[i] = '*';
@ -41,7 +41,7 @@ void bool_not() {
} }
void bool_complex() { void bool_complex() {
const byte* screen = $478; byte* const screen = $478;
for( byte i : 0..20) { for( byte i : 0..20) {
if( ((i<10) && (i&1)==0) || !((i<10) || (i&1)==0) ) { if( ((i<10) && (i&1)==0) || !((i<10) || (i&1)==0) ) {
screen[i] = '*'; screen[i] = '*';

View File

@ -4,7 +4,7 @@
// https://gitlab.com/camelot/kickc/issues/199 // https://gitlab.com/camelot/kickc/issues/199
void main() { void main() {
const char* screen = 0x0400; char* const screen = 0x0400;
for(char i: 0..7) { for(char i: 0..7) {
bool b = (i&1)==1; bool b = (i&1)==1;
char c = !b ? 1 : 0 ; char c = !b ? 1 : 0 ;

View File

@ -4,7 +4,7 @@
// https://gitlab.com/camelot/kickc/issues/199 // https://gitlab.com/camelot/kickc/issues/199
void main() { void main() {
const char* screen = 0x0400; char* const screen = 0x0400;
for(char i: 0..7) { for(char i: 0..7) {
char b = i&1; char b = i&1;
char c = !b ? 1 : 0 ; char c = !b ? 1 : 0 ;

View File

@ -4,7 +4,7 @@
// https://gitlab.com/camelot/kickc/issues/295 // https://gitlab.com/camelot/kickc/issues/295
void main() { void main() {
const char* screen = 0x0400; char* const screen = 0x0400;
for(char i: 0..7) { for(char i: 0..7) {
char b = (i&1); char b = (i&1);
screen[i] = !b; screen[i] = !b;

View File

@ -8,7 +8,7 @@ void main() {
} }
void bool_and() { void bool_and() {
const byte* screen = $400; byte* const screen = $400;
for( byte i : 0..20) { for( byte i : 0..20) {
bool o1 = (i<10); bool o1 = (i<10);
bool o2 = ((i&1)==0); bool o2 = ((i&1)==0);
@ -22,7 +22,7 @@ void bool_and() {
} }
void bool_or() { void bool_or() {
const byte* screen = $428; byte* const screen = $428;
for( byte i : 0..20) { for( byte i : 0..20) {
bool o1 = (i<10); bool o1 = (i<10);
bool o2 = ((i&1)==0); bool o2 = ((i&1)==0);
@ -36,7 +36,7 @@ void bool_or() {
} }
void bool_not() { void bool_not() {
const byte* screen = $450; byte* const screen = $450;
for( byte i : 0..20) { for( byte i : 0..20) {
bool o1 = (i<10); bool o1 = (i<10);
bool o2 = (i&1)==0; bool o2 = (i&1)==0;
@ -50,7 +50,7 @@ void bool_not() {
} }
void bool_complex() { void bool_complex() {
const byte* screen = $478; byte* const screen = $478;
for( byte i : 0..20) { for( byte i : 0..20) {
bool o1 = (i<10); bool o1 = (i<10);
bool o2 = (i&1)==0; bool o2 = (i&1)==0;

View File

@ -2,9 +2,9 @@
import "c64dtv.kc" import "c64dtv.kc"
// Plane with the screen // Plane with the screen
const byte* SCREEN = $7c00; byte* const SCREEN = $7c00;
// Plane with all pixels // Plane with all pixels
const byte* CHARSET8 = $8000; byte* const CHARSET8 = $8000;
void main() { void main() {
asm { sei } // Disable normal interrupt (prevent keyboard reading glitches and allows to hide basic/kernal) asm { sei } // Disable normal interrupt (prevent keyboard reading glitches and allows to hide basic/kernal)

View File

@ -2,7 +2,7 @@
import "c64dtv.kc" import "c64dtv.kc"
// Plane with all pixels // Plane with all pixels
const byte* CHUNKY = $8000; byte* const CHUNKY = $8000;
void main() { void main() {
asm { sei } // Disable normal interrupt (prevent keyboard reading glitches and allows to hide basic/kernal) asm { sei } // Disable normal interrupt (prevent keyboard reading glitches and allows to hide basic/kernal)

View File

@ -2,7 +2,7 @@
import "c64dtv.kc" import "c64dtv.kc"
const byte* SCREEN = $400; byte* const SCREEN = $400;
const byte SRCA[] = "camelot rules!"; const byte SRCA[] = "camelot rules!";
const byte SRCB[] = { $80 }; const byte SRCB[] = { $80 };

View File

@ -1,6 +1,6 @@
import "c64dtv.kc" import "c64dtv.kc"
const byte* SCREEN = $400; byte* const SCREEN = $400;
const byte SRCA[] = { 'c', 'a', 'm', 'e', 'l', 'o', 't', '!', ' '}; const byte SRCA[] = { 'c', 'a', 'm', 'e', 'l', 'o', 't', '!', ' '};
const byte SRCA_LEN = 9; const byte SRCA_LEN = 9;
const byte SRCB[] = { $80 }; const byte SRCB[] = { $80 };

View File

@ -22,15 +22,15 @@ void main() {
} }
// VIC Screens // VIC Screens
const byte* VIC_SCREEN0 = $4000; byte* const VIC_SCREEN0 = $4000;
const byte* VIC_SCREEN1 = $4400; byte* const VIC_SCREEN1 = $4400;
const byte* VIC_SCREEN2 = $4800; byte* const VIC_SCREEN2 = $4800;
const byte* VIC_SCREEN3 = $4c00; byte* const VIC_SCREEN3 = $4c00;
const byte* VIC_SCREEN4 = $5000; byte* const VIC_SCREEN4 = $5000;
// VIC Charset from ROM // VIC Charset from ROM
const byte* VIC_CHARSET_ROM = $5800; byte* const VIC_CHARSET_ROM = $5800;
// VIC Bitmap // VIC Bitmap
const byte* VIC_BITMAP = $6000; byte* const VIC_BITMAP = $6000;
// 8BPP Chunky Bitmap (contains 8bpp pixels) // 8BPP Chunky Bitmap (contains 8bpp pixels)
const dword PLANE_8BPP_CHUNKY = $20000; const dword PLANE_8BPP_CHUNKY = $20000;
@ -110,9 +110,9 @@ byte* get_vic_charset(byte idx) {
} }
// Screen containing the FORM // Screen containing the FORM
const byte* FORM_SCREEN = $0400; byte* const FORM_SCREEN = $0400;
// Charset used for the FORM // Charset used for the FORM
const byte* FORM_CHARSET = $1800; // Charset ROM byte* const FORM_CHARSET = $1800; // Charset ROM
byte FORM_TEXT[] = byte FORM_TEXT[] =
" C64 DTV Graphics Mode Explorer @" " C64 DTV Graphics Mode Explorer @"
@ -254,42 +254,42 @@ void render_preset_name(byte idx) {
// Form fields direct addressing // Form fields direct addressing
const byte* form_preset = form_fields_val+0; byte* const form_preset = form_fields_val+0;
const byte* form_ctrl_bmm = form_fields_val+1; byte* const form_ctrl_bmm = form_fields_val+1;
const byte* form_ctrl_mcm = form_fields_val+2; byte* const form_ctrl_mcm = form_fields_val+2;
const byte* form_ctrl_ecm = form_fields_val+3; byte* const form_ctrl_ecm = form_fields_val+3;
const byte* form_ctrl_hicol = form_fields_val+4; byte* const form_ctrl_hicol = form_fields_val+4;
const byte* form_ctrl_line = form_fields_val+5; byte* const form_ctrl_line = form_fields_val+5;
const byte* form_ctrl_colof = form_fields_val+6; byte* const form_ctrl_colof = form_fields_val+6;
const byte* form_ctrl_chunk = form_fields_val+7; byte* const form_ctrl_chunk = form_fields_val+7;
const byte* form_ctrl_borof = form_fields_val+8; byte* const form_ctrl_borof = form_fields_val+8;
const byte* form_ctrl_overs = form_fields_val+9; byte* const form_ctrl_overs = form_fields_val+9;
const byte* form_a_pattern = form_fields_val+10; byte* const form_a_pattern = form_fields_val+10;
const byte* form_a_start_hi = form_fields_val+11; byte* const form_a_start_hi = form_fields_val+11;
const byte* form_a_start_lo = form_fields_val+12; byte* const form_a_start_lo = form_fields_val+12;
const byte* form_a_step_hi = form_fields_val+13; byte* const form_a_step_hi = form_fields_val+13;
const byte* form_a_step_lo = form_fields_val+14; byte* const form_a_step_lo = form_fields_val+14;
const byte* form_a_mod_hi = form_fields_val+15; byte* const form_a_mod_hi = form_fields_val+15;
const byte* form_a_mod_lo = form_fields_val+16; byte* const form_a_mod_lo = form_fields_val+16;
const byte* form_b_pattern = form_fields_val+17; byte* const form_b_pattern = form_fields_val+17;
const byte* form_b_start_hi = form_fields_val+18; byte* const form_b_start_hi = form_fields_val+18;
const byte* form_b_start_lo = form_fields_val+19; byte* const form_b_start_lo = form_fields_val+19;
const byte* form_b_step_hi = form_fields_val+20; byte* const form_b_step_hi = form_fields_val+20;
const byte* form_b_step_lo = form_fields_val+21; byte* const form_b_step_lo = form_fields_val+21;
const byte* form_b_mod_hi = form_fields_val+22; byte* const form_b_mod_hi = form_fields_val+22;
const byte* form_b_mod_lo = form_fields_val+23; byte* const form_b_mod_lo = form_fields_val+23;
const byte* form_vic_screen = form_fields_val+24; byte* const form_vic_screen = form_fields_val+24;
const byte* form_vic_gfx = form_fields_val+25; byte* const form_vic_gfx = form_fields_val+25;
const byte* form_vic_cols = form_fields_val+26; byte* const form_vic_cols = form_fields_val+26;
const byte* form_dtv_palet = form_fields_val+27; byte* const form_dtv_palet = form_fields_val+27;
const byte* form_vic_bg0_hi = form_fields_val+28; byte* const form_vic_bg0_hi = form_fields_val+28;
const byte* form_vic_bg0_lo = form_fields_val+29; byte* const form_vic_bg0_lo = form_fields_val+29;
const byte* form_vic_bg1_hi = form_fields_val+30; byte* const form_vic_bg1_hi = form_fields_val+30;
const byte* form_vic_bg1_lo = form_fields_val+31; byte* const form_vic_bg1_lo = form_fields_val+31;
const byte* form_vic_bg2_hi = form_fields_val+32; byte* const form_vic_bg2_hi = form_fields_val+32;
const byte* form_vic_bg2_lo = form_fields_val+33; byte* const form_vic_bg2_lo = form_fields_val+33;
const byte* form_vic_bg3_hi = form_fields_val+34; byte* const form_vic_bg3_hi = form_fields_val+34;
const byte* form_vic_bg3_lo = form_fields_val+35; byte* const form_vic_bg3_lo = form_fields_val+35;
// Change graphics mode to show the selected graphics mode // Change graphics mode to show the selected graphics mode
void gfx_mode() { void gfx_mode() {

View File

@ -42,8 +42,8 @@ byte MENU_TEXT[] =
void menu() { void menu() {
const byte* SCREEN = $8000; byte* const SCREEN = $8000;
const byte* CHARSET = $9800; // Charset ROM byte* const CHARSET = $9800; // Charset ROM
// DTV Graphics Bank // DTV Graphics Bank
*DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000); *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000);
// DTV Color Bank // DTV Color Bank
@ -187,9 +187,9 @@ void mode_ctrl() {
// - 0: 4bpp BgColor0[3:0] // - 0: 4bpp BgColor0[3:0]
// - 1: 4bpp ColorData[3:0] // - 1: 4bpp ColorData[3:0]
void mode_stdchar() { void mode_stdchar() {
const byte* SCREEN = $8000; byte* const SCREEN = $8000;
const byte* CHARSET = $9000; // Charset ROM byte* const CHARSET = $9000; // Charset ROM
const byte* COLORS = $d800; byte* const COLORS = $d800;
// DTV Graphics Bank // DTV Graphics Bank
*DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000); *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000);
// DTV Color Bank // DTV Color Bank
@ -238,9 +238,9 @@ void mode_stdchar() {
// - CharData[7:6] 11: 4bpp BgColor3[3:0] // - CharData[7:6] 11: 4bpp BgColor3[3:0]
// - 1: 4bpp ColorData[3:0] // - 1: 4bpp ColorData[3:0]
void mode_ecmchar() { void mode_ecmchar() {
const byte* SCREEN = $8000; byte* const SCREEN = $8000;
const byte* CHARSET = $9000; // Charset ROM byte* const CHARSET = $9000; // Charset ROM
const byte* COLORS = $d800; byte* const COLORS = $d800;
// DTV Graphics Bank // DTV Graphics Bank
*DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000); *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000);
// DTV Color Bank // DTV Color Bank
@ -294,9 +294,9 @@ void mode_ecmchar() {
// - 10: 4bpp BgColor2[3:0] // - 10: 4bpp BgColor2[3:0]
// - 11: 4bpp ColorData[2:0]// Standard Character Mode (LINEAR/HICOL/CHUNK/COLDIS/ECM/MCM/BMM = 0) // - 11: 4bpp ColorData[2:0]// Standard Character Mode (LINEAR/HICOL/CHUNK/COLDIS/ECM/MCM/BMM = 0)
void mode_mcchar() { void mode_mcchar() {
const byte* SCREEN = $8000; byte* const SCREEN = $8000;
const byte* CHARSET = $9000; // Charset ROM byte* const CHARSET = $9000; // Charset ROM
const byte* COLORS = $d800; byte* const COLORS = $d800;
// DTV Graphics Bank // DTV Graphics Bank
*DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000); *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000);
// DTV Color Bank // DTV Color Bank
@ -344,8 +344,8 @@ void mode_mcchar() {
// - 0: 4bpp CharData[3:0] // - 0: 4bpp CharData[3:0]
// - 1: 4bpp CharData[7:4] // - 1: 4bpp CharData[7:4]
void mode_stdbitmap() { void mode_stdbitmap() {
const byte* SCREEN = $4000; byte* const SCREEN = $4000;
const byte* BITMAP = $6000; byte* const BITMAP = $6000;
// DTV Graphics Bank // DTV Graphics Bank
*DTV_GRAPHICS_VIC_BANK = (byte)((dword)BITMAP/$10000); *DTV_GRAPHICS_VIC_BANK = (byte)((dword)BITMAP/$10000);
// DTV Graphics Mode // DTV Graphics Mode
@ -396,9 +396,9 @@ void mode_stdbitmap() {
// - 0: 8bpp BgColor0[7:0] // - 0: 8bpp BgColor0[7:0]
// - 1: 8bpp ColorData[7:0] // - 1: 8bpp ColorData[7:0]
void mode_hicolstdchar() { void mode_hicolstdchar() {
const byte* SCREEN = $8000; byte* const SCREEN = $8000;
const byte* CHARSET = $9000; // Charset ROM byte* const CHARSET = $9000; // Charset ROM
const byte* COLORS = $8400; byte* const COLORS = $8400;
// DTV Graphics Bank // DTV Graphics Bank
*DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000); *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000);
// DTV Color Bank // DTV Color Bank
@ -449,9 +449,9 @@ void mode_hicolstdchar() {
// - CharData[7:6] 11: 8bpp BgColor3[7:0] // - CharData[7:6] 11: 8bpp BgColor3[7:0]
// - 1: 8bpp ColorData[7:0] // - 1: 8bpp ColorData[7:0]
void mode_hicolecmchar() { void mode_hicolecmchar() {
const byte* SCREEN = $8000; byte* const SCREEN = $8000;
const byte* CHARSET = $9000; // Charset ROM byte* const CHARSET = $9000; // Charset ROM
const byte* COLORS = $8400; byte* const COLORS = $8400;
// DTV Graphics Bank // DTV Graphics Bank
*DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000); *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000);
// DTV Color Bank // DTV Color Bank
@ -505,9 +505,9 @@ void mode_hicolecmchar() {
// - 10: 8bpp BgColor2[7:0] // - 10: 8bpp BgColor2[7:0]
// - 11: 8bpp ColorData[7:4] "0" & Color[2:0] // - 11: 8bpp ColorData[7:4] "0" & Color[2:0]
void mode_hicolmcchar() { void mode_hicolmcchar() {
const byte* SCREEN = $8000; byte* const SCREEN = $8000;
const byte* CHARSET = $9000; // Charset ROM byte* const CHARSET = $9000; // Charset ROM
const byte* COLORS = $8400; byte* const COLORS = $8400;
// DTV Graphics Bank // DTV Graphics Bank
*DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000); *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000);
// DTV Color Bank // DTV Color Bank
@ -557,9 +557,9 @@ void mode_hicolmcchar() {
// - Plane A = 1 Plane B = 0: 8bpp "0000" & ColorData[3:0] // - Plane A = 1 Plane B = 0: 8bpp "0000" & ColorData[3:0]
// - Plane A = 1 Plane B = 1: 8bpp BgColor1[7:0] // - Plane A = 1 Plane B = 1: 8bpp BgColor1[7:0]
void mode_twoplanebitmap() { void mode_twoplanebitmap() {
const byte* PLANEA = $4000; byte* const PLANEA = $4000;
const byte* PLANEB = $6000; byte* const PLANEB = $6000;
const byte* COLORS = $8000; byte* const COLORS = $8000;
// DTV Graphics Mode // DTV Graphics Mode
dtv_control = DTV_HIGHCOLOR | DTV_LINEAR; dtv_control = DTV_HIGHCOLOR | DTV_LINEAR;
*DTV_CONTROL = DTV_HIGHCOLOR | DTV_LINEAR; *DTV_CONTROL = DTV_HIGHCOLOR | DTV_LINEAR;
@ -627,9 +627,9 @@ void mode_twoplanebitmap() {
// GfxData/PlaneA Pixel Shifter (2), CharData/PlaneB Pixel Shifter (2): // GfxData/PlaneA Pixel Shifter (2), CharData/PlaneB Pixel Shifter (2):
// - 8bpp color (ColorData[3:0],CharData/PlaneB[1:0], GfxData/PlaneA[1:0]) // - 8bpp color (ColorData[3:0],CharData/PlaneB[1:0], GfxData/PlaneA[1:0])
void mode_sixsfred() { void mode_sixsfred() {
const byte* PLANEA = $4000; byte* const PLANEA = $4000;
const byte* PLANEB = $6000; byte* const PLANEB = $6000;
const byte* COLORS = $8000; byte* const COLORS = $8000;
// DTV Graphics Mode // DTV Graphics Mode
dtv_control = DTV_HIGHCOLOR | DTV_LINEAR; dtv_control = DTV_HIGHCOLOR | DTV_LINEAR;
*DTV_CONTROL = DTV_HIGHCOLOR | DTV_LINEAR; *DTV_CONTROL = DTV_HIGHCOLOR | DTV_LINEAR;
@ -693,9 +693,9 @@ void mode_sixsfred() {
// PlaneA Pixel Shifter (2), PlaneB Pixel Shifter (2): // PlaneA Pixel Shifter (2), PlaneB Pixel Shifter (2):
// - 8bpp color (PlaneB[1:0],ColorData[5:4],PlaneA[1:0],ColorData[1:0]) // - 8bpp color (PlaneB[1:0],ColorData[5:4],PlaneA[1:0],ColorData[1:0])
void mode_sixsfred2() { void mode_sixsfred2() {
const byte* PLANEA = $4000; byte* const PLANEA = $4000;
const byte* PLANEB = $6000; byte* const PLANEB = $6000;
const byte* COLORS = $8000; byte* const COLORS = $8000;
// DTV Graphics Mode // DTV Graphics Mode
dtv_control = DTV_LINEAR; dtv_control = DTV_LINEAR;
*DTV_CONTROL = DTV_LINEAR; *DTV_CONTROL = DTV_LINEAR;
@ -764,9 +764,9 @@ void mode_sixsfred2() {
//Counter B step and modulo should be set to 0, counter A modulo to 0 and counter A step to 1 for normal operation. //Counter B step and modulo should be set to 0, counter A modulo to 0 and counter A step to 1 for normal operation.
void mode_8bpppixelcell() { void mode_8bpppixelcell() {
// 8BPP Pixel Cell Screen (contains 40x25=1000 chars) // 8BPP Pixel Cell Screen (contains 40x25=1000 chars)
const byte* PLANEA = $3c00; byte* const PLANEA = $3c00;
// 8BPP Pixel Cell Charset (contains 256 64 byte chars) // 8BPP Pixel Cell Charset (contains 256 64 byte chars)
const byte* PLANEB = $4000; byte* const PLANEB = $4000;
// DTV Graphics Mode // DTV Graphics Mode
dtv_control = DTV_HIGHCOLOR | DTV_LINEAR | DTV_CHUNKY; dtv_control = DTV_HIGHCOLOR | DTV_LINEAR | DTV_CHUNKY;
*DTV_CONTROL = DTV_HIGHCOLOR | DTV_LINEAR | DTV_CHUNKY; *DTV_CONTROL = DTV_HIGHCOLOR | DTV_LINEAR | DTV_CHUNKY;

View File

@ -7,7 +7,7 @@ void main() {
print( {0x12,0x34} ); print( {0x12,0x34} );
} }
const word* SCREEN = 0x0400; word* const SCREEN = 0x0400;
byte idx = 0; byte idx = 0;
void print(word w) { void print(word w) {

View File

@ -4,7 +4,7 @@ import "c64"
import "time" import "time"
import "print" import "print"
const byte* SCREEN = 0x0400; byte* const SCREEN = 0x0400;
void main() { void main() {

View File

@ -4,7 +4,7 @@ import "c64"
import "time" import "time"
import "print" import "print"
const byte* SCREEN = 0x0400; byte* const SCREEN = 0x0400;
void main() { void main() {

View File

@ -3,7 +3,7 @@ byte* BORDERCOL = $d020;
byte* RASTER = $d012; byte* RASTER = $d012;
byte DARK_GREY = $b; byte DARK_GREY = $b;
byte BLACK = 0; byte BLACK = 0;
const void()** KERNEL_IRQ = $0314; void()** const KERNEL_IRQ = $0314;
void main() { void main() {

View File

@ -1,7 +1,7 @@
// Tests variable coalescing over assignments // Tests variable coalescing over assignments
void main() { void main() {
const byte* SCREEN = 0x0400; byte* const SCREEN = 0x0400;
byte idx = 0; byte idx = 0;
for( byte a: 0..5) { for( byte a: 0..5) {
for( byte b: 0..5) { for( byte b: 0..5) {

View File

@ -1,6 +1,6 @@
// Test code after return in main() // Test code after return in main()
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
char b = 0; char b = 0;

View File

@ -1,6 +1,6 @@
// Test code after return in main() // Test code after return in main()
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
void main() { void main() {
SCREEN[0] = 'a'; SCREEN[0] = 'a';

View File

@ -1,7 +1,7 @@
// Tests comma-separated declarations with different array-ness // Tests comma-separated declarations with different array-ness
void main() { void main() {
const char* SCREEN = $400; char* const SCREEN = $400;
char b, c[3], d; char b, c[3], d;
SCREEN[0] = b; SCREEN[0] = b;
SCREEN[1] = c[0]; SCREEN[1] = c[0];

View File

@ -1,7 +1,7 @@
// Tests comma-separated declarations inside for() // Tests comma-separated declarations inside for()
void main() { void main() {
const byte* SCREEN = $400; byte* const SCREEN = $400;
for(byte i, j='g'; i<10; i++, j++) { for(byte i, j='g'; i<10; i++, j++) {
SCREEN[i] = j; SCREEN[i] = j;
} }

View File

@ -1,7 +1,7 @@
// Tests comma-separated declarations // Tests comma-separated declarations
void main() { void main() {
const byte* SCREEN = $400; byte* const SCREEN = $400;
byte b = 'c', c = b+1, d = c+1; byte b = 'c', c = b+1, d = c+1;
SCREEN[0] = b; SCREEN[0] = b;
SCREEN[1] = c; SCREEN[1] = c;

View File

@ -1,7 +1,7 @@
// Tests simple comma-expression (in parenthesis) // Tests simple comma-expression (in parenthesis)
void main() { void main() {
const byte* SCREEN = $400; byte* const SCREEN = $400;
byte b = (1,2,3); byte b = (1,2,3);
byte c = (1+1,b+1); byte c = (1+1,b+1);
SCREEN[1,0] = c; SCREEN[1,0] = c;

View File

@ -1,7 +1,7 @@
// Tests simple comma-expressions (without parenthesis) // Tests simple comma-expressions (without parenthesis)
void main() { void main() {
const byte* SCREEN = $400; byte* const SCREEN = $400;
byte b; byte b;
byte c; byte c;
b = 1,2,3; b = 1,2,3;

View File

@ -1,7 +1,7 @@
// Tests comma-expressions in for()-statement // Tests comma-expressions in for()-statement
void main() { void main() {
const byte* SCREEN = $400; byte* const SCREEN = $400;
byte j='g'; byte j='g';
for( byte i=0; j<10, i<10; i++, j++) { for( byte i=0; j<10, i<10; i++, j++) {
SCREEN[i] = j; SCREEN[i] = j;

View File

@ -1,10 +1,10 @@
// Test rewriting of constant comparisons for pointers // Test rewriting of constant comparisons for pointers
void main() { void main() {
const byte* screen = $0400; byte* const screen = $0400;
for(byte* sc =screen;sc<=screen+999;sc++) *sc='a'; for(byte* sc =screen;sc<=screen+999;sc++) *sc='a';
const byte* cols = $d800; byte* const cols = $d800;
for(byte* cc =cols+999;cc>cols-1;cc--) *cc=2; for(byte* cc =cols+999;cc>cols-1;cc--) *cc=2;
} }

View File

@ -1,7 +1,7 @@
// Test rewriting of constant comparisons // Test rewriting of constant comparisons
void main() { void main() {
const byte* SCREEN = $0400; byte* const SCREEN = $0400;
for(byte* sc : SCREEN..SCREEN+1000) *sc=' '; for(byte* sc : SCREEN..SCREEN+1000) *sc=' ';

View File

@ -1,7 +1,7 @@
// Test to provoke Exception when using complex || condition // Test to provoke Exception when using complex || condition
const byte* RASTER = $d012; byte* const RASTER = $d012;
const byte* SCREEN = $0400; byte* const SCREEN = $0400;
void main() { void main() {
while(true) { while(true) {

View File

@ -4,7 +4,7 @@
#pragma link("ataritempest.ld") #pragma link("ataritempest.ld")
const char* BGCOL = 0xc01a; char* const BGCOL = 0xc01a;
#pragma data_seg(RomData) #pragma data_seg(RomData)
char MESSAGE[] = "hello world"; char MESSAGE[] = "hello world";
@ -25,4 +25,4 @@ void main() {
} }
#pragma data_seg(Vectors) #pragma data_seg(Vectors)
export const void()* VECTORS[] = { &nmiHandler, &entryPoint }; export void()* const VECTORS[] = { &nmiHandler, &entryPoint };

View File

@ -9,9 +9,9 @@ import "c64"
const bool DEBUG = false; const bool DEBUG = false;
// Address of the screen // Address of the screen
const byte* SCREEN = 0x0400; byte* const SCREEN = 0x0400;
// Sprite data for the animating sprites // Sprite data for the animating sprites
const byte* SPRITE_DATA = 0x2000; byte* const SPRITE_DATA = 0x2000;
// Values added to VX // Values added to VX
const unsigned int VXSIN[40] = kickasm {{ const unsigned int VXSIN[40] = kickasm {{
.for(var i=0; i<40; i++) { .for(var i=0; i<40; i++) {

View File

@ -29,13 +29,13 @@ signed char align(0x40) SIN[0x140] = kickasm {{
signed char* COS = SIN+$40; // sin(x) = cos(x+PI/2) signed char* COS = SIN+$40; // sin(x) = cos(x+PI/2)
// The BASIC screen // The BASIC screen
const char* BASIC_SCREEN = 0x0400; char* const BASIC_SCREEN = 0x0400;
// The BASIC charset // The BASIC charset
const char* BASIC_CHARSET = 0x1000; char* const BASIC_CHARSET = 0x1000;
// The BOB screen // The BOB screen
const char* BOB_SCREEN = 0x2800; char* const BOB_SCREEN = 0x2800;
// The BOB charset // The BOB charset
const char* BOB_CHARSET = 0x2000; char* const BOB_CHARSET = 0x2000;
// Tables containing the char to use for a specific cell of a shifted BOB. // Tables containing the char to use for a specific cell of a shifted BOB.
// char_id = BOB_TABLES[cell*BOB_SUBTABLE_SIZE + shift_y*BOB_SHIFTS_X + shift_x]; // char_id = BOB_TABLES[cell*BOB_SUBTABLE_SIZE + shift_y*BOB_SHIFTS_X + shift_x];

View File

@ -36,13 +36,13 @@ align(0x100) const char VOGEL_THETA[] = kickasm {{
align(0x100) const char VOGEL_R[] = kickasm {{ .fill 100, round(sqrt(i)*15) }}; align(0x100) const char VOGEL_R[] = kickasm {{ .fill 100, round(sqrt(i)*15) }};
// The BASIC screen // The BASIC screen
const char* SCREEN_BASIC = 0x0400; char* const SCREEN_BASIC = 0x0400;
// The BASIC charset // The BASIC charset
const char* CHARSET_BASIC = 0x1000; char* const CHARSET_BASIC = 0x1000;
// The BOB screen // The BOB screen
const char* BOB_SCREEN = 0x2800; char* const BOB_SCREEN = 0x2800;
// The BOB charset // The BOB charset
const char* BOB_CHARSET = 0x2000; char* const BOB_CHARSET = 0x2000;
// Tables containing the char to use for a specific cell of a shifted BOB. // Tables containing the char to use for a specific cell of a shifted BOB.
// char_id = BOB_TABLES[cell*BOB_SUBTABLE_SIZE + shift_y*BOB_SHIFTS_X + shift_x]; // char_id = BOB_TABLES[cell*BOB_SUBTABLE_SIZE + shift_y*BOB_SHIFTS_X + shift_x];

View File

@ -24,7 +24,7 @@ align(0x40) signed char SIN[0x140] = kickasm {{
signed char* COS = SIN+0x40; // sin(x) = cos(x+PI/2) signed char* COS = SIN+0x40; // sin(x) = cos(x+PI/2)
// The BASIC screen // The BASIC screen
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
// The number of BOBs to render // The number of BOBs to render
const char NUM_BOBS = 16; const char NUM_BOBS = 16;

View File

@ -7,9 +7,9 @@ import "print"
import "fastmultiply" import "fastmultiply"
import "c64" import "c64"
const char* PRINT_SCREEN = 0x0400; char* const PRINT_SCREEN = 0x0400;
const char* BITMAP_SCREEN = 0x5c00; char* const BITMAP_SCREEN = 0x5c00;
const char* BITMAP_GRAPHICS = 0x6000; char* const BITMAP_GRAPHICS = 0x6000;
// A segment of a spline // A segment of a spline
struct Segment { struct Segment {

View File

@ -1,8 +1,8 @@
// SID registers for random number generation // SID registers for random number generation
const unsigned int* SID_VOICE3_FREQ = 0xd40e; unsigned int* const SID_VOICE3_FREQ = 0xd40e;
const char* SID_VOICE3_FREQ_LOW = 0xd40e; char* const SID_VOICE3_FREQ_LOW = 0xd40e;
const char* SID_VOICE3_FREQ_HIGH = 0xd40f; char* const SID_VOICE3_FREQ_HIGH = 0xd40f;
const char* SID_VOICE3_CONTROL = 0xd412; char* const SID_VOICE3_CONTROL = 0xd412;
const char SID_CONTROL_NOISE = 0x80; const char SID_CONTROL_NOISE = 0x80;
const char SID_CONTROL_PULSE = 0x40; const char SID_CONTROL_PULSE = 0x40;
const char SID_CONTROL_SAWTOOTH = 0x20; const char SID_CONTROL_SAWTOOTH = 0x20;
@ -11,7 +11,7 @@ const char SID_CONTROL_TEST = 0x08;
const char SID_CONTROL_RING = 0x04; const char SID_CONTROL_RING = 0x04;
const char SID_CONTROL_SYNC = 0x02; const char SID_CONTROL_SYNC = 0x02;
const char SID_CONTROL_GATE = 0x01; const char SID_CONTROL_GATE = 0x01;
const char* SID_VOICE3_OSC = 0xd41b; char* const SID_VOICE3_OSC = 0xd41b;
// Initialize SID voice 3 for random number generation // Initialize SID voice 3 for random number generation
void sid_rnd_init() { void sid_rnd_init() {

View File

@ -2,17 +2,17 @@
// Memory Layout and Shared Data // Memory Layout and Shared Data
// Address of the first screen // Address of the first screen
const char* PLAYFIELD_SCREEN_1 = 0x0400; char* const PLAYFIELD_SCREEN_1 = 0x0400;
// Address of the second screen // Address of the second screen
const char* PLAYFIELD_SCREEN_2 = 0x2c00; char* const PLAYFIELD_SCREEN_2 = 0x2c00;
// Screen Sprite pointers on screen 1 // Screen Sprite pointers on screen 1
const char* PLAYFIELD_SPRITE_PTRS_1 = (PLAYFIELD_SCREEN_1+SPRITE_PTRS); char* const PLAYFIELD_SPRITE_PTRS_1 = (PLAYFIELD_SCREEN_1+SPRITE_PTRS);
// Screen Sprite pointers on screen 2 // Screen Sprite pointers on screen 2
const char* PLAYFIELD_SPRITE_PTRS_2 = (PLAYFIELD_SCREEN_2+SPRITE_PTRS); char* const PLAYFIELD_SPRITE_PTRS_2 = (PLAYFIELD_SCREEN_2+SPRITE_PTRS);
// Address of the sprites covering the playfield // Address of the sprites covering the playfield
const char* PLAYFIELD_SPRITES = 0x3000; char* const PLAYFIELD_SPRITES = 0x3000;
// Address of the charset // Address of the charset
const char* PLAYFIELD_CHARSET = 0x2800; char* const PLAYFIELD_CHARSET = 0x2800;
// The size of the playfield // The size of the playfield
const char PLAYFIELD_LINES = 22; const char PLAYFIELD_LINES = 22;

View File

@ -7,11 +7,11 @@ import "string"
#pragma link("xmega65.ld") #pragma link("xmega65.ld")
const char* RASTER = 0xd012; char* const RASTER = 0xd012;
const char* VIC_MEMORY = 0xd018; char* const VIC_MEMORY = 0xd018;
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
const char* BGCOL = 0xd021; char* const BGCOL = 0xd021;
const char* COLS = 0xd800; char* const COLS = 0xd800;
const char BLACK = 0; const char BLACK = 0;
const char WHITE = 1; const char WHITE = 1;

View File

@ -2,7 +2,7 @@
// Fill the palette values into // Fill the palette values into
void main() { void main() {
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
for(byte i:0..0xff) { for(byte i:0..0xff) {
(SCREEN+40*0)[i] = LOGO256_RED[i]; (SCREEN+40*0)[i] = LOGO256_RED[i];
(SCREEN+40*8)[i] = LOGO256_GREEN[i]; (SCREEN+40*8)[i] = LOGO256_GREEN[i];

View File

@ -1,7 +1,7 @@
// Tests using integer conditions in if() // Tests using integer conditions in if()
// This should produce '+ ++ ++' at the top of the screen // This should produce '+ ++ ++' at the top of the screen
const byte* SCREEN = 0x0400; byte* const SCREEN = 0x0400;
void main() { void main() {
byte idx = 0; byte idx = 0;

View File

@ -1,7 +1,7 @@
// Tests using integer conditions in if() // Tests using integer conditions in if()
// This should produce '0 0 0' at the top of the screen // This should produce '0 0 0' at the top of the screen
const byte* SCREEN = 0x0400; byte* const SCREEN = 0x0400;
void main() { void main() {
byte idx = 0; byte idx = 0;

View File

@ -1,7 +1,7 @@
// Tests using integer conditions in while() / for() / do..while // Tests using integer conditions in while() / for() / do..while
// This should produce 'ba ba ba' at the top of the screen // This should produce 'ba ba ba' at the top of the screen
const byte* SCREEN = 0x0400; byte* const SCREEN = 0x0400;
byte idx = 0; byte idx = 0;
void main() { void main() {

View File

@ -1,7 +1,7 @@
// Tests using integer conditions in ternary operator // Tests using integer conditions in ternary operator
// This should produce '++0++' at the top of the screen // This should produce '++0++' at the top of the screen
const byte* SCREEN = 0x0400; byte* const SCREEN = 0x0400;
void main() { void main() {
byte idx = 0; byte idx = 0;

View File

@ -1,7 +1,7 @@
// Tests using integer conditions in && and || operator // Tests using integer conditions in && and || operator
// This should produce '01010101', '00110011', '00010001', '01110111' at the top of the screen // This should produce '01010101', '00110011', '00010001', '01110111' at the top of the screen
const byte* SCREEN = 0x0400; byte* const SCREEN = 0x0400;
void main() { void main() {
byte idx = 0; byte idx = 0;

View File

@ -1,4 +1,4 @@
const byte* screen = $400; byte* const screen = $400;
void main() { void main() {
inline for( byte j: 0..1) { inline for( byte j: 0..1) {

View File

@ -3,7 +3,7 @@
void main() { void main() {
char bError = 7; char bError = 7;
bError &= ~(0x10 | 0x20 | 0x40); bError &= ~(0x10 | 0x20 | 0x40);
const char* screen = 0x0400; char* const screen = 0x0400;
*screen = bError; *screen = bError;
} }

View File

@ -1,7 +1,7 @@
// Ensure that if()'s with constant comparisons are identified and eliminated // Ensure that if()'s with constant comparisons are identified and eliminated
void main() { void main() {
const byte* SCREEN = $0400; byte* const SCREEN = $0400;
if(7<4) { if(7<4) {
SCREEN[0] = '*'; SCREEN[0] = '*';
} else { } else {

View File

@ -1,12 +1,12 @@
// Tests a number of constant declarations // Tests a number of constant declarations
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
const char LINE_LEN = 40; const char LINE_LEN = 40;
const char MARGIN_TOP = 4; const char MARGIN_TOP = 4;
const char MARGIN_LEFT = 4; const char MARGIN_LEFT = 4;
const unsigned int OFFSET = 40*5+5; const unsigned int OFFSET = 40*5+5;
const char* BODY1 = SCREEN+MARGIN_TOP*LINE_LEN+MARGIN_LEFT; char* const BODY1 = SCREEN+MARGIN_TOP*LINE_LEN+MARGIN_LEFT;
const char* BODY2 = SCREEN+OFFSET; char* const BODY2 = SCREEN+OFFSET;
void main() { void main() {
*BODY1 = '*'; *BODY1 = '*';

View File

@ -1,5 +1,5 @@
const byte* plots = $1000; byte* const plots = $1000;
const byte* SCREEN = $0400; byte* const SCREEN = $0400;
void main() { void main() {
for(byte i : 0..39) { for(byte i : 0..39) {

View File

@ -1,5 +1,5 @@
// Test a problem with converting casted constant numbers to fixed type constant integers // Test a problem with converting casted constant numbers to fixed type constant integers
const byte* SCREEN = $0400; byte* const SCREEN = $0400;
void main() { void main() {
for( byte i: 121..122) { for( byte i: 121..122) {

View File

@ -1,7 +1,7 @@
// Test that modifying constant pointers fail // Test that modifying constant pointers fail
void main() { void main() {
const byte* screen = $400; byte* const screen = $400;
screen[0] = 'c'; screen[0] = 'c';
screen++; screen++;
screen[0] = 'm'; screen[0] = 'm';

View File

@ -1,4 +1,4 @@
const byte* SCREEN = $0400; byte* const SCREEN = $0400;
void main() { void main() {
*SCREEN = 1; *SCREEN = 1;

View File

@ -1,4 +1,4 @@
const byte* SCREEN = $0400; byte* const SCREEN = $0400;
const byte STAR = 81; const byte STAR = 81;
byte* VIC = $d000; byte* VIC = $d000;

View File

@ -1,5 +1,5 @@
import "print.kc" import "print.kc"
const byte* BGCOL = $d021; byte* const BGCOL = $d021;
const byte GREEN = 5; const byte GREEN = 5;
const byte RED = 2 ; const byte RED = 2 ;

View File

@ -6,8 +6,8 @@ import "atan2"
import "c64" import "c64"
import "print" import "print"
const byte* CHARSET = 0x2000; byte* const CHARSET = 0x2000;
const byte* SCREEN = 0x2800; byte* const SCREEN = 0x2800;
const byte SCREEN_REF[1000] = kickasm {{ const byte SCREEN_REF[1000] = kickasm {{
.for(var y=-12;y<=12;y++) .for(var y=-12;y<=12;y++)

View File

@ -5,8 +5,8 @@ import "font-hex"
import "atan2" import "atan2"
import "c64" import "c64"
const byte* CHARSET = 0x2000; byte* const CHARSET = 0x2000;
const byte* SCREEN = 0x2800; byte* const SCREEN = 0x2800;
void main() { void main() {
init_font_hex(CHARSET); init_font_hex(CHARSET);

View File

@ -4,8 +4,8 @@ import "font-hex"
import "atan2" import "atan2"
import "c64" import "c64"
const byte* CHARSET = 0x2000; byte* const CHARSET = 0x2000;
const byte* SCREEN = 0x2800; byte* const SCREEN = 0x2800;
void main() { void main() {
init_font_hex(CHARSET); init_font_hex(CHARSET);

View File

@ -6,8 +6,8 @@ import "c64"
import "atan2" import "atan2"
const byte* CHARSET = 0x2000; byte* const CHARSET = 0x2000;
const byte* SCREEN = 0x2800; byte* const SCREEN = 0x2800;
void main() { void main() {
init_font_hex(CHARSET); init_font_hex(CHARSET);

View File

@ -4,7 +4,7 @@
#pragma cpu(MOS6502) #pragma cpu(MOS6502)
void main() { void main() {
const char* screen = 0x0400; char* const screen = 0x0400;
char c=0; char c=0;
while(c<100) { while(c<100) {
screen[c] = '*'; screen[c] = '*';

View File

@ -2,7 +2,7 @@
// https://www.protovision.games/hardw/build4player.php?language=en&fbclid=IwAR1MJLgQjOU0zVa0ax2aNeGa-xVbE9IGY9zC6b6eInTV4HQzoUAoCPoXu14 // https://www.protovision.games/hardw/build4player.php?language=en&fbclid=IwAR1MJLgQjOU0zVa0ax2aNeGa-xVbE9IGY9zC6b6eInTV4HQzoUAoCPoXu14
import "c64" import "c64"
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
void main() { void main() {
(*CIA2_PORT_B) &= 0x7f; (*CIA2_PORT_B) &= 0x7f;
asm { lda #0 } asm { lda #0 }

View File

@ -2,7 +2,7 @@
__mem __ma char idx; __mem __ma char idx;
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
void main() { void main() {
for( char i: 0..5 ) { for( char i: 0..5 ) {

View File

@ -4,7 +4,7 @@
__mem __ma char idx; __mem __ma char idx;
char* idx_p = &idx; char* idx_p = &idx;
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
void main() { void main() {
for( char i: 0..5 ) { for( char i: 0..5 ) {

View File

@ -1,7 +1,7 @@
// Test declaring a variable as "memory", meaning it will be stored in memory and accessed through an implicit pointer (using load/store) // Test declaring a variable as "memory", meaning it will be stored in memory and accessed through an implicit pointer (using load/store)
// Test a memory variable containing a pointer // Test a memory variable containing a pointer
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
__mem __ma char* cursor = SCREEN; __mem __ma char* cursor = SCREEN;

View File

@ -10,7 +10,7 @@ __mem __ma struct foo bar = { 'a', 'b' };
void main(void) { void main(void) {
struct foo* barp = &bar; struct foo* barp = &bar;
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
char i=0; char i=0;
SCREEN[i++] = barp->thing1; SCREEN[i++] = barp->thing1;
SCREEN[i++] = barp->thing2; SCREEN[i++] = barp->thing2;

View File

@ -11,7 +11,7 @@ __mem __ma struct foo bar = { 'a', 'b', "qwe" };
void main(void) { void main(void) {
struct foo* barp = &bar; struct foo* barp = &bar;
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
char i=0; char i=0;
SCREEN[i++] = barp->thing1; SCREEN[i++] = barp->thing1;
SCREEN[i++] = barp->thing2; SCREEN[i++] = barp->thing2;

View File

@ -9,7 +9,7 @@ struct foo {
__mem __ma struct foo bar = { 'a', 'b' }; __mem __ma struct foo bar = { 'a', 'b' };
void main(void) { void main(void) {
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
char i=0; char i=0;
SCREEN[i++] = bar.thing1; SCREEN[i++] = bar.thing1;
SCREEN[i++] = bar.thing2; SCREEN[i++] = bar.thing2;

View File

@ -1,6 +1,6 @@
// Test declaring a variable as "memory", meaning it will be stored in memory and accessed through an implicit pointer (using load/store) // Test declaring a variable as "memory", meaning it will be stored in memory and accessed through an implicit pointer (using load/store)
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
char i=0; char i=0;
void main(void) { void main(void) {

View File

@ -3,7 +3,7 @@
__ma char idx; __ma char idx;
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
void main() { void main() {
for( char i: 0..5 ) { for( char i: 0..5 ) {

View File

@ -3,7 +3,7 @@
__ma __address(0x1000) char idx; __ma __address(0x1000) char idx;
const char* SCREEN = 0x0400; char* const SCREEN = 0x0400;
void main() { void main() {
for( char i: 0..5 ) { for( char i: 0..5 ) {

View File

@ -3,10 +3,10 @@
char __ssa idx_ssa_g; char __ssa idx_ssa_g;
char __ma idx_nssa_g; char __ma idx_nssa_g;
const char* SCREEN1 = 0x0400; char* const SCREEN1 = 0x0400;
const char* SCREEN2 = 0x0400+40; char* const SCREEN2 = 0x0400+40;
const char* SCREEN3 = 0x0400+80; char* const SCREEN3 = 0x0400+80;
const char* SCREEN4 = 0x0400+120; char* const SCREEN4 = 0x0400+120;
void main() { void main() {
char __ssa idx_ssa_l; char __ssa idx_ssa_l;

View File

@ -8,7 +8,7 @@ void main() {
print(msg2); print(msg2);
} }
const word* SCREEN = $0400; word* const SCREEN = $0400;
byte screen_idx=0; byte screen_idx=0;
void print(byte* m) { void print(byte* m) {

View File

@ -8,7 +8,7 @@ void main() {
print(msg2); print(msg2);
} }
const byte* SCREEN = $0400; byte* const SCREEN = $0400;
byte idx=0; byte idx=0;
void print(byte* m) { void print(byte* m) {

View File

@ -1,7 +1,7 @@
// Tests that array-indexing by a word variable is turned into pointer addition // Tests that array-indexing by a word variable is turned into pointer addition
void main() { void main() {
const byte* screen = 0x0400; byte* const screen = 0x0400;
for( word i=0;i<1000;i+=40) { for( word i=0;i<1000;i+=40) {
screen[i] = 'a'; screen[i] = 'a';
} }

Some files were not shown because too many files have changed in this diff Show More