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

Changed code to standard C array syntax char x[8].

This commit is contained in:
jespergravgaard 2020-03-26 12:03:21 +01:00
parent 6894f0bd7c
commit d3012e92d1
11 changed files with 39 additions and 38 deletions

View File

@ -1566,6 +1566,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
@Override @Override
public SymbolType visitTypeArray(KickCParser.TypeArrayContext ctx) { public SymbolType visitTypeArray(KickCParser.TypeArrayContext ctx) {
// throw new CompileError("Non-standard array declaration ", new StatementSource(ctx));
SymbolType elementType = (SymbolType) visit(ctx.typeDecl()); SymbolType elementType = (SymbolType) visit(ctx.typeDecl());
if(ctx.expr() != null) { if(ctx.expr() != null) {
RValue sizeVal = (RValue) visit(ctx.expr()); RValue sizeVal = (RValue) visit(ctx.expr());

View File

@ -5,7 +5,7 @@
const byte CORDIC_ITERATIONS_16 = 15; const byte CORDIC_ITERATIONS_16 = 15;
// Angles representing ATAN(0.5), ATAN(0.25), ATAN(0.125), ... // Angles representing ATAN(0.5), ATAN(0.25), ATAN(0.125), ...
word[CORDIC_ITERATIONS_16] CORDIC_ATAN2_ANGLES_16 = kickasm {{ word CORDIC_ATAN2_ANGLES_16[CORDIC_ITERATIONS_16] = kickasm {{
.for (var i=0; i<CORDIC_ITERATIONS_16; i++) .for (var i=0; i<CORDIC_ITERATIONS_16; i++)
.word 256*2*256*atan(1/pow(2,i))/PI/2 .word 256*2*256*atan(1/pow(2,i))/PI/2
}}; }};
@ -56,7 +56,7 @@ word atan2_16(signed word x, signed word y) {
const byte CORDIC_ITERATIONS_8 = 8; const byte CORDIC_ITERATIONS_8 = 8;
// Angles representing ATAN(0.5), ATAN(0.25), ATAN(0.125), ... // Angles representing ATAN(0.5), ATAN(0.25), ATAN(0.125), ...
byte[CORDIC_ITERATIONS_8] CORDIC_ATAN2_ANGLES_8 = kickasm {{ byte CORDIC_ATAN2_ANGLES_8[CORDIC_ITERATIONS_8] = kickasm {{
.fill CORDIC_ITERATIONS_8, 2*256*atan(1/pow(2,i))/PI/2 .fill CORDIC_ITERATIONS_8, 2*256*atan(1/pow(2,i))/PI/2
}}; }};

View File

@ -2,11 +2,11 @@
// Currently it can only plot on the first 256 x-positions. // Currently it can only plot on the first 256 x-positions.
// Tables for the plotter - initialized by calling bitmap_draw_init(); // Tables for the plotter - initialized by calling bitmap_draw_init();
const byte[256] bitmap_plot_xlo; const byte bitmap_plot_xlo[256];
const byte[256] bitmap_plot_xhi; const byte bitmap_plot_xhi[256];
const byte[256] bitmap_plot_ylo; const byte bitmap_plot_ylo[256];
const byte[256] bitmap_plot_yhi; const byte bitmap_plot_yhi[256];
const byte[256] bitmap_plot_bit; const byte bitmap_plot_bit[256];
// Initialize the bitmap plotter tables for a specific bitmap // Initialize the bitmap plotter tables for a specific bitmap
void bitmap_init(byte* bitmap) { void bitmap_init(byte* bitmap) {

View File

@ -7,9 +7,9 @@ byte* bitmap_screen;
byte* bitmap_gfx; byte* bitmap_gfx;
// Tables for the plotter - initialized by calling bitmap_init(); // Tables for the plotter - initialized by calling bitmap_init();
const byte[256] bitmap_plot_ylo; const byte bitmap_plot_ylo[256];
const byte[256] bitmap_plot_yhi; const byte bitmap_plot_yhi[256];
const byte[256] bitmap_plot_bit; const byte bitmap_plot_bit[256];
// Initialize bitmap plotting tables // Initialize bitmap plotting tables
void bitmap_init(byte* gfx, byte* screen) { void bitmap_init(byte* gfx, byte* screen) {

View File

@ -25,7 +25,7 @@ const byte DTV_CHUNKY = $40;
const byte* DTV_PALETTE = $d200; const byte* DTV_PALETTE = $d200;
// Default vallues for the palette // Default vallues for the palette
byte[16] DTV_PALETTE_DEFAULT = { $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; const byte* DTV_PLANEA_START_LO = $d03a;

View File

@ -4,13 +4,13 @@
// mulf_sqr tables will contain f(x)=int(x*x/4) and g(x) = f(x-255). // mulf_sqr tables will contain f(x)=int(x*x/4) and g(x) = f(x-255).
// <f(x) = <(( x * x )/4) // <f(x) = <(( x * x )/4)
byte[512] align($100) mulf_sqr1_lo; byte align($100) mulf_sqr1_lo[512];
// >f(x) = >(( x * x )/4) // >f(x) = >(( x * x )/4)
byte[512] align($100) mulf_sqr1_hi; byte align($100) mulf_sqr1_hi[512];
// <g(x) = <((( x - 255) * ( x - 255 ))/4) // <g(x) = <((( x - 255) * ( x - 255 ))/4)
byte[512] align($100) mulf_sqr2_lo; byte align($100) mulf_sqr2_lo[512];
// >g(x) = >((( x - 255) * ( x - 255 ))/4) // >g(x) = >((( x - 255) * ( x - 255 ))/4)
byte[512] align($100) mulf_sqr2_hi; byte align($100) mulf_sqr2_hi[512];
// Initialize the mulf_sqr multiplication tables with f(x)=int(x*x/4) // Initialize the mulf_sqr multiplication tables with f(x)=int(x*x/4)
void mulf_init() { void mulf_init() {

View File

@ -88,7 +88,7 @@ const byte KEY_RUNSTOP = $3f;
// Keycodes for each screen code character from $00-$3f. // Keycodes for each screen code character from $00-$3f.
// Chars that do not have an unmodified keycode return $3f (representing RUN/STOP). // Chars that do not have an unmodified keycode return $3f (representing RUN/STOP).
const byte[] keyboard_char_keycodes = { const byte keyboard_char_keycodes[] = {
/*@*/KEY_AT, /*a*/KEY_A, /*b*/KEY_B, /*c*/KEY_C, /*d*/KEY_D, /*e*/KEY_E, /*f*/KEY_F, /*g*/KEY_G, /*@*/KEY_AT, /*a*/KEY_A, /*b*/KEY_B, /*c*/KEY_C, /*d*/KEY_D, /*e*/KEY_E, /*f*/KEY_F, /*g*/KEY_G,
/*h*/KEY_H, /*i*/KEY_I, /*j*/KEY_J, /*k*/KEY_K, /*l*/KEY_L, /*m*/KEY_M, /*n*/KEY_N, /*o*/KEY_O, /*h*/KEY_H, /*i*/KEY_I, /*j*/KEY_J, /*k*/KEY_K, /*l*/KEY_L, /*m*/KEY_M, /*n*/KEY_N, /*o*/KEY_O,
/*p*/KEY_P, /*q*/KEY_Q, /*r*/KEY_R, /*s*/KEY_S, /*t*/KEY_T, /*u*/KEY_U, /*v*/KEY_V, /*w*/KEY_W, /*p*/KEY_P, /*q*/KEY_Q, /*r*/KEY_R, /*s*/KEY_S, /*t*/KEY_T, /*u*/KEY_U, /*v*/KEY_V, /*w*/KEY_W,
@ -100,10 +100,10 @@ const byte[] keyboard_char_keycodes = {
}; };
// Keyboard row bitmask as expected by CIA#1 Port A when reading a specific keyboard matrix row (rows are numbered 0-7) // Keyboard row bitmask as expected by CIA#1 Port A when reading a specific keyboard matrix row (rows are numbered 0-7)
byte[8] keyboard_matrix_row_bitmask = { %11111110, %11111101, %11111011, %11110111, %11101111, %11011111, %10111111, %01111111 }; byte keyboard_matrix_row_bitmask[8] = { %11111110, %11111101, %11111011, %11110111, %11101111, %11011111, %10111111, %01111111 };
// Keyboard matrix column bitmasks for a specific keybooard matrix column when reading the keyboard. (columns are numbered 0-7) // Keyboard matrix column bitmasks for a specific keybooard matrix column when reading the keyboard. (columns are numbered 0-7)
byte[8] keyboard_matrix_col_bitmask = { %00000001, %00000010, %00000100, %00001000, %00010000, %00100000, %01000000, %10000000 }; byte keyboard_matrix_col_bitmask[8] = { %00000001, %00000010, %00000100, %00001000, %00010000, %00100000, %01000000, %10000000 };
// Initialize keyboard reading by setting CIA#$ Data Direction Registers // Initialize keyboard reading by setting CIA#$ Data Direction Registers
void keyboard_init() { void keyboard_init() {
@ -142,7 +142,7 @@ byte keyboard_get_keycode(byte ch) {
} }
// Keyboard event buffer. Contains keycodes for key presses/releases. Presses are represented by the keycode. Releases by keycode | $40. The buffer is filled by keyboard_scan() // Keyboard event buffer. Contains keycodes for key presses/releases. Presses are represented by the keycode. Releases by keycode | $40. The buffer is filled by keyboard_scan()
byte[8] keyboard_events; byte keyboard_events[8];
// Keyboard event buffer size. The number of events currently in the event buffer // Keyboard event buffer size. The number of events currently in the event buffer
byte keyboard_events_size = 0; byte keyboard_events_size = 0;
// Current keyboard modifiers (left shift, right shift, ctrl, commodore) // Current keyboard modifiers (left shift, right shift, ctrl, commodore)
@ -158,7 +158,7 @@ const byte KEY_MODIFIER_COMMODORE = 8;
// Any shift is pressed // Any shift is pressed
const byte KEY_MODIFIER_SHIFT = KEY_MODIFIER_LSHIFT|KEY_MODIFIER_RSHIFT; const byte KEY_MODIFIER_SHIFT = KEY_MODIFIER_LSHIFT|KEY_MODIFIER_RSHIFT;
// The values scanned values for each row. Set by keyboard_scan() and used by keyboard_get_event() // The values scanned values for each row. Set by keyboard_scan() and used by keyboard_get_event()
byte[8] keyboard_scan_values; byte keyboard_scan_values[8];
// Scans the entire matrix to determine which keys have been pressed/depressed. // Scans the entire matrix to determine which keys have been pressed/depressed.
// Generates keyboard events into the event buffer. Events can be read using keyboard_event_get(). // Generates keyboard events into the event buffer. Events can be read using keyboard_event_get().

View File

@ -18,19 +18,19 @@ import "c64"
const byte PLEX_COUNT = 32; const byte PLEX_COUNT = 32;
// The x-positions of the multiplexer sprites ($000-$1ff) // The x-positions of the multiplexer sprites ($000-$1ff)
word[PLEX_COUNT] PLEX_XPOS; word PLEX_XPOS[PLEX_COUNT];
// The y-positions of the multiplexer sprites. // The y-positions of the multiplexer sprites.
byte[PLEX_COUNT] PLEX_YPOS; byte PLEX_YPOS[PLEX_COUNT];
// The sprite pointers for the multiplexed sprites // The sprite pointers for the multiplexed sprites
byte[PLEX_COUNT] PLEX_PTR; byte PLEX_PTR[PLEX_COUNT];
// The address of the sprite pointers on the current screen (screen+$3f8). // The address of the sprite pointers on the current screen (screen+$3f8).
byte* PLEX_SCREEN_PTR = $400+$3f8; byte* PLEX_SCREEN_PTR = $400+$3f8;
// Indexes of the plex-sprites sorted by sprite y-position. Each call to plexSort() will fix the sorting if changes to the Y-positions have ruined it. // Indexes of the plex-sprites sorted by sprite y-position. Each call to plexSort() will fix the sorting if changes to the Y-positions have ruined it.
byte[PLEX_COUNT] PLEX_SORTED_IDX; byte PLEX_SORTED_IDX[PLEX_COUNT];
// Variables controlling the showing of sprites // Variables controlling the showing of sprites
@ -115,7 +115,7 @@ inline byte plexShowNextYpos() {
} }
// Contains the Y-position where each sprite is free again. PLEX_FREE_YPOS[s] holds the Y-position where sprite s is free to use again. // Contains the Y-position where each sprite is free again. PLEX_FREE_YPOS[s] holds the Y-position where sprite s is free to use again.
byte[8] PLEX_FREE_YPOS; byte PLEX_FREE_YPOS[8];
// The index of the sprite that is free next. Since sprites are used round-robin this moves forward each time a sprite is shown. // The index of the sprite that is free next. Since sprites are used round-robin this moves forward each time a sprite is shown.
byte plex_free_next = 0; byte plex_free_next = 0;

View File

@ -93,7 +93,7 @@ void print_word(word w) {
} }
// Digits used for storing the decimal word // Digits used for storing the decimal word
char[6] decimal_digits; char decimal_digits[6];
// Print a byte as DECIMAL // Print a byte as DECIMAL
void print_byte_decimal(byte b) { void print_byte_decimal(byte b) {
@ -120,7 +120,7 @@ void print_dword(dword dw) {
} }
// Digits used for storing the decimal word // Digits used for storing the decimal word
char[11] decimal_digits_long; char decimal_digits_long[11];
// Print a dword as DECIMAL // Print a dword as DECIMAL
void print_dword_decimal(dword w) { void print_dword_decimal(dword w) {
@ -145,7 +145,7 @@ void print_sdword(signed dword dw) {
print_dword((dword)dw); print_dword((dword)dw);
} }
const byte[] print_hextab = "0123456789abcdef"z; const byte print_hextab[] = "0123456789abcdef"z;
// Print a byte as HEX // Print a byte as HEX
void print_byte(byte b) { void print_byte(byte b) {

View File

@ -55,16 +55,16 @@ unsigned int* bsearch16u(unsigned int key, unsigned int* items, char num) {
// The different supported radix // The different supported radix
enum RADIX { BINARY=2, OCTAL=8, DECIMAL=10, HEXADECIMAL=16 }; enum RADIX { BINARY=2, OCTAL=8, DECIMAL=10, HEXADECIMAL=16 };
// The digits used for numbers // The digits used for numbers
char[] DIGITS = "0123456789abcdef"z; char DIGITS[] = "0123456789abcdef"z;
// Values of binary digits // Values of binary digits
unsigned int[] RADIX_BINARY_VALUES = { 0b1000000000000000, 0b0100000000000000, 0b0010000000000000, 0b0001000000000000, 0b0000100000000000, 0b0000010000000000, 0b0000001000000000, 0b0000000100000000, 0b0000000010000000, 0b0000000001000000, 0b0000000000100000, 0b0000000000010000, 0b0000000000001000, 0b0000000000000100, 0b0000000000000010 }; unsigned int RADIX_BINARY_VALUES[] = { 0b1000000000000000, 0b0100000000000000, 0b0010000000000000, 0b0001000000000000, 0b0000100000000000, 0b0000010000000000, 0b0000001000000000, 0b0000000100000000, 0b0000000010000000, 0b0000000001000000, 0b0000000000100000, 0b0000000000010000, 0b0000000000001000, 0b0000000000000100, 0b0000000000000010 };
// Values of octal digits // Values of octal digits
unsigned int[] RADIX_OCTAL_VALUES = { 0x8000, 0x1000, 0x200, 0x40, 0x8 }; unsigned int RADIX_OCTAL_VALUES[] = { 0x8000, 0x1000, 0x200, 0x40, 0x8 };
// Values of decimal digits // Values of decimal digits
unsigned int[] RADIX_DECIMAL_VALUES = { 10000, 1000, 100, 10 }; unsigned int RADIX_DECIMAL_VALUES[] = { 10000, 1000, 100, 10 };
// Values of hexadecimal digits // Values of hexadecimal digits
unsigned int[] RADIX_HEXADECIMAL_VALUES = { 0x1000, 0x100, 0x10 }; unsigned int RADIX_HEXADECIMAL_VALUES[] = { 0x1000, 0x100, 0x10 };
// Converts unsigned number value to a string representing it in RADIX format. // Converts unsigned number value to a string representing it in RADIX format.
// If the leading digits are zero they are not included in the string. // If the leading digits are zero they are not included in the string.
@ -122,13 +122,13 @@ unsigned int utoa_append(char *buffer, unsigned int value, unsigned int sub){
} }
// Values of binary digits // Values of binary digits
unsigned long[] RADIX_BINARY_VALUES_LONG = { 0b10000000000000000000000000000000, 0b01000000000000000000000000000000, 0b00100000000000000000000000000000, 0b00010000000000000000000000000000, 0b00001000000000000000000000000000, 0b00000100000000000000000000000000, 0b00000010000000000000000000000000, 0b00000001000000000000000000000000, 0b00000000100000000000000000000000, 0b00000000010000000000000000000000, 0b00000000001000000000000000000000, 0b00000000000100000000000000000000, 0b00000000000010000000000000000000, 0b00000000000001000000000000000000, 0b00000000000000100000000000000000, 0b00000000000000010000000000000000, 0b00000000000000001000000000000000, 0b00000000000000000100000000000000, 0b00000000000000000010000000000000, 0b00000000000000000001000000000000, 0b00000000000000000000100000000000, 0b00000000000000000000010000000000, 0b00000000000000000000001000000000, 0b00000000000000000000000100000000, 0b00000000000000000000000010000000, 0b00000000000000000000000001000000, 0b00000000000000000000000000100000, 0b00000000000000000000000000010000, 0b00000000000000000000000000001000, 0b00000000000000000000000000000100, 0b00000000000000000000000000000010 }; unsigned long RADIX_BINARY_VALUES_LONG[] = { 0b10000000000000000000000000000000, 0b01000000000000000000000000000000, 0b00100000000000000000000000000000, 0b00010000000000000000000000000000, 0b00001000000000000000000000000000, 0b00000100000000000000000000000000, 0b00000010000000000000000000000000, 0b00000001000000000000000000000000, 0b00000000100000000000000000000000, 0b00000000010000000000000000000000, 0b00000000001000000000000000000000, 0b00000000000100000000000000000000, 0b00000000000010000000000000000000, 0b00000000000001000000000000000000, 0b00000000000000100000000000000000, 0b00000000000000010000000000000000, 0b00000000000000001000000000000000, 0b00000000000000000100000000000000, 0b00000000000000000010000000000000, 0b00000000000000000001000000000000, 0b00000000000000000000100000000000, 0b00000000000000000000010000000000, 0b00000000000000000000001000000000, 0b00000000000000000000000100000000, 0b00000000000000000000000010000000, 0b00000000000000000000000001000000, 0b00000000000000000000000000100000, 0b00000000000000000000000000010000, 0b00000000000000000000000000001000, 0b00000000000000000000000000000100, 0b00000000000000000000000000000010 };
// Values of octal digits // Values of octal digits
unsigned long[] RADIX_OCTAL_VALUES_LONG = { 0x40000000, 0x8000000, 0x1000000, 0x200000, 0x40000, 0x8000, 0x1000, 0x200, 0x40, 0x8 }; unsigned long RADIX_OCTAL_VALUES_LONG[] = { 0x40000000, 0x8000000, 0x1000000, 0x200000, 0x40000, 0x8000, 0x1000, 0x200, 0x40, 0x8 };
// Values of decimal digits // Values of decimal digits
unsigned long[] RADIX_DECIMAL_VALUES_LONG = { 1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10 }; unsigned long RADIX_DECIMAL_VALUES_LONG[] = { 1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10 };
// Values of hexadecimal digits // Values of hexadecimal digits
unsigned long[] RADIX_HEXADECIMAL_VALUES_LONG = { 0x10000000, 0x1000000, 0x100000, 0x10000, 0x1000, 0x100, 0x10 }; unsigned long RADIX_HEXADECIMAL_VALUES_LONG[] = { 0x10000000, 0x1000000, 0x100000, 0x10000, 0x1000, 0x100, 0x10 };
// Converts unsigned number value to a string representing it in RADIX format. // Converts unsigned number value to a string representing it in RADIX format.
// If the leading digits are zero they are not included in the string. // If the leading digits are zero they are not included in the string.

View File

@ -114,7 +114,7 @@ char* RENDERBOB_CLEANUP[NUM_BOBS];
char** renderBobCleanupNext; char** renderBobCleanupNext;
// *40 Table unsigned int[0x20] MUL40 = { ((unsigned int)i)*40 }; // *40 Table unsigned int[0x20] MUL40 = { ((unsigned int)i)*40 };
unsigned int[0x20] MUL40; unsigned int MUL40[0x20];
// Initialize the tables used by renderBob() // Initialize the tables used by renderBob()
void renderBobInit() { void renderBobInit() {