1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-01-09 20:31:44 +00:00

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

This commit is contained in:
jespergravgaard 2020-03-26 10:56:19 +01:00
parent f9560de10d
commit 6894f0bd7c
14 changed files with 51 additions and 51 deletions

View File

@ -7,9 +7,9 @@
const char* BGCOL = 0xc01a;
#pragma data_seg(RomData)
char[] MESSAGE = "hello world";
char MESSAGE[] = "hello world";
#pragma data_seg(RamData)
char[50] SCREEN;
char SCREEN[50];
void entryPoint() {
for( char i:0..49)
@ -25,4 +25,4 @@ void main() {
}
#pragma data_seg(Vectors)
export const void()*[] VECTORS = { &nmiHandler, &entryPoint };
export const void()* VECTORS[] = { &nmiHandler, &entryPoint };

View File

@ -13,14 +13,14 @@ const byte* SCREEN = 0x0400;
// Sprite data for the animating sprites
const byte* SPRITE_DATA = 0x2000;
// Values added to VX
const word[40] VXSIN = kickasm {{
const word VXSIN[40] = kickasm {{
.for(var i=0; i<40; i++) {
.word -sin(toRadians([i*360]/40))*4
}
}};
// Values added to VY
const word[25] VYSIN = kickasm {{
const word VYSIN[25] = kickasm {{
.for(var i=0; i<25; i++) {
.word -sin(toRadians([i*360]/25))*4
}

View File

@ -4,13 +4,13 @@
import "c64"
import "string"
byte[1000] MEDUSA_SCREEN = kickasm(resource "medusas.prg" ) {{
char MEDUSA_SCREEN[1000] = kickasm(resource "medusas.prg" ) {{
.var fileScreen = LoadBinary("medusas.prg", BF_C64FILE)
.fill fileScreen.getSize(), fileScreen.get(i)
}};
byte[] MEDUSA_COLORS = kickasm(resource "medusac.prg" ) {{
char MEDUSA_COLORS[] = kickasm(resource "medusac.prg" ) {{
.var fileCols = LoadBinary("medusac.prg", BF_C64FILE)
.fill fileCols.getSize(), fileCols.get(i)
}};

View File

@ -11,7 +11,7 @@ import "fastmultiply"
// 0 3 6
// 1 4 7
// 2 5 8
const char[3*3*8] PROTO_BOB = kickasm(resource "smiley.png") {{
const char PROTO_BOB[3*3*8] = kickasm(resource "smiley.png") {{
.var pic = LoadPicture("smiley.png", List().add($000000, $ffffff))
.for (var x=0;x<3; x++)
.for (var y=0; y<24; y++)
@ -21,7 +21,7 @@ const char[3*3*8] PROTO_BOB = kickasm(resource "smiley.png") {{
// Sine and Cosine tables
// Angles: $00=0, $80=PI,$100=2*PI
// Sine/Cosine: signed fixed [-$7f,$7f]
signed char[0x140] align(0x40) SIN = kickasm {{
signed char align(0x40) SIN[0x140] = kickasm {{
.for(var i=0;i<$140;i++)
.byte >round($7fff*sin(i*2*PI/256))
}};
@ -39,7 +39,7 @@ const char* BOB_CHARSET = 0x2000;
// 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[9*8*4] BOB_TABLES;
char BOB_TABLES[9*8*4];
// The number of different X-shifts
const char BOB_SHIFTS_X = 4;
// The number of different Y-shifts
@ -103,7 +103,7 @@ void main() {
}
// Table used for deleting rendered BOB's. Contains pointers to first char of each BOB.
char*[NUM_BOBS] RENDERBOB_CLEANUP;
char* RENDERBOB_CLEANUP[NUM_BOBS];
// Pointer to the next clean-up to add
char** renderBobCleanupNext;
@ -267,7 +267,7 @@ void progress_init(char* line) {
// Done by increasing the character until the idx is 8 and then moving to the next char
void progress_inc() {
// Progress characters
const char[] progress_chars = { 0x20, 0x65, 0x74, 0x75, 0x61, 0xf6, 0xe7, 0xea, 0xe0 };
const char progress_chars[] = { 0x20, 0x65, 0x74, 0x75, 0x61, 0xf6, 0xe7, 0xea, 0xe0 };
if(++progress_idx==8) {
*progress_cursor = progress_chars[8];
progress_cursor++;

View File

@ -11,7 +11,7 @@ import "fastmultiply"
// 0 3 6
// 1 4 7
// 2 5 8
const char[3*3*8] PROTO_BOB = kickasm(resource "smiley.png") {{
const char PROTO_BOB[3*3*8] = kickasm(resource "smiley.png") {{
.var pic = LoadPicture("smiley.png", List().add($000000, $ffffff))
.for (var x=0;x<3; x++)
.for (var y=0; y<24; y++)
@ -21,7 +21,7 @@ const char[3*3*8] PROTO_BOB = kickasm(resource "smiley.png") {{
// Sine and Cosine tables
// Angles: $00=0, $80=PI,$100=2*PI
// Sine/Cosine: signed fixed [-$7f,$7f]
signed char[0x140] align(0x40) SIN = kickasm {{
signed char align(0x40) SIN[0x140] = kickasm {{
.for(var i=0;i<$140;i++)
.byte >round($7fff*sin(i*2*PI/256))
}};
@ -29,11 +29,11 @@ signed char[0x140] align(0x40) SIN = kickasm {{
signed char* COS = SIN+$40; // sin(x) = cos(x+PI/2)
// Vogel Sunflower polar coordinates
align(0x100) const char[] VOGEL_THETA = kickasm {{
align(0x100) const char VOGEL_THETA[] = kickasm {{
.const PHI = (1+sqrt(5))/2
.fill 100, round(mod(256*i/(PHI*PHI),256))
}};
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
const char* SCREEN_BASIC = 0x0400;
@ -46,7 +46,7 @@ const char* BOB_CHARSET = 0x2000;
// 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[9*8*4] BOB_TABLES;
char BOB_TABLES[9*8*4];
// The number of different X-shifts
const char BOB_SHIFTS_X = 4;
// The number of different Y-shifts
@ -108,7 +108,7 @@ void main() {
}
// Table used for deleting rendered BOB's. Contains pointers to first char of each BOB.
char*[NUM_BOBS] RENDERBOB_CLEANUP;
char* RENDERBOB_CLEANUP[NUM_BOBS];
// Pointer to the next clean-up to add
char** renderBobCleanupNext;
@ -273,7 +273,7 @@ void progress_init(char* line) {
// Done by increasing the character until the idx is 8 and then moving to the next char
void progress_inc() {
// Progress characters
const char[] progress_chars = { 0x20, 0x65, 0x74, 0x75, 0x61, 0xf6, 0xe7, 0xea, 0xe0 };
const char progress_chars[] = { 0x20, 0x65, 0x74, 0x75, 0x61, 0xf6, 0xe7, 0xea, 0xe0 };
if(++progress_idx==8) {
*progress_cursor = progress_chars[8];
progress_cursor++;

View File

@ -6,7 +6,7 @@ import "string"
import "keyboard"
// The BOB sprite
align(0x1000) char[] SPRITE = kickasm(resource "smiley.png") {{
align(0x1000) char SPRITE[] = kickasm(resource "smiley.png") {{
.var pic = LoadPicture("smiley.png", List().add($000000, $ffffff))
.for (var y=0; y<21; y++)
.for (var x=0;x<3; x++)
@ -16,7 +16,7 @@ align(0x1000) char[] SPRITE = kickasm(resource "smiley.png") {{
// Sine and Cosine tables
// Angles: $00=0, $80=PI,$100=2*PI
// Sine/Cosine: signed fixed [-$7f,$7f]
align(0x40) signed char[0x140] SIN = kickasm {{
align(0x40) signed char SIN[0x140] = kickasm {{
.for(var i=0;i<$140;i++)
.byte >round($7fff*sin(i*2*PI/256))
}};

View File

@ -108,7 +108,7 @@ void bitmap_plot_spline_8seg() {
// Sine and Cosine tables
// Angles: $00=0, $80=PI,$100=2*PI
// Sine/Cosine: signed fixed [-$7f,$7f]
signed char[0x140] align(0x40) SIN = kickasm {{
signed char align(0x40) SIN[0x140] = kickasm {{
.for(var i=0;i<$140;i++)
.byte >round($7fff*sin(i*2*PI/256))
}};

View File

@ -1,6 +1,6 @@
import "tetris-sprites"
char[256] SIN = kickasm {{
char SIN[256] = kickasm {{
.var AMPL = 200-21
.for(var i=0; i<256; i++) {
.byte 51+AMPL/2+sin(toRadians([i*360]/256))*AMPL/2

View File

@ -20,7 +20,7 @@ const char PLAYFIELD_COLS = 10;
// The playfield. 0 is empty non-zero is color.
// The playfield is layed out line by line, meaning the first 10 bytes are line 1, the next 10 line 2 and so forth,
char[PLAYFIELD_LINES*PLAYFIELD_COLS] playfield;
char playfield[PLAYFIELD_LINES*PLAYFIELD_COLS];
// Pointer to the current piece in the current orientation. Updated each time current_orientation is updated.
char* current_piece_gfx;

View File

@ -2,7 +2,7 @@
// The tetris pieces
// The T-piece
align(0x40) char[64] PIECE_T = {
align(0x40) char PIECE_T[64] = {
0, 0, 0, 0,
1, 1, 1, 0,
0, 1, 0, 0,
@ -25,7 +25,7 @@ align(0x40) char[64] PIECE_T = {
};
// The S-piece
align(0x40) char[64] PIECE_S = {
align(0x40) char PIECE_S[64] = {
0, 0, 0, 0,
0, 1, 1, 0,
1, 1, 0, 0,
@ -49,7 +49,7 @@ align(0x40) char[64] PIECE_S = {
};
// The Z-piece
align(0x40) char[64] PIECE_Z = {
align(0x40) char PIECE_Z[64] = {
0, 0, 0, 0,
1, 1, 0, 0,
0, 1, 1, 0,
@ -73,7 +73,7 @@ align(0x40) char[64] PIECE_Z = {
};
// The L-piece
align(0x40) char[64] PIECE_L = {
align(0x40) char PIECE_L[64] = {
0, 0, 0, 0,
1, 1, 1, 0,
1, 0, 0, 0,
@ -97,7 +97,7 @@ align(0x40) char[64] PIECE_L = {
};
// The J-piece
align(0x40) char[64] PIECE_J = {
align(0x40) char PIECE_J[64] = {
0, 0, 0, 0,
1, 1, 1, 0,
0, 0, 1, 0,
@ -121,7 +121,7 @@ align(0x40) char[64] PIECE_J = {
};
// The O-piece
align(0x40) char[64] PIECE_O = {
align(0x40) char PIECE_O[64] = {
0, 0, 0, 0,
0, 1, 1, 0,
0, 1, 1, 0,
@ -145,7 +145,7 @@ align(0x40) char[64] PIECE_O = {
};
// The I-piece
align(0x40) char[64] PIECE_I = {
align(0x40) char PIECE_I[64] = {
0, 0, 0, 0,
0, 0, 0, 0,
1, 1, 1, 1,
@ -169,14 +169,14 @@ align(0x40) char[64] PIECE_I = {
};
// The different pieces
unsigned int[] PIECES = { (unsigned int)PIECE_T, (unsigned int)PIECE_S, (unsigned int)PIECE_Z, (unsigned int)PIECE_J, (unsigned int)PIECE_O, (unsigned int)PIECE_I, (unsigned int)PIECE_L };
unsigned int PIECES[] = { (unsigned int)PIECE_T, (unsigned int)PIECE_S, (unsigned int)PIECE_Z, (unsigned int)PIECE_J, (unsigned int)PIECE_O, (unsigned int)PIECE_I, (unsigned int)PIECE_L };
// The chars to use for the different pieces - when inside the playing area
char[] PIECES_CHARS = { 0x65, 0x66, 0xa6, 0x66, 0x65, 0x65, 0xa6 };
char PIECES_CHARS[] = { 0x65, 0x66, 0xa6, 0x66, 0x65, 0x65, 0xa6 };
// The chars to use for the different pieces - when outside the playing area (eg. the next area).
char[] PIECES_NEXT_CHARS = { 0x63, 0x64, 0xa4, 0x64, 0x63, 0x63, 0xa4 };
char PIECES_NEXT_CHARS[] = { 0x63, 0x64, 0xa4, 0x64, 0x63, 0x63, 0xa4 };
// The initial X/Y for each piece
char[] PIECES_START_X = { 4, 4, 4, 4, 4, 4, 4 };
char[] PIECES_START_Y = { 1, 1, 1, 1, 1, 0, 1 };
char PIECES_START_X[] = { 4, 4, 4, 4, 4, 4, 4 };
char PIECES_START_Y[] = { 1, 1, 1, 1, 1, 0, 1 };

View File

@ -6,10 +6,10 @@ import "tetris-data"
import "tetris-pieces"
// Pointers to the playfield address for each playfield line
char*[PLAYFIELD_LINES] playfield_lines;
char* playfield_lines[PLAYFIELD_LINES];
// Indixes into the playfield for each playfield line
char[PLAYFIELD_LINES+1] playfield_lines_idx;
char playfield_lines_idx[PLAYFIELD_LINES+1];
// The index of the next moving piece. (0-6)
char next_piece_idx = 0;
@ -23,7 +23,7 @@ char current_orientation = 0;
// The speed of moving down the piece when soft-drop is not activated
// This array holds the number of frames per move by level (0-29). For all levels 29+ the value is 1.
const char[] MOVEDOWN_SLOW_SPEEDS = { 48, 43, 38, 33, 28, 23, 18, 13, 8, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 };
const char MOVEDOWN_SLOW_SPEEDS[] = { 48, 43, 38, 33, 28, 23, 18, 13, 8, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 };
// The rate of moving down the current piece (number of frames between moves if movedown is not forced)
char current_movedown_slow = 48;
@ -36,11 +36,11 @@ char current_movedown_counter = 0;
// Base Score values for removing 0-4 lines (in BCD)
// These values are added to score_add_bcd for each level gained.
const unsigned long[] SCORE_BASE_BCD = { 0x0000, 0x0040, 0x0100, 0x0300, 0x1200 };
const unsigned long SCORE_BASE_BCD[] = { 0x0000, 0x0040, 0x0100, 0x0300, 0x1200 };
// Score values for removing 0-4 lines (in BCD)
// These values are updated based on the players level and the base values from SCORE_BASE_BCD
unsigned long[5] score_add_bcd;
unsigned long score_add_bcd[5];
// Initialize play data tables
void play_init() {

View File

@ -12,7 +12,7 @@ kickasm(pc PLAYFIELD_CHARSET, resource "playfield-screen.imap") {{
// Address of the original playscreen chars
const char PLAYFIELD_SCREEN_ORIGINAL_WIDTH=32;
const char[] PLAYFIELD_SCREEN_ORIGINAL = kickasm(resource "playfield-screen.iscr", resource "playfield-extended.col" ) {{
const char PLAYFIELD_SCREEN_ORIGINAL[] = kickasm(resource "playfield-screen.iscr", resource "playfield-extended.col" ) {{
// Load chars for the screen
.var screen = LoadBinary("playfield-screen.iscr")
// Load extended colors for the screen
@ -24,18 +24,18 @@ const char[] PLAYFIELD_SCREEN_ORIGINAL = kickasm(resource "playfield-screen.iscr
}};
// Original Color Data
const char[] PLAYFIELD_COLORS_ORIGINAL = kickasm(resource "playfield-screen.col") {{
const char PLAYFIELD_COLORS_ORIGINAL[] = kickasm(resource "playfield-screen.col") {{
.import binary "playfield-screen.col"
}};
// The color #1 to use for the pieces for each level
char[] PIECES_COLORS_1 = {
char PIECES_COLORS_1[] = {
BLUE, GREEN, PURPLE, BLUE, RED, LIGHT_GREEN, RED, BLUE, LIGHT_BLUE, RED,
BLUE, GREEN, PURPLE, BLUE, RED, LIGHT_GREEN, RED, BLUE, LIGHT_BLUE, RED,
BLUE, GREEN, PURPLE, BLUE, RED, LIGHT_GREEN, RED, BLUE, LIGHT_BLUE, RED
};
// The color #2 to use for the pieces for each level
char[] PIECES_COLORS_2 = {
char PIECES_COLORS_2[] = {
CYAN, LIGHT_GREEN, PINK, LIGHT_GREEN, LIGHT_GREEN, LIGHT_BLUE, DARK_GREY, PURPLE, RED, ORANGE,
CYAN, LIGHT_GREEN, PINK, LIGHT_GREEN, LIGHT_GREEN, LIGHT_BLUE, DARK_GREY, PURPLE, RED, ORANGE,
CYAN, LIGHT_GREEN, PINK, LIGHT_GREEN, LIGHT_GREEN, LIGHT_BLUE, DARK_GREY, PURPLE, RED, ORANGE
@ -43,8 +43,8 @@ char[] PIECES_COLORS_2 = {
// Pointers to the screen address for rendering each playfield line
// The lines for screen 1 is aligned with 0x80 and screen 2 with 0x40 - so XOR'ing with 0x40 gives screen 2 lines.
align(0x80) char*[PLAYFIELD_LINES] screen_lines_1;
align(0x40) char*[PLAYFIELD_LINES] screen_lines_2;
align(0x80) char* screen_lines_1[PLAYFIELD_LINES];
align(0x40) char* screen_lines_2[PLAYFIELD_LINES];
// Initialize rendering
void render_init() {

View File

@ -15,7 +15,7 @@ const char* COLS = 0xd800;
const char BLACK = 0;
const char WHITE = 1;
char[] MESSAGE = "hello world!";
char MESSAGE[] = "hello world!";
void main() {
// Initialize screen memory
@ -58,11 +58,11 @@ struct SysCall {
const char JMP = 0x4c;
const char NOP = 0xea;
export struct SysCall[] SYSCALLS = {
export struct SysCall SYSCALLS[] = {
{ JMP, &syscall1, NOP },
{ JMP, &syscall2, NOP }
};
export align(0x100) struct SysCall[] SYSCALL_RESET = {
export align(0x100) struct SysCall SYSCALL_RESET[] = {
{ JMP, &main, NOP }
};

View File

@ -11,7 +11,7 @@ void main() {
}
// Import a 128x128 8bit-per-color logo using inline KickAsm
char[] LOGO256 = kickasm(resource "mega65-256.png", resource "xmega65graphics.asm") {{
char LOGO256[] = kickasm(resource "mega65-256.png", resource "xmega65graphics.asm") {{
#import "xmega65graphics.asm"
.var logo256 = LoadPicture("mega65-256.png")
.var palette256 = getPalette(logo256)