1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-26 03:32:23 +00:00

Renamed import to #include. #169

This commit is contained in:
jespergravgaard 2020-04-07 12:43:31 +02:00
parent d8138615ac
commit 682757b10c
161 changed files with 2526 additions and 2401 deletions

View File

@ -62,9 +62,7 @@ ASSIGN: '=' ;
ASSIGN_COMPOUND : '+=' | '-=' | '*=' | '/=' | '%=' | '<<=' | '>>=' | '&=' | '|=' | '^=' ;
// Keywords
IMPORT: 'import' { importEnter=true; } ;
TYPEDEF: 'typedef' ;
PRAGMA: '#pragma' ;
RESERVE:'reserve' ;
PC:'pc';
TARGET:'target';
@ -123,7 +121,10 @@ KICKASM_BODY: '{{' .*? '}}';
STRING : '"' ('\\"' | ~'"')* '"' [z]?([ps][mu]?)?[z]? { if(importEnter) { importEnter=false; cParser.loadCFile(getText()); } } ;
CHAR : '\'' ('\\'['"rfn] | ~'\'' ) '\'';
// Macros
// Preprocessor
IMPORT: '#import' { importEnter=true; } ;
INCLUDE: '#include' { importEnter=true; } ;
PRAGMA: '#pragma' ;
DEFINE: '#define' ;
DEFINE_CONTINUE: '\\\n' | '\\\r\n';
UNDEF: '#undef' ;

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -35,122 +35,123 @@ LOGIC_AND=34
LOGIC_OR=35
ASSIGN=36
ASSIGN_COMPOUND=37
IMPORT=38
TYPEDEF=39
PRAGMA=40
RESERVE=41
PC=42
TARGET=43
LINK=44
CPU=45
CODESEG=46
DATASEG=47
ENCODING=48
CONST=49
EXTERN=50
EXPORT=51
ALIGN=52
INLINE=53
VOLATILE=54
STATIC=55
INTERRUPT=56
REGISTER=57
ADDRESS=58
ADDRESS_ZEROPAGE=59
ADDRESS_MAINMEM=60
FORM_SSA=61
FORM_MA=62
CALLING=63
CALLINGCONVENTION=64
VARMODEL=65
IF=66
ELSE=67
WHILE=68
DO=69
FOR=70
SWITCH=71
RETURN=72
BREAK=73
CONTINUE=74
ASM=75
DEFAULT=76
CASE=77
STRUCT=78
ENUM=79
SIZEOF=80
TYPEID=81
DEFINED=82
KICKASM=83
RESOURCE=84
USES=85
CLOBBERS=86
BYTES=87
CYCLES=88
LOGIC_NOT=89
SIGNEDNESS=90
SIMPLETYPE=91
BOOLEAN=92
KICKASM_BODY=93
STRING=94
CHAR=95
DEFINE=96
DEFINE_CONTINUE=97
UNDEF=98
IFDEF=99
IFNDEF=100
IFIF=101
ELIF=102
IFELSE=103
ENDIF=104
NUMBER=105
NUMFLOAT=106
BINFLOAT=107
DECFLOAT=108
HEXFLOAT=109
NUMINT=110
BININTEGER=111
DECINTEGER=112
HEXINTEGER=113
NAME=114
WS=115
COMMENT_LINE=116
COMMENT_BLOCK=117
ASM_BYTE=118
ASM_MNEMONIC=119
ASM_IMM=120
ASM_COLON=121
ASM_COMMA=122
ASM_PAR_BEGIN=123
ASM_PAR_END=124
ASM_BRACKET_BEGIN=125
ASM_BRACKET_END=126
ASM_DOT=127
ASM_SHIFT_LEFT=128
ASM_SHIFT_RIGHT=129
ASM_PLUS=130
ASM_MINUS=131
ASM_LESS_THAN=132
ASM_GREATER_THAN=133
ASM_MULTIPLY=134
ASM_DIVIDE=135
ASM_CURLY_BEGIN=136
ASM_CURLY_END=137
ASM_NUMBER=138
ASM_NUMFLOAT=139
ASM_BINFLOAT=140
ASM_DECFLOAT=141
ASM_HEXFLOAT=142
ASM_NUMINT=143
ASM_BININTEGER=144
ASM_DECINTEGER=145
ASM_HEXINTEGER=146
ASM_CHAR=147
ASM_MULTI_REL=148
ASM_MULTI_NAME=149
ASM_NAME=150
ASM_WS=151
ASM_COMMENT_LINE=152
ASM_COMMENT_BLOCK=153
TYPEDEF=38
RESERVE=39
PC=40
TARGET=41
LINK=42
CPU=43
CODESEG=44
DATASEG=45
ENCODING=46
CONST=47
EXTERN=48
EXPORT=49
ALIGN=50
INLINE=51
VOLATILE=52
STATIC=53
INTERRUPT=54
REGISTER=55
ADDRESS=56
ADDRESS_ZEROPAGE=57
ADDRESS_MAINMEM=58
FORM_SSA=59
FORM_MA=60
CALLING=61
CALLINGCONVENTION=62
VARMODEL=63
IF=64
ELSE=65
WHILE=66
DO=67
FOR=68
SWITCH=69
RETURN=70
BREAK=71
CONTINUE=72
ASM=73
DEFAULT=74
CASE=75
STRUCT=76
ENUM=77
SIZEOF=78
TYPEID=79
DEFINED=80
KICKASM=81
RESOURCE=82
USES=83
CLOBBERS=84
BYTES=85
CYCLES=86
LOGIC_NOT=87
SIGNEDNESS=88
SIMPLETYPE=89
BOOLEAN=90
KICKASM_BODY=91
STRING=92
CHAR=93
IMPORT=94
INCLUDE=95
PRAGMA=96
DEFINE=97
DEFINE_CONTINUE=98
UNDEF=99
IFDEF=100
IFNDEF=101
IFIF=102
ELIF=103
IFELSE=104
ENDIF=105
NUMBER=106
NUMFLOAT=107
BINFLOAT=108
DECFLOAT=109
HEXFLOAT=110
NUMINT=111
BININTEGER=112
DECINTEGER=113
HEXINTEGER=114
NAME=115
WS=116
COMMENT_LINE=117
COMMENT_BLOCK=118
ASM_BYTE=119
ASM_MNEMONIC=120
ASM_IMM=121
ASM_COLON=122
ASM_COMMA=123
ASM_PAR_BEGIN=124
ASM_PAR_END=125
ASM_BRACKET_BEGIN=126
ASM_BRACKET_END=127
ASM_DOT=128
ASM_SHIFT_LEFT=129
ASM_SHIFT_RIGHT=130
ASM_PLUS=131
ASM_MINUS=132
ASM_LESS_THAN=133
ASM_GREATER_THAN=134
ASM_MULTIPLY=135
ASM_DIVIDE=136
ASM_CURLY_BEGIN=137
ASM_CURLY_END=138
ASM_NUMBER=139
ASM_NUMFLOAT=140
ASM_BINFLOAT=141
ASM_DECFLOAT=142
ASM_HEXFLOAT=143
ASM_NUMINT=144
ASM_BININTEGER=145
ASM_DECINTEGER=146
ASM_HEXINTEGER=147
ASM_CHAR=148
ASM_MULTI_REL=149
ASM_MULTI_NAME=150
ASM_NAME=151
ASM_WS=152
ASM_COMMENT_LINE=153
ASM_COMMENT_BLOCK=154
';'=8
'..'=11
'?'=12
@ -169,64 +170,65 @@ ASM_COMMENT_BLOCK=153
'&&'=34
'||'=35
'='=36
'import'=38
'typedef'=39
'#pragma'=40
'reserve'=41
'pc'=42
'target'=43
'link'=44
'cpu'=45
'code_seg'=46
'data_seg'=47
'encoding'=48
'const'=49
'extern'=50
'export'=51
'align'=52
'inline'=53
'volatile'=54
'static'=55
'interrupt'=56
'register'=57
'__address'=58
'__zp'=59
'__mem'=60
'__ssa'=61
'__ma'=62
'calling'=63
'var_model'=65
'if'=66
'else'=67
'while'=68
'do'=69
'for'=70
'switch'=71
'return'=72
'break'=73
'continue'=74
'asm'=75
'default'=76
'case'=77
'struct'=78
'enum'=79
'sizeof'=80
'typeid'=81
'defined'=82
'kickasm'=83
'resource'=84
'uses'=85
'clobbers'=86
'bytes'=87
'cycles'=88
'!'=89
'#define'=96
'#undef'=98
'#ifdef'=99
'#ifndef'=100
'#if'=101
'#elif'=102
'#else'=103
'#endif'=104
'.byte'=118
'#'=120
'typedef'=38
'reserve'=39
'pc'=40
'target'=41
'link'=42
'cpu'=43
'code_seg'=44
'data_seg'=45
'encoding'=46
'const'=47
'extern'=48
'export'=49
'align'=50
'inline'=51
'volatile'=52
'static'=53
'interrupt'=54
'register'=55
'__address'=56
'__zp'=57
'__mem'=58
'__ssa'=59
'__ma'=60
'calling'=61
'var_model'=63
'if'=64
'else'=65
'while'=66
'do'=67
'for'=68
'switch'=69
'return'=70
'break'=71
'continue'=72
'asm'=73
'default'=74
'case'=75
'struct'=76
'enum'=77
'sizeof'=78
'typeid'=79
'defined'=80
'kickasm'=81
'resource'=82
'uses'=83
'clobbers'=84
'bytes'=85
'cycles'=86
'!'=87
'#import'=94
'#include'=95
'#pragma'=96
'#define'=97
'#undef'=99
'#ifdef'=100
'#ifndef'=101
'#if'=102
'#elif'=103
'#else'=104
'#endif'=105
'.byte'=119
'#'=121

View File

@ -35,7 +35,8 @@ declOrImport
;
importDecl
: IMPORT STRING
: IMPORT STRING #importFile
| INCLUDE STRING #includeFile
;
decl

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -35,122 +35,123 @@ LOGIC_AND=34
LOGIC_OR=35
ASSIGN=36
ASSIGN_COMPOUND=37
IMPORT=38
TYPEDEF=39
PRAGMA=40
RESERVE=41
PC=42
TARGET=43
LINK=44
CPU=45
CODESEG=46
DATASEG=47
ENCODING=48
CONST=49
EXTERN=50
EXPORT=51
ALIGN=52
INLINE=53
VOLATILE=54
STATIC=55
INTERRUPT=56
REGISTER=57
ADDRESS=58
ADDRESS_ZEROPAGE=59
ADDRESS_MAINMEM=60
FORM_SSA=61
FORM_MA=62
CALLING=63
CALLINGCONVENTION=64
VARMODEL=65
IF=66
ELSE=67
WHILE=68
DO=69
FOR=70
SWITCH=71
RETURN=72
BREAK=73
CONTINUE=74
ASM=75
DEFAULT=76
CASE=77
STRUCT=78
ENUM=79
SIZEOF=80
TYPEID=81
DEFINED=82
KICKASM=83
RESOURCE=84
USES=85
CLOBBERS=86
BYTES=87
CYCLES=88
LOGIC_NOT=89
SIGNEDNESS=90
SIMPLETYPE=91
BOOLEAN=92
KICKASM_BODY=93
STRING=94
CHAR=95
DEFINE=96
DEFINE_CONTINUE=97
UNDEF=98
IFDEF=99
IFNDEF=100
IFIF=101
ELIF=102
IFELSE=103
ENDIF=104
NUMBER=105
NUMFLOAT=106
BINFLOAT=107
DECFLOAT=108
HEXFLOAT=109
NUMINT=110
BININTEGER=111
DECINTEGER=112
HEXINTEGER=113
NAME=114
WS=115
COMMENT_LINE=116
COMMENT_BLOCK=117
ASM_BYTE=118
ASM_MNEMONIC=119
ASM_IMM=120
ASM_COLON=121
ASM_COMMA=122
ASM_PAR_BEGIN=123
ASM_PAR_END=124
ASM_BRACKET_BEGIN=125
ASM_BRACKET_END=126
ASM_DOT=127
ASM_SHIFT_LEFT=128
ASM_SHIFT_RIGHT=129
ASM_PLUS=130
ASM_MINUS=131
ASM_LESS_THAN=132
ASM_GREATER_THAN=133
ASM_MULTIPLY=134
ASM_DIVIDE=135
ASM_CURLY_BEGIN=136
ASM_CURLY_END=137
ASM_NUMBER=138
ASM_NUMFLOAT=139
ASM_BINFLOAT=140
ASM_DECFLOAT=141
ASM_HEXFLOAT=142
ASM_NUMINT=143
ASM_BININTEGER=144
ASM_DECINTEGER=145
ASM_HEXINTEGER=146
ASM_CHAR=147
ASM_MULTI_REL=148
ASM_MULTI_NAME=149
ASM_NAME=150
ASM_WS=151
ASM_COMMENT_LINE=152
ASM_COMMENT_BLOCK=153
TYPEDEF=38
RESERVE=39
PC=40
TARGET=41
LINK=42
CPU=43
CODESEG=44
DATASEG=45
ENCODING=46
CONST=47
EXTERN=48
EXPORT=49
ALIGN=50
INLINE=51
VOLATILE=52
STATIC=53
INTERRUPT=54
REGISTER=55
ADDRESS=56
ADDRESS_ZEROPAGE=57
ADDRESS_MAINMEM=58
FORM_SSA=59
FORM_MA=60
CALLING=61
CALLINGCONVENTION=62
VARMODEL=63
IF=64
ELSE=65
WHILE=66
DO=67
FOR=68
SWITCH=69
RETURN=70
BREAK=71
CONTINUE=72
ASM=73
DEFAULT=74
CASE=75
STRUCT=76
ENUM=77
SIZEOF=78
TYPEID=79
DEFINED=80
KICKASM=81
RESOURCE=82
USES=83
CLOBBERS=84
BYTES=85
CYCLES=86
LOGIC_NOT=87
SIGNEDNESS=88
SIMPLETYPE=89
BOOLEAN=90
KICKASM_BODY=91
STRING=92
CHAR=93
IMPORT=94
INCLUDE=95
PRAGMA=96
DEFINE=97
DEFINE_CONTINUE=98
UNDEF=99
IFDEF=100
IFNDEF=101
IFIF=102
ELIF=103
IFELSE=104
ENDIF=105
NUMBER=106
NUMFLOAT=107
BINFLOAT=108
DECFLOAT=109
HEXFLOAT=110
NUMINT=111
BININTEGER=112
DECINTEGER=113
HEXINTEGER=114
NAME=115
WS=116
COMMENT_LINE=117
COMMENT_BLOCK=118
ASM_BYTE=119
ASM_MNEMONIC=120
ASM_IMM=121
ASM_COLON=122
ASM_COMMA=123
ASM_PAR_BEGIN=124
ASM_PAR_END=125
ASM_BRACKET_BEGIN=126
ASM_BRACKET_END=127
ASM_DOT=128
ASM_SHIFT_LEFT=129
ASM_SHIFT_RIGHT=130
ASM_PLUS=131
ASM_MINUS=132
ASM_LESS_THAN=133
ASM_GREATER_THAN=134
ASM_MULTIPLY=135
ASM_DIVIDE=136
ASM_CURLY_BEGIN=137
ASM_CURLY_END=138
ASM_NUMBER=139
ASM_NUMFLOAT=140
ASM_BINFLOAT=141
ASM_DECFLOAT=142
ASM_HEXFLOAT=143
ASM_NUMINT=144
ASM_BININTEGER=145
ASM_DECINTEGER=146
ASM_HEXINTEGER=147
ASM_CHAR=148
ASM_MULTI_REL=149
ASM_MULTI_NAME=150
ASM_NAME=151
ASM_WS=152
ASM_COMMENT_LINE=153
ASM_COMMENT_BLOCK=154
';'=8
'..'=11
'?'=12
@ -169,64 +170,65 @@ ASM_COMMENT_BLOCK=153
'&&'=34
'||'=35
'='=36
'import'=38
'typedef'=39
'#pragma'=40
'reserve'=41
'pc'=42
'target'=43
'link'=44
'cpu'=45
'code_seg'=46
'data_seg'=47
'encoding'=48
'const'=49
'extern'=50
'export'=51
'align'=52
'inline'=53
'volatile'=54
'static'=55
'interrupt'=56
'register'=57
'__address'=58
'__zp'=59
'__mem'=60
'__ssa'=61
'__ma'=62
'calling'=63
'var_model'=65
'if'=66
'else'=67
'while'=68
'do'=69
'for'=70
'switch'=71
'return'=72
'break'=73
'continue'=74
'asm'=75
'default'=76
'case'=77
'struct'=78
'enum'=79
'sizeof'=80
'typeid'=81
'defined'=82
'kickasm'=83
'resource'=84
'uses'=85
'clobbers'=86
'bytes'=87
'cycles'=88
'!'=89
'#define'=96
'#undef'=98
'#ifdef'=99
'#ifndef'=100
'#if'=101
'#elif'=102
'#else'=103
'#endif'=104
'.byte'=118
'#'=120
'typedef'=38
'reserve'=39
'pc'=40
'target'=41
'link'=42
'cpu'=43
'code_seg'=44
'data_seg'=45
'encoding'=46
'const'=47
'extern'=48
'export'=49
'align'=50
'inline'=51
'volatile'=52
'static'=53
'interrupt'=54
'register'=55
'__address'=56
'__zp'=57
'__mem'=58
'__ssa'=59
'__ma'=60
'calling'=61
'var_model'=63
'if'=64
'else'=65
'while'=66
'do'=67
'for'=68
'switch'=69
'return'=70
'break'=71
'continue'=72
'asm'=73
'default'=74
'case'=75
'struct'=76
'enum'=77
'sizeof'=78
'typeid'=79
'defined'=80
'kickasm'=81
'resource'=82
'uses'=83
'clobbers'=84
'bytes'=85
'cycles'=86
'!'=87
'#import'=94
'#include'=95
'#pragma'=96
'#define'=97
'#undef'=99
'#ifdef'=100
'#ifndef'=101
'#if'=102
'#elif'=103
'#else'=104
'#endif'=105
'.byte'=119
'#'=121

View File

@ -1,4 +1,4 @@
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickCParser.g4 by ANTLR 4.7.2
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.7.2
package dk.camelot64.kickc.parser;
@ -66,13 +66,25 @@ public class KickCParserBaseListener implements KickCParserListener {
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterImportDecl(KickCParser.ImportDeclContext ctx) { }
@Override public void enterImportFile(KickCParser.ImportFileContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitImportDecl(KickCParser.ImportDeclContext ctx) { }
@Override public void exitImportFile(KickCParser.ImportFileContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterIncludeFile(KickCParser.IncludeFileContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitIncludeFile(KickCParser.IncludeFileContext ctx) { }
/**
* {@inheritDoc}
*

View File

@ -1,4 +1,4 @@
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickCParser.g4 by ANTLR 4.7.2
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.7.2
package dk.camelot64.kickc.parser;
@ -47,7 +47,14 @@ public class KickCParserBaseVisitor<T> extends AbstractParseTreeVisitor<T> imple
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitImportDecl(KickCParser.ImportDeclContext ctx) { return visitChildren(ctx); }
@Override public T visitImportFile(KickCParser.ImportFileContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitIncludeFile(KickCParser.IncludeFileContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*

View File

@ -1,4 +1,4 @@
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickCParser.g4 by ANTLR 4.7.2
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.7.2
package dk.camelot64.kickc.parser;
@ -50,15 +50,29 @@ public interface KickCParserListener extends ParseTreeListener {
*/
void exitDeclOrImport(KickCParser.DeclOrImportContext ctx);
/**
* Enter a parse tree produced by {@link KickCParser#importDecl}.
* Enter a parse tree produced by the {@code importFile}
* labeled alternative in {@link KickCParser#importDecl}.
* @param ctx the parse tree
*/
void enterImportDecl(KickCParser.ImportDeclContext ctx);
void enterImportFile(KickCParser.ImportFileContext ctx);
/**
* Exit a parse tree produced by {@link KickCParser#importDecl}.
* Exit a parse tree produced by the {@code importFile}
* labeled alternative in {@link KickCParser#importDecl}.
* @param ctx the parse tree
*/
void exitImportDecl(KickCParser.ImportDeclContext ctx);
void exitImportFile(KickCParser.ImportFileContext ctx);
/**
* Enter a parse tree produced by the {@code includeFile}
* labeled alternative in {@link KickCParser#importDecl}.
* @param ctx the parse tree
*/
void enterIncludeFile(KickCParser.IncludeFileContext ctx);
/**
* Exit a parse tree produced by the {@code includeFile}
* labeled alternative in {@link KickCParser#importDecl}.
* @param ctx the parse tree
*/
void exitIncludeFile(KickCParser.IncludeFileContext ctx);
/**
* Enter a parse tree produced by {@link KickCParser#decl}.
* @param ctx the parse tree

View File

@ -1,4 +1,4 @@
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickCParser.g4 by ANTLR 4.7.2
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.7.2
package dk.camelot64.kickc.parser;
@ -37,11 +37,19 @@ public interface KickCParserVisitor<T> extends ParseTreeVisitor<T> {
*/
T visitDeclOrImport(KickCParser.DeclOrImportContext ctx);
/**
* Visit a parse tree produced by {@link KickCParser#importDecl}.
* Visit a parse tree produced by the {@code importFile}
* labeled alternative in {@link KickCParser#importDecl}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitImportDecl(KickCParser.ImportDeclContext ctx);
T visitImportFile(KickCParser.ImportFileContext ctx);
/**
* Visit a parse tree produced by the {@code includeFile}
* labeled alternative in {@link KickCParser#importDecl}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitIncludeFile(KickCParser.IncludeFileContext ctx);
/**
* Visit a parse tree produced by {@link KickCParser#decl}.
* @param ctx the parse tree

View File

@ -93,7 +93,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
}
@Override
public Object visitImportDecl(KickCParser.ImportDeclContext ctx) {
public Object visitImportFile(KickCParser.ImportFileContext ctx) {
String importName = ctx.STRING().getText();
String importFileName = importName.substring(1, importName.length() - 1);
if(program.getLog().isVerboseParse()) {
@ -102,6 +102,16 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
return null;
}
@Override
public Object visitIncludeFile(KickCParser.IncludeFileContext ctx) {
String includeName = ctx.STRING().getText();
String includeFileName = includeName.substring(1, includeName.length() - 1);
if(program.getLog().isVerboseParse()) {
program.getLog().append("Including " + includeFileName);
}
return null;
}
@Override
public Object visitGlobalDirectiveVarModel(KickCParser.GlobalDirectiveVarModelContext ctx) {
List<TerminalNode> settingNodes = new ArrayList<>(ctx.NAME());

View File

@ -1,5 +1,5 @@
// Simple single-color (320x200) bitmap routines
import "string"
#include "string"
// The adddress of the bitmap screen (used for colors)
byte* bitmap_screen;

View File

@ -4,7 +4,7 @@
// (J) https://www.c64-wiki.com/wiki/C64DTV_Programming_Guide
// (H) http://dtvhacking.cbm8bit.com/dtv_wiki/images/d/d9/Dtv_registers_full.txt
import "c64.kc"
#include "c64.kc"
// Feature enables or disables the extra C64 DTV features
byte* const DTV_FEATURE = $d03f;

View File

@ -16,7 +16,7 @@
// |7. | #%01111111 (127/$7f) | STOP ($ )| q ($11)|COMMODR($ )| SPACE ($20)| 2 ($32)|CONTROL($ )| <- ($1f)| 1 ($31)|
// +----+----------------------+------------+------------+------------+------------+------------+------------+------------+------------+
import "c64.kc"
#include "c64.kc"
// Keyboard Codes for all 63 keys.
// Keyboard Codes are %00rrrccc, where rrr is the row ID (0-7) and ccc is the column ID (0-7).

View File

@ -12,7 +12,7 @@
// In practice a good method is to wait until the raster is beyond plexFreeNextYpos() and then call plexShowSprite(). Repeat until all 32 sprites have been shown.
// TODO: Let the caller specify the number of sprites to use (or add PLEX_ENABLE[PLEX_COUNT])
import "c64"
#include "c64"
// The number of sprites in the multiplexer
const char PLEX_COUNT = 32;

View File

@ -1,5 +1,5 @@
import "stdlib"
import "string"
#include "stdlib"
#include "string"
byte* print_screen = $0400;
byte* print_line_cursor = print_screen;

View File

@ -4,8 +4,8 @@
// Uses the approximation sin(x) = x - x^/6 + x^/128
// Optimization possibility: Use symmetries when generating sinustables. wavelength%2==0 -> mirror symmetry over PI, wavelength%4==0 -> mirror symmetry over PI/2.
import "division.kc"
import "multiply.kc"
#include "division.kc"
#include "multiply.kc"
// PI*2 in u[4.28] format
const dword PI2_u4f28 = $6487ed51;

View File

@ -1,6 +1,6 @@
// Table-based implementation of integer square sqr() and square root sqrt()
import "stdlib"
#include "stdlib"
// The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
byte NUM_SQUARES = 0xff;

View File

@ -1,6 +1,6 @@
// C standard library stdlib.h
// Implementation of functions found int C stdlib.h / stdlib.c
import "string"
#include "string"
// Top of the heap used by malloc()
unsigned char* HEAP_TOP = 0xa000;

View File

@ -1,7 +1,7 @@
// C standard library time.h
// Functions to get and manipulate date and time information.
import "c64"
#include "c64"
// Type suitable for storing the processor time.
typedef unsigned long clock_t;

View File

@ -1,4 +1,4 @@
import "bgblacklib"
#include "bgblacklib"
void main() {
*BGCOL = BLACK;
}

View File

@ -1,4 +1,4 @@
import "c64"
#include "c64"
byte* const SCREEN = $400;
byte* const BITMAP = $2000;

View File

@ -2,7 +2,7 @@
// Coded by Richard-William Loerakker
// Original Source https://bcaorganizer.blogspot.com/p/c-program-for_21.html?fbclid=IwAR0iL8pYcCqhCPa6LmtQ9qej-YonYVepY2cBegYRIWO0l8RPeOnTVniMAac
import "c64"
#include "c64"
byte* const SCREEN = $400;
byte* const BITMAP = $2000;

View File

@ -1,8 +1,8 @@
// Illustrates problem with bitmap-draw.kc line()
// Reported by Janne Johansson
import "c64.kc"
import "bitmap-draw.kc"
#include "c64.kc"
#include "bitmap-draw.kc"
byte* const SCREEN = $400;
byte* const BITMAP = $2000;

View File

@ -1,8 +1,8 @@
// Shows that bitmap2.kc line() does not have the same problem as bitmap-draw.kc
// See bitmap-line-anim-1.kc
import "c64.kc"
import "bitmap2.kc"
#include "c64.kc"
#include "bitmap2.kc"
byte* const SCREEN = $400;
byte* const BITMAP = $2000;

View File

@ -1,7 +1,7 @@
// Tests the simple bitmap plotter - and counts plots per frame in an IRQ
// Plots simple plots
import "c64"
import "bitmap2"
#include "c64"
#include "bitmap2"
byte* BITMAP = 0x2000;
byte* SCREEN = 0x0400;

View File

@ -1,9 +1,9 @@
// Tests the simple bitmap plotter - and counts plots per frame in an IRQ
// Plots a fullscreen elipsis
import "c64"
import "sinus"
import "multiply"
import "bitmap2"
#include "c64"
#include "sinus"
#include "multiply"
#include "bitmap2"
byte* BITMAP = 0x2000;
byte* SCREEN = 0x0400;

View File

@ -1,9 +1,9 @@
// Tests the simple bitmap plotter - and counts plots per frame in an IRQ
// Plots a spiral
import "c64"
import "sinus"
import "multiply"
import "bitmap2"
#include "c64"
#include "sinus"
#include "multiply"
#include "bitmap2"
byte* BITMAP = 0x2000;
byte* SCREEN = 0x0400;

View File

@ -1,8 +1,8 @@
// Tests the simple bitmap plotter
// Plots a few lines using the bresenham line algorithm
import "c64"
import "bitmap2"
import "print"
#include "c64"
#include "bitmap2"
#include "print"
byte* BITMAP = 0x2000;
byte* SCREEN = 0x0400;

View File

@ -1,6 +1,6 @@
// Tests the different standard C types
import "print"
#include "print"
void main() {
print_cls();

View File

@ -1,5 +1,5 @@
// C64DTV 8bpp charmode stretcher
import "c64dtv.kc"
#include "c64dtv.kc"
// Plane with the screen
byte* const SCREEN = $7c00;

View File

@ -1,5 +1,5 @@
// C64DTV 8bpp charmode stretcher
import "c64dtv.kc"
#include "c64dtv.kc"
// Plane with all pixels
byte* const CHUNKY = $8000;

View File

@ -1,6 +1,6 @@
// Fill a box on the screen using the blitter
import "c64dtv.kc"
#include "c64dtv.kc"
byte* const SCREEN = $400;
const byte SRCA[] = "camelot rules!";

View File

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

View File

@ -1,6 +1,6 @@
// Test C64DTV v2 256-colors and the 16-color redefinable palette
import "c64dtv.kc"
#include "c64dtv.kc"
void main() {
asm { sei }

View File

@ -1,8 +1,8 @@
// Interactive Explorer for C64DTV Screen Modes
import "c64dtv.kc"
import "print.kc"
import "keyboard.kc"
import "bitmap-draw.kc"
#include "c64dtv.kc"
#include "print.kc"
#include "keyboard.kc"
#include "bitmap-draw.kc"
void main() {
asm { sei } // Disable normal interrupt (prevent keyboard reading glitches and allows to hide basic/kernal)

View File

@ -1,8 +1,8 @@
// Exploring C64DTV Screen Modes
import "c64dtv.kc"
import "print.kc"
import "keyboard.kc"
import "bitmap-draw.kc"
#include "c64dtv.kc"
#include "print.kc"
#include "keyboard.kc"
#include "bitmap-draw.kc"
void main() {
asm { sei } // Disable normal interrupt (prevent keyboard reading glitches and allows to hide basic/kernal)

View File

@ -1,8 +1,8 @@
// Counting cycles using a CIA timer
import "c64"
import "time"
import "print"
#include "c64"
#include "time"
#include "print"
byte* const SCREEN = 0x0400;

View File

@ -1,8 +1,8 @@
// Setup and run a simple CIA-timer
import "c64"
import "time"
import "print"
#include "c64"
#include "time"
#include "print"
byte* const SCREEN = 0x0400;

View File

@ -1,9 +1,9 @@
// Clears start screen throwing around the letters (by turning them into sprites)
import "stdlib"
import "sqr"
import "atan2"
import "multiply"
import "c64"
#include "stdlib"
#include "sqr"
#include "atan2"
#include "multiply"
#include "c64"
// Generate debug code (raster time usage etc.)
const bool DEBUG = false;

View File

@ -1,8 +1,8 @@
// Display MEDUSA PETSCII by Buzz_clik
// https://csdb.dk/release/?id=178673
import "c64"
import "string"
#include "c64"
#include "string"
char MEDUSA_SCREEN[1000] = kickasm(resource "medusas.prg" ) {{
.var fileScreen = LoadBinary("medusas.prg", BF_C64FILE)

View File

@ -1,10 +1,10 @@
// Pre-calculated bobs inside a charset (pre-moved to all x/y-combinations)
import "c64"
import "string"
import "keyboard"
import "time"
import "print"
import "fastmultiply"
#include "c64"
#include "string"
#include "keyboard"
#include "time"
#include "print"
#include "fastmultiply"
// The prototype BOB (a 3x3 char image with a bob image in the upper 2x2 chars)
// The chars are layout as follows with data in chars 0, 1, 3, 4 initially

View File

@ -1,10 +1,10 @@
// Pre-calculated bobs inside a charset (pre-moved to all x/y-combinations)
import "c64"
import "string"
import "keyboard"
import "time"
import "print"
import "fastmultiply"
#include "c64"
#include "string"
#include "keyboard"
#include "time"
#include "print"
#include "fastmultiply"
// The prototype BOB (a 3x3 char image with a bob image in the upper 2x2 chars)
// The chars are layout as follows with data in chars 0, 1, 3, 4 initially

View File

@ -1,9 +1,9 @@
// Same animation using a multiplexer
import "c64"
import "multiplexer"
import "fastmultiply"
import "string"
import "keyboard"
#include "c64"
#include "multiplexer"
#include "fastmultiply"
#include "string"
#include "keyboard"
// The BOB sprite
align(0x1000) char SPRITE[] = kickasm(resource "smiley.png") {{

View File

@ -1,11 +1,11 @@
// Show a few simple splines using the splines library
import "splines"
import "bitmap2"
import "time"
import "print"
import "fastmultiply"
import "c64"
#include "splines"
#include "bitmap2"
#include "time"
#include "print"
#include "fastmultiply"
#include "c64"
char* const PRINT_SCREEN = 0x0400;
char* const BITMAP_SCREEN = 0x5c00;

View File

@ -1,6 +1,6 @@
// Put a 2x2 font into sprites and show it on screen
import "c64"
import "multiplexer"
#include "c64"
#include "multiplexer"
char * const CHARSET_DEFAULT = 0x1000;
char * const SPRITES = 0x3000;

View File

@ -1,4 +1,4 @@
import "tetris-sprites"
#include "tetris-sprites"
char SIN[256] = kickasm {{
.var AMPL = 200-21

View File

@ -2,8 +2,8 @@
// Implementation of the tetris game play logic. Most of the logic is modelled after NES tetris
// Source: https://meatfighter.com/nintendotetrisai/
import "tetris-data"
import "tetris-pieces"
#include "tetris-data"
#include "tetris-pieces"
// Pointers to the playfield address for each playfield line
char* playfield_lines[PLAYFIELD_LINES];

View File

@ -2,8 +2,8 @@
// All rendering logic for showing the playfield, the pieces and the scores
// Also handles double buffering
import "tetris-data"
import "tetris-pieces"
#include "tetris-data"
#include "tetris-pieces"
kickasm(pc PLAYFIELD_CHARSET, resource "playfield-screen.imap") {{
.fill 8,$00 // Place a filled char at the start of the charset

View File

@ -1,7 +1,7 @@
// Tetris Game for the Commodore 64
// A sprite multiplexer covering the playfield with a black layer to allow for 3 single-pixel colors
import "c64"
import "tetris-data"
#include "c64"
#include "tetris-data"
kickasm(pc PLAYFIELD_SPRITES, resource "playfield-sprites.png") {{
.var sprites = LoadPicture("playfield-sprites.png", List().add($010101, $000000))

View File

@ -2,13 +2,13 @@
// The tetris game tries to match NES tetris gameplay pretty closely
// Source: https://meatfighter.com/nintendotetrisai/
import "c64"
import "keyboard"
import "sid"
import "tetris-data"
import "tetris-render"
import "tetris-sprites"
import "tetris-play"
#include "c64"
#include "keyboard"
#include "sid"
#include "tetris-data"
#include "tetris-render"
#include "tetris-sprites"
#include "tetris-play"
void main() {
sid_rnd_init();

View File

@ -1,5 +1,5 @@
import "c64.kc"
import "print"
#include "c64.kc"
#include "print"
byte* SCREEN = $0400;

View File

@ -2,7 +2,7 @@
// Each function of the kernal is a no-args function
// The functions are placed in the SYSCALLS table surrounded by JMP and NOP
import "string"
#include "string"
#pragma link("xmega65.ld")

View File

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

View File

@ -1,10 +1,10 @@
// Find atan2(x, y) using the CORDIC method
// See http://bsvi.ru/uploads/CORDIC--_10EBA/cordic.pdf
import "font-hex"
import "atan2"
import "c64"
import "print"
#include "font-hex"
#include "atan2"
#include "c64"
#include "print"
byte* const CHARSET = 0x2000;
byte* const SCREEN = 0x2800;

View File

@ -1,9 +1,9 @@
// Find atan2(x, y) using the CORDIC method
// See http://bsvi.ru/uploads/CORDIC--_10EBA/cordic.pdf
import "font-hex"
import "atan2"
import "c64"
#include "font-hex"
#include "atan2"
#include "c64"
byte* const CHARSET = 0x2000;
byte* const SCREEN = 0x2800;

View File

@ -1,8 +1,8 @@
// Find atan2(x, y) using the CORDIC method
// See http://bsvi.ru/uploads/CORDIC--_10EBA/cordic.pdf
import "font-hex"
import "atan2"
import "c64"
#include "font-hex"
#include "atan2"
#include "c64"
byte* const CHARSET = 0x2000;
byte* const SCREEN = 0x2800;

View File

@ -1,9 +1,9 @@
// Find atan2(x, y) using the CORDIC method
// See http://bsvi.ru/uploads/CORDIC--_10EBA/cordic.pdf
import "font-hex"
import "c64"
import "atan2"
#include "font-hex"
#include "c64"
#include "atan2"
byte* const CHARSET = 0x2000;

View File

@ -1,7 +1,7 @@
// Tests problem writing/reading joystick encountered by Danny Spijksma
// https://www.protovision.games/hardw/build4player.php?language=en&fbclid=IwAR1MJLgQjOU0zVa0ax2aNeGa-xVbE9IGY9zC6b6eInTV4HQzoUAoCPoXu14
import "c64"
#include "c64"
char* const SCREEN = 0x0400;
void main() {
(*CIA2_PORT_B) &= 0x7f;

View File

@ -1,6 +1,6 @@
// Show default font on screen
import "string"
#include "string"
byte* SCREEN = 0x0400;

View File

@ -1,5 +1,5 @@
import "imported"
import "imported"
#include "imported"
#include "imported"
void main() {
*BGCOL = RED;

View File

@ -4,7 +4,7 @@
* Based on facebook post from
*/
import "print"
#include "print"
void main () {
print_cls();

View File

@ -2,8 +2,8 @@
// Based on:
// - C= Hacking Magazine Issue 8. http://www.ffd2.com/fridge/chacking/c=hacking8.txt
// - Codebase64 Article http://codebase64.org/doku.php?id=base:3d_rotation
import "c64"
import "print"
#include "c64"
#include "print"
// The rotated point - updated by calling rotate_matrix()
signed char* xr = $f0;

View File

@ -2,8 +2,8 @@
// Based on:
// - C= Hacking Magazine Issue 8. http://www.ffd2.com/fridge/chacking/c=hacking8.txt
// - Codebase64 Article http://codebase64.org/doku.php?id=base:3d_rotation
import "c64"
import "print"
#include "c64"
#include "print"
// The rotated point - updated by calling rotate()
signed char* xr = $f0;

View File

@ -1,5 +1,5 @@
import "c64.kc"
import "bitmap-draw.kc"
#include "c64.kc"
#include "bitmap-draw.kc"
char* const SCREEN = $400;
char* const BITMAP = $2000;

View File

@ -1,6 +1,6 @@
// Allows analysis of the CHARGEN ROM font
import "c64.kc"
import "keyboard.kc"
#include "c64.kc"
#include "keyboard.kc"
char* SCREEN = $400;

View File

@ -6,7 +6,7 @@
// - http://codebase64.org/doku.php?id=base:seriously_fast_multiplication
// - http://codebase64.org/doku.php?id=magazines:chacking16
import "print.kc"
#include "print.kc"
signed char vals[] = {-95, -64, -32, -16, 0, 16, 32, 64, 95};

View File

@ -4,8 +4,8 @@
// Ported to KickC by Jesper Gravgaard.
// Original source https://github.com/cc65/cc65/blob/master/samples/fire.c
import "c64"
import "sid"
#include "c64"
#include "sid"
unsigned char* SCREEN1 = 0x3800;
unsigned char* SCREEN2 = 0x3c00;

View File

@ -1,7 +1,7 @@
// Creates a 2x2 font from the system CHARGEN font and compress it by identifying identical chars
import "c64"
import "string"
#include "c64"
#include "string"
char* const SCREEN = 0x0400;
char* const FONT_ORIGINAL = 0x2000;

View File

@ -1,4 +1,4 @@
import "print"
#include "print"
void main() {
print_str("hello world!");
print_ln();

View File

@ -1,5 +1,5 @@
// A raster IRQ that opens the top/bottom border.
import "c64.kc"
#include "c64.kc"
char* const GHOST_BYTE = $3fff;

View File

@ -3,8 +3,8 @@
// To execute the program succesfully you must mount the D64 disk image and execute the kernalload.PRG program
#pragma link("kernalload.ld")
import "string"
import "c64"
#include "string"
#include "c64"
// Sprite file
#pragma data_seg(Sprite)

View File

@ -1,6 +1,6 @@
// A simple usage of the flexible sprite multiplexer routine
import "c64"
import "multiplexer"
#include "c64"
#include "multiplexer"
// Location of screen & sprites
char* SCREEN = $400;

View File

@ -1,5 +1,5 @@
// A simple SID music player playing music in the main loop.
import "c64.kc"
#include "c64.kc"
char* const MUSIC = $1000;

View File

@ -1,5 +1,5 @@
// A simple SID music player using RASTER IRQ
import "c64.kc"
#include "c64.kc"
char* const MUSIC = $1000;

View File

@ -2,7 +2,7 @@
// Code by Scan of Desire (Richard-William Loerakker)
// Sample from ART OF NOISE: MOMENTS IN LOVE
import "c64"
#include "c64"
const unsigned int SAMPLE_SIZE = 0x6100;
char SAMPLE[SAMPLE_SIZE] = kickasm(resource "moments_sample.bin") {{ .import binary "moments_sample.bin" }};

View File

@ -6,9 +6,9 @@
// Ported to KickC by Jesper Gravgaard.
// Original source https://github.com/cc65/cc65/blob/master/samples/plasma.c
import "c64"
import "print"
import "sid"
#include "c64"
#include "print"
#include "sid"
unsigned char* const SCREEN1 = $2800;
unsigned char* const CHARSET = $2000;

View File

@ -4,9 +4,9 @@
// Ported to KickC by Jesper Gravgaard.
// Original source https://github.com/cc65/cc65/blob/master/samples/plasma.c
import "c64"
import "print"
import "sid"
#include "c64"
#include "print"
#include "sid"
char* const SCREEN1 = 0x2800;
char* const SCREEN2 = 0x2c00;

View File

@ -1,4 +1,4 @@
import "c64.kc"
#include "c64.kc"
void main() {
asm {

View File

@ -1,9 +1,9 @@
// 2D rotattion of 8 sprites
import "c64"
import "fastmultiply"
import "time"
import "print"
#include "c64"
#include "fastmultiply"
#include "time"
#include "print"
char* SCREEN = $0400;

View File

@ -1,6 +1,6 @@
import "c64.kc"
import "sinus.kc"
import "string.kc"
#include "c64.kc"
#include "sinus.kc"
#include "string.kc"
char* SCREEN = $400;
char* LOGO = $2000;

View File

@ -1,5 +1,5 @@
import "c64.kc"
import "string"
#include "c64.kc"
#include "string"
char* SCREEN = $400;
char* LOGO = $2000;

View File

@ -1,9 +1,9 @@
// Generate a big sinus and plot it on a bitmap
import "c64.kc"
import "sinus.kc"
import "string.kc"
import "bitmap2.kc"
#include "c64.kc"
#include "sinus.kc"
#include "string.kc"
#include "bitmap2.kc"
char* SCREEN = $400;
char* BITMAP = $2000;

View File

@ -1,6 +1,6 @@
import "c64"
import "basic-floats"
import "print"
#include "c64"
#include "basic-floats"
#include "print"
const char sinlen_x = 221;
const char sintab_x[221];

View File

@ -4,7 +4,7 @@
// Uses principles from C=Hacking #16 https://codebase64.org/doku.php?id=magazines:chacking16
// Utilizes the fact that a*b = ((a+b)/2)^2 - ((a-b)/2)^2
import "print"
#include "print"
void main() {
print_cls();

View File

@ -1,7 +1,7 @@
// Shows a font where each char contains the number of the char (00-ff)
import "c64"
import "string"
import "font-hex"
#include "c64"
#include "string"
#include "font-hex"
byte* SCREEN = 0x0400;
byte* CHARSET = 0x2000;

View File

@ -1,6 +1,6 @@
// Test minimization of constants
import "c64"
#include "c64"
void main() {
byte* const PLAYFIELD_CHARSET = $2800;

View File

@ -1,4 +1,4 @@
import "imported.kc"
#include "imported.kc"
void main() {
byte* screen = $0400;

View File

@ -1,4 +1,4 @@
import "print.kc"
#include "print.kc"
byte txt[] = "camelot";

View File

@ -1,5 +1,5 @@
// A minimal working raster hardware IRQ with clobber-based register savings
import "c64"
#include "c64"
void main() {
asm { sei }

View File

@ -1,5 +1,5 @@
// Test interrupt routine using a variable between calls (irq_idx)
import "c64"
#include "c64"
byte* const SCREEN = $0400;

View File

@ -1,6 +1,6 @@
// A minimal working IRQ
import "c64"
#include "c64"
// Setup the IRQ routine
void main() {

View File

@ -5,8 +5,8 @@
// Press "C" to enter pressed state (increaded bgcol) - and "SPACE" to leave presssed state again.
// Holding SPACE will sometimes trigger the pressed state when normal interrupts are enabled (green border)
// but never when they are disabled (red border)
import "keyboard.kc"
import "c64.kc"
#include "keyboard.kc"
#include "c64.kc"
void main() {
*BORDERCOL = GREEN;

View File

@ -1,6 +1,6 @@
// Animated lines drawn on a single color bitmap
import "c64.kc"
import "division.kc"
#include "c64.kc"
#include "division.kc"
byte* BITMAP = $a000;
byte* SCREEN = $8800;

View File

@ -1,7 +1,7 @@
// Linear table generator
// Work in progress towards a sinus generator
import "division.kc"
import "print.kc"
#include "division.kc"
#include "print.kc"
void main() {
word lintab1[20];

View File

@ -8,7 +8,7 @@
// 2.8212026 23111.2917 23111
// -1.7417939 -14268.77563 -14269
import "multiply"
#include "multiply"
void main() {

View File

@ -1,8 +1,8 @@
// Program where loop-head optimization produces wrong return value
// Reported by Richard-William Loerakker
import "c64"
import "multiply"
#include "c64"
#include "multiply"
void main() {
dword result = mul16u(4,123);

View File

@ -1,6 +1,6 @@
// Experiments with malloc() - a byte array
import "stdlib"
#include "stdlib"
byte* BYTES = malloc(0x100);

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