From 7f9fd7b46af1a8ad92b19f05c45e5a1de8ac9cb3 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Tue, 29 Oct 2019 23:55:43 +0100 Subject: [PATCH 1/2] Updated tetris to C types. --- src/test/kc/complex/tetris/sid.kc | 26 ++--- src/test/kc/complex/tetris/test-sprites.kc | 18 +-- src/test/kc/complex/tetris/tetris-data.kc | 46 ++++---- src/test/kc/complex/tetris/tetris-pieces.kc | 22 ++-- src/test/kc/complex/tetris/tetris-play.kc | 114 +++++++++---------- src/test/kc/complex/tetris/tetris-render.kc | 84 +++++++------- src/test/kc/complex/tetris/tetris-sprites.kc | 24 ++-- src/test/kc/complex/tetris/tetris.kc | 4 +- src/test/ref/complex/tetris/test-sprites.log | 6 +- src/test/ref/complex/tetris/tetris.log | 36 +++--- 10 files changed, 190 insertions(+), 190 deletions(-) diff --git a/src/test/kc/complex/tetris/sid.kc b/src/test/kc/complex/tetris/sid.kc index 4dcef6cb4..94afd4f7e 100644 --- a/src/test/kc/complex/tetris/sid.kc +++ b/src/test/kc/complex/tetris/sid.kc @@ -1,17 +1,17 @@ // SID registers for random number generation const word* SID_VOICE3_FREQ = $d40e; -const byte* SID_VOICE3_FREQ_LOW = $d40e; -const byte* SID_VOICE3_FREQ_HIGH = $d40f; -const byte* SID_VOICE3_CONTROL = $d412; -const byte SID_CONTROL_NOISE = $80; -const byte SID_CONTROL_PULSE = $40; -const byte SID_CONTROL_SAWTOOTH = $20; -const byte SID_CONTROL_TRIANGLE = $10; -const byte SID_CONTROL_TEST = $08; -const byte SID_CONTROL_RING = $04; -const byte SID_CONTROL_SYNC = $02; -const byte SID_CONTROL_GATE = $01; -const byte* SID_VOICE3_OSC = $d41b; +const char* SID_VOICE3_FREQ_LOW = $d40e; +const char* SID_VOICE3_FREQ_HIGH = $d40f; +const char* SID_VOICE3_CONTROL = $d412; +const char SID_CONTROL_NOISE = $80; +const char SID_CONTROL_PULSE = $40; +const char SID_CONTROL_SAWTOOTH = $20; +const char SID_CONTROL_TRIANGLE = $10; +const char SID_CONTROL_TEST = $08; +const char SID_CONTROL_RING = $04; +const char SID_CONTROL_SYNC = $02; +const char SID_CONTROL_GATE = $01; +const char* SID_VOICE3_OSC = $d41b; // Initialize SID voice 3 for random number generation void sid_rnd_init() { @@ -21,7 +21,7 @@ void sid_rnd_init() { // Get a random number from the SID voice 3, // Must be initialized with sid_rnd_init() -inline byte sid_rnd() { +inline char sid_rnd() { return *SID_VOICE3_OSC; } diff --git a/src/test/kc/complex/tetris/test-sprites.kc b/src/test/kc/complex/tetris/test-sprites.kc index 0b386c787..94f1c9fd6 100644 --- a/src/test/kc/complex/tetris/test-sprites.kc +++ b/src/test/kc/complex/tetris/test-sprites.kc @@ -1,18 +1,18 @@ import "tetris-sprites" -byte[256] SIN = kickasm {{ +char[256] SIN = kickasm {{ .var AMPL = 200-21 .for(var i=0; i<256; i++) { .byte 51+AMPL/2+sin(toRadians([i*360]/256))*AMPL/2 } }}; -byte* SIN_SPRITE = $2800; +char* SIN_SPRITE = $2800; kickasm(pc SIN_SPRITE) {{ .fill $40, $ff }} -byte sin_idx = 0; +char sin_idx = 0; void main() { vicSelectGfxBank(PLAYFIELD_SCREEN_1); @@ -21,10 +21,10 @@ void main() { *SPRITES_ENABLE = $ff; - byte xpos = 24; - byte ypos = 50; - for(byte s:4..7) { - byte s2 = s*2; + char xpos = 24; + char ypos = 50; + for(char s:4..7) { + char s2 = s*2; SPRITES_XPOS[s2] = xpos; SPRITES_YPOS[s2] = ypos; SPRITES_COLS[s] = s-3; @@ -41,8 +41,8 @@ void main() { void loop() { while(true) { do {} while (*RASTER!=$ff); - byte idx = sin_idx; - for(byte s:4..7) { + char idx = sin_idx; + for(char s:4..7) { SPRITES_YPOS[s*2] = SIN[idx]; idx += 10; } diff --git a/src/test/kc/complex/tetris/tetris-data.kc b/src/test/kc/complex/tetris/tetris-data.kc index 25015ce52..d7f86487b 100644 --- a/src/test/kc/complex/tetris/tetris-data.kc +++ b/src/test/kc/complex/tetris/tetris-data.kc @@ -2,55 +2,55 @@ // Memory Layout and Shared Data // Address of the first screen -const byte* PLAYFIELD_SCREEN_1 = $0400; +const char* PLAYFIELD_SCREEN_1 = $0400; // Address of the second screen -const byte* PLAYFIELD_SCREEN_2 = $2c00; +const char* PLAYFIELD_SCREEN_2 = $2c00; // Screen Sprite pointers on screen 1 -const byte* PLAYFIELD_SPRITE_PTRS_1 = (PLAYFIELD_SCREEN_1+SPRITE_PTRS); +const char* PLAYFIELD_SPRITE_PTRS_1 = (PLAYFIELD_SCREEN_1+SPRITE_PTRS); // Screen Sprite pointers on screen 2 -const byte* PLAYFIELD_SPRITE_PTRS_2 = (PLAYFIELD_SCREEN_2+SPRITE_PTRS); +const char* PLAYFIELD_SPRITE_PTRS_2 = (PLAYFIELD_SCREEN_2+SPRITE_PTRS); // Address of the original playscreen chars -const byte* PLAYFIELD_SCREEN_ORIGINAL = $1800; +const char* PLAYFIELD_SCREEN_ORIGINAL = $1800; // Address of the original playscreen colors -const byte* PLAYFIELD_COLORS_ORIGINAL = $1c00; +const char* PLAYFIELD_COLORS_ORIGINAL = $1c00; // Address of the sprites covering the playfield -const byte* PLAYFIELD_SPRITES = $2000; +const char* PLAYFIELD_SPRITES = $2000; // Address of the charset -const byte* PLAYFIELD_CHARSET = $2800; +const char* PLAYFIELD_CHARSET = $2800; // The size of the playfield -const byte PLAYFIELD_LINES = 22; -const byte PLAYFIELD_COLS = 10; +const char PLAYFIELD_LINES = 22; +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, -byte[PLAYFIELD_LINES*PLAYFIELD_COLS] playfield; +char[PLAYFIELD_LINES*PLAYFIELD_COLS] playfield; // Pointer to the current piece in the current orientation. Updated each time current_orientation is updated. -byte* current_piece_gfx; +char* current_piece_gfx; // The char of the current piece -byte current_piece_char; +char current_piece_char; // Position of top left corner of current moving piece on the playfield -byte current_xpos; -byte current_ypos; +char current_xpos; +char current_ypos; // The screen currently being rendered to. $00 for screen 1 / $20 for screen 2. -byte render_screen_render = $20; +char render_screen_render = $20; // The screen currently to show next to the user. $00 for screen 1 / $20 for screen 2. -byte render_screen_show = 0; +char render_screen_show = 0; // The screen currently being showed to the user. $00 for screen 1 / $20 for screen 2. -volatile byte render_screen_showing = 0; +volatile char render_screen_showing = 0; // Current score in BCD-format -dword score_bcd = 0; +unsigned long score_bcd = 0; // Current number of cleared lines in BCD-format -word lines_bcd = 0; +unsigned int lines_bcd = 0; // Current level BCD-format -byte level_bcd = 0; +char level_bcd = 0; // Current level in normal (non-BCD) format -byte level = 0; +char level = 0; // Is the game over? -byte game_over = 0; +char game_over = 0; diff --git a/src/test/kc/complex/tetris/tetris-pieces.kc b/src/test/kc/complex/tetris/tetris-pieces.kc index 197248f18..b14ba85a1 100644 --- a/src/test/kc/complex/tetris/tetris-pieces.kc +++ b/src/test/kc/complex/tetris/tetris-pieces.kc @@ -2,7 +2,7 @@ // The tetris pieces // The T-piece -align($40) byte[4*4*4] PIECE_T = { +align($40) char[4*4*4] PIECE_T = { 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, @@ -25,7 +25,7 @@ align($40) byte[4*4*4] PIECE_T = { }; // The S-piece -align($40) byte[4*4*4] PIECE_S = { +align($40) char[4*4*4] PIECE_S = { 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, @@ -49,7 +49,7 @@ align($40) byte[4*4*4] PIECE_S = { }; // The Z-piece -align($40) byte[4*4*4] PIECE_Z = { +align($40) char[4*4*4] PIECE_Z = { 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, @@ -73,7 +73,7 @@ align($40) byte[4*4*4] PIECE_Z = { }; // The L-piece -align($40) byte[4*4*4] PIECE_L = { +align($40) char[4*4*4] PIECE_L = { 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, @@ -97,7 +97,7 @@ align($40) byte[4*4*4] PIECE_L = { }; // The J-piece -align($40) byte[4*4*4] PIECE_J = { +align($40) char[4*4*4] PIECE_J = { 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, @@ -121,7 +121,7 @@ align($40) byte[4*4*4] PIECE_J = { }; // The O-piece -align($40) byte[4*4*4] PIECE_O = { +align($40) char[4*4*4] PIECE_O = { 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, @@ -145,7 +145,7 @@ align($40) byte[4*4*4] PIECE_O = { }; // The I-piece -align($40) byte[4*4*4] PIECE_I = { +align($40) char[4*4*4] PIECE_I = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, @@ -172,11 +172,11 @@ align($40) byte[4*4*4] PIECE_I = { word[] PIECES = { (word)PIECE_T, (word)PIECE_S, (word)PIECE_Z, (word)PIECE_J, (word)PIECE_O, (word)PIECE_I, (word)PIECE_L }; // The chars to use for the different pieces - when inside the playing area -byte[] PIECES_CHARS = { $65, $66, $a6, $66, $65, $65, $a6 }; +char[] PIECES_CHARS = { $65, $66, $a6, $66, $65, $65, $a6 }; // The chars to use for the different pieces - when outside the playing area (eg. the next area). -byte[] PIECES_NEXT_CHARS = { $63, $64, $a4, $64, $63, $63, $a4 }; +char[] PIECES_NEXT_CHARS = { $63, $64, $a4, $64, $63, $63, $a4 }; // The initial X/Y for each piece -byte[] PIECES_START_X = { 4, 4, 4, 4, 4, 4, 4 }; -byte[] PIECES_START_Y = { 1, 1, 1, 1, 1, 0, 1 }; \ No newline at end of file +char[] PIECES_START_X = { 4, 4, 4, 4, 4, 4, 4 }; +char[] PIECES_START_Y = { 1, 1, 1, 1, 1, 0, 1 }; \ No newline at end of file diff --git a/src/test/kc/complex/tetris/tetris-play.kc b/src/test/kc/complex/tetris/tetris-play.kc index 79539813c..30e695813 100644 --- a/src/test/kc/complex/tetris/tetris-play.kc +++ b/src/test/kc/complex/tetris/tetris-play.kc @@ -6,48 +6,48 @@ import "tetris-data" import "tetris-pieces" // Pointers to the playfield address for each playfield line -byte*[PLAYFIELD_LINES] playfield_lines; +char*[PLAYFIELD_LINES] playfield_lines; // Indixes into the playfield for each playfield line -byte[PLAYFIELD_LINES+1] playfield_lines_idx; +char[PLAYFIELD_LINES+1] playfield_lines_idx; // The index of the next moving piece. (0-6) -byte next_piece_idx = 0; +char next_piece_idx = 0; // The current moving piece. Points to the start of the piece definition. -byte* current_piece = 0; +char* current_piece = 0; // The curent piece orientation - each piece have 4 orientations (00/$10/$20/$30). // The orientation chooses one of the 4 sub-graphics of the piece. -byte current_orientation = 0; +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 byte[] 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) -byte current_movedown_slow = 48; +char current_movedown_slow = 48; // The rate of moving down the current piece fast (number of frames between moves if movedown is not forced) -const byte current_movedown_fast = 10; +const char current_movedown_fast = 10; // Counts up to the next movedown of current piece -byte current_movedown_counter = 0; +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 dword[] SCORE_BASE_BCD = { $0000, $0040, $0100, $0300, $1200 }; +const unsigned long[] SCORE_BASE_BCD = { $0000, $0040, $0100, $0300, $1200 }; // 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 -dword[5] score_add_bcd; +unsigned long[5] score_add_bcd; // Initialize play data tables void play_init() { // Initialize the playfield line pointers; - byte idx = 0; - byte* pli = playfield; - for(byte j:0..PLAYFIELD_LINES-1) { + char idx = 0; + char* pli = playfield; + for(char j:0..PLAYFIELD_LINES-1) { playfield_lines[j] = pli; playfield_lines_idx[j] = idx; pli += PLAYFIELD_COLS; @@ -58,7 +58,7 @@ void play_init() { // Set initial speed of moving down a tetromino current_movedown_slow = MOVEDOWN_SLOW_SPEEDS[level]; // Set the initial score add values - for(byte b: 0..4) { + for(char b: 0..4) { score_add_bcd[b] = SCORE_BASE_BCD[b]; } @@ -67,8 +67,8 @@ void play_init() { // Perform any movement of the current piece // key_event is the next keyboard_event() og $ff if no keyboard event is pending // Returns a byte signaling whether rendering is needed. (0 no render, >0 render needed) -byte play_movement(byte key_event) { - byte render = 0; +char play_movement(char key_event) { + char render = 0; render += play_move_down(key_event); if(game_over!=0) { return render; @@ -80,10 +80,10 @@ byte play_movement(byte key_event) { // Move down the current piece // Return non-zero if a render is needed -byte play_move_down(byte key_event) { +char play_move_down(byte key_event) { // Handle moving down current piece ++current_movedown_counter; - byte movedown = 0; + char movedown = 0; // As soon as space is pressed move down once if(key_event==KEY_SPACE) { movedown++; @@ -107,7 +107,7 @@ byte play_move_down(byte key_event) { // Lock current piece play_lock_current(); // Check for any lines and remove them - byte removed = play_remove_lines(); + char removed = play_remove_lines(); // Tally up the score play_update_score(removed); // Spawn a new piece @@ -121,7 +121,7 @@ byte play_move_down(byte key_event) { // Move left/right or rotate the current piece // Return non-zero if a render is needed -byte play_move_leftright(byte key_event) { +char play_move_leftright(char key_event) { // Handle keyboard events if(key_event==KEY_COMMA) { if(play_collision(current_xpos-1,current_ypos,current_orientation)==COLLISION_NONE) { @@ -139,9 +139,9 @@ byte play_move_leftright(byte key_event) { // Rotate the current piece based on key-presses // Return non-zero if a render is needed -byte play_move_rotate(byte key_event) { +char play_move_rotate(char key_event) { // Handle keyboard events - byte orientation = $80; + char orientation = $80; if(key_event==KEY_Z) { orientation = (current_orientation-$10)&$3f; } else if(key_event==KEY_X) { @@ -158,26 +158,26 @@ byte play_move_rotate(byte key_event) { } // No collision -const byte COLLISION_NONE = 0; +const char COLLISION_NONE = 0; // Playfield piece collision (cell on top of other cell on the playfield) -const byte COLLISION_PLAYFIELD = 1; +const char COLLISION_PLAYFIELD = 1; // Bottom collision (cell below bottom of the playfield) -const byte COLLISION_BOTTOM = 2; +const char COLLISION_BOTTOM = 2; // Left side collision (cell beyond the left side of the playfield) -const byte COLLISION_LEFT = 4; +const char COLLISION_LEFT = 4; // Right side collision (cell beyond the right side of the playfield) -const byte COLLISION_RIGHT = 8; +const char COLLISION_RIGHT = 8; // Test if there is a collision between the current piece moved to (x, y) and anything on the playfield or the playfield boundaries // Returns information about the type of the collision detected -byte play_collision(byte xpos, byte ypos, byte orientation) { - byte* piece_gfx = current_piece + orientation; - byte i = 0; - byte yp = ypos; - for(byte l:0..3) { - byte* playfield_line = playfield_lines[yp]; - byte xp = xpos; - for(byte c:0..3) { +char play_collision(char xpos, char ypos, char orientation) { + char* piece_gfx = current_piece + orientation; + char i = 0; + char yp = ypos; + for(char l:0..3) { + char* playfield_line = playfield_lines[yp]; + char xp = xpos; + for(char c:0..3) { if(piece_gfx[i++]!=0) { if(yp>=PLAYFIELD_LINES) { // Below the playfield bottom @@ -205,12 +205,12 @@ byte play_collision(byte xpos, byte ypos, byte orientation) { // Lock the current piece onto the playfield void play_lock_current() { - byte i = 0; - byte yp = current_ypos; - for(byte l:0..3) { - byte* playfield_line = playfield_lines[yp]; - byte xp = current_xpos; - for(byte c:0..3) { + char i = 0; + char yp = current_ypos; + for(char l:0..3) { + char* playfield_line = playfield_lines[yp]; + char xp = current_xpos; + for(char c:0..3) { if(current_piece_gfx[i++]!=0) { playfield_line[xp] = current_piece_char; } @@ -224,7 +224,7 @@ void play_lock_current() { // Moves the next piece into the current and spawns a new next piece void play_spawn_current() { // Move next piece into current - byte current_piece_idx = next_piece_idx; + char current_piece_idx = next_piece_idx; current_piece = PIECES[current_piece_idx]; current_piece_char = PIECES_CHARS[current_piece_idx]; current_orientation = 0; @@ -237,7 +237,7 @@ void play_spawn_current() { // Spawn a new next piece // Pick a random piece (0-6) - byte piece_idx = 7; + char piece_idx = 7; while(piece_idx==7) { piece_idx = sid_rnd()&7; } @@ -249,17 +249,17 @@ void play_spawn_current() { // Utilizes two cursors on the playfield - one reading cells and one writing cells // Whenever a full line is detected the writing cursor is instructed to write to the same line once more. // Returns the number of lines removed -byte play_remove_lines() { +char play_remove_lines() { // Start both cursors at the end of the playfield - byte r = PLAYFIELD_LINES*PLAYFIELD_COLS-1; - byte w = PLAYFIELD_LINES*PLAYFIELD_COLS-1; + char r = PLAYFIELD_LINES*PLAYFIELD_COLS-1; + char w = PLAYFIELD_LINES*PLAYFIELD_COLS-1; - byte removed = 0; + char removed = 0; // Read all lines and rewrite them - for(byte y:0..PLAYFIELD_LINES-1) { - byte full = 1; - for(byte x:0..PLAYFIELD_COLS-1) { - byte c = playfield[r--]; + for(char y:0..PLAYFIELD_LINES-1) { + char full = 1; + for(char x:0..PLAYFIELD_COLS-1) { + char c = playfield[r--]; if(c==0) { full = 0; } @@ -281,10 +281,10 @@ byte play_remove_lines() { } // Update the score based on the number of lines removed -void play_update_score(byte removed) { +void play_update_score(char removed) { if(removed!=0){ - byte lines_before = lines_bcd, 1); render_bcd( screen, lines_offset+1, > 4); } @@ -134,13 +134,13 @@ void render_bcd(byte* screen, word offset, byte bcd, byte only_low) { // Copy the original screen data to the passed screen // Also copies colors to $d800 -void render_screen_original(byte* screen) { - byte SPACE = 0; - byte* oscr = PLAYFIELD_SCREEN_ORIGINAL+32*2; - byte* ocols = PLAYFIELD_COLORS_ORIGINAL+32*2; - byte* cols = COLS; - for(byte y:0..24) { - byte x=0; +void render_screen_original(char* screen) { + char SPACE = 0; + char* oscr = PLAYFIELD_SCREEN_ORIGINAL+32*2; + char* ocols = PLAYFIELD_COLORS_ORIGINAL+32*2; + char* cols = COLS; + for(char y:0..24) { + char x=0; do { *screen++ = SPACE; *cols++ = BLACK; @@ -159,10 +159,10 @@ void render_screen_original(byte* screen) { // Render the static playfield on the screen (all pieces already locked into place) void render_playfield() { // Do not render the top 2 lines. - byte i = PLAYFIELD_COLS*2; - for(byte l:2..PLAYFIELD_LINES-1) { - byte* screen_line = screen_lines_1[render_screen_render+l]; - for(byte c:0..PLAYFIELD_COLS-1) { + char i = PLAYFIELD_COLS*2; + for(char l:2..PLAYFIELD_LINES-1) { + char* screen_line = screen_lines_1[render_screen_render+l]; + for(char c:0..PLAYFIELD_COLS-1) { *(screen_line++) = playfield[i++]; } } @@ -171,14 +171,14 @@ void render_playfield() { // Render the current moving piece at position (current_xpos, current_ypos) // Ignores cases where parts of the tetromino is outside the playfield (sides/bottom) since the movement collision routine prevents this. void render_moving() { - byte i = 0; - byte ypos = current_ypos; - for(byte l:0..3) { + char i = 0; + char ypos = current_ypos; + for(char l:0..3) { if(ypos>1) { - byte* screen_line = screen_lines_1[render_screen_render+ypos]; - byte xpos = current_xpos; - for(byte c:0..3) { - byte current_cell = current_piece_gfx[i++]; + char* screen_line = screen_lines_1[render_screen_render+ypos]; + char xpos = current_xpos; + for(char c:0..3) { + char current_cell = current_piece_gfx[i++]; if(current_cell!=0) { screen_line[xpos] = current_piece_char; } @@ -195,8 +195,8 @@ void render_moving() { void render_next() { // Find the screen area - word next_area_offset = 40*12 + 24 + 4; - byte* screen_next_area; + unsigned int next_area_offset = 40*12 + 24 + 4; + char* screen_next_area; if(render_screen_render==0) { screen_next_area = PLAYFIELD_SCREEN_1+next_area_offset; } else { @@ -204,11 +204,11 @@ void render_next() { } // Render the next piece - byte* next_piece_gfx = PIECES[next_piece_idx]; - byte next_piece_char = PIECES_NEXT_CHARS[next_piece_idx]; - for(byte l:0..3) { - for(byte c:0..3) { - byte cell = *next_piece_gfx++; + char* next_piece_gfx = PIECES[next_piece_idx]; + char next_piece_char = PIECES_NEXT_CHARS[next_piece_idx]; + for(char l:0..3) { + for(char c:0..3) { + char cell = *next_piece_gfx++; if(cell!=0) { *screen_next_area = next_piece_char; } else { diff --git a/src/test/kc/complex/tetris/tetris-sprites.kc b/src/test/kc/complex/tetris/tetris-sprites.kc index e311f4558..144aa058b 100644 --- a/src/test/kc/complex/tetris/tetris-sprites.kc +++ b/src/test/kc/complex/tetris/tetris-sprites.kc @@ -24,9 +24,9 @@ kickasm(pc PLAYFIELD_SPRITES, resource "playfield-sprites.png") {{ void sprites_init() { *SPRITES_ENABLE = %00001111; *SPRITES_EXPAND_X = *SPRITES_EXPAND_Y = *SPRITES_MC = 0; - byte xpos = 24+15*8; - for(byte s:0..3) { - byte s2 = s*2; + char xpos = 24+15*8; + for(char s:0..3) { + char s2 = s*2; SPRITES_XPOS[s2] = xpos; SPRITES_COLS[s] = BLACK; xpos = xpos+24; @@ -34,17 +34,17 @@ void sprites_init() { } // The Y-position of the first sprite row -const byte SPRITES_FIRST_YPOS = 49; +const char SPRITES_FIRST_YPOS = 49; // The line of the first IRQ -const byte IRQ_RASTER_FIRST = SPRITES_FIRST_YPOS + 19; +const char IRQ_RASTER_FIRST = SPRITES_FIRST_YPOS + 19; // The raster line of the next IRQ -volatile byte irq_raster_next = IRQ_RASTER_FIRST; +volatile char irq_raster_next = IRQ_RASTER_FIRST; // Y-pos of the sprites on the next IRQ -volatile byte irq_sprite_ypos = SPRITES_FIRST_YPOS + 21; +volatile char irq_sprite_ypos = SPRITES_FIRST_YPOS + 21; // Index of the sprites to show on the next IRQ -volatile byte irq_sprite_ptr = toSpritePtr(PLAYFIELD_SPRITES) + 3; +volatile char irq_sprite_ptr = toSpritePtr(PLAYFIELD_SPRITES) + 3; // Counting the 10 IRQs -volatile byte irq_cnt = 0; +volatile char irq_cnt = 0; // Setup the IRQ void sprites_irq_init() { @@ -77,18 +77,18 @@ interrupt(hardware_clobber) void sprites_irq() { // Clear decimal flag (because it is used by the score algorithm) asm { cld } // Place the sprites - byte ypos = irq_sprite_ypos; + char ypos = irq_sprite_ypos; SPRITES_YPOS[0] = ypos; SPRITES_YPOS[2] = ypos; SPRITES_YPOS[4] = ypos; SPRITES_YPOS[6] = ypos; // Wait for the y-position before changing sprite pointers - volatile byte raster_sprite_gfx_modify = irq_raster_next+1; + volatile char raster_sprite_gfx_modify = irq_raster_next+1; do { } while(*RASTERplay_remove_lines::@6#1] -- register_copy // play_remove_lines::@6 __b6: - // for(byte y:0..PLAYFIELD_LINES-1) + // for(char y:0..PLAYFIELD_LINES-1) // [356] (byte) play_remove_lines::y#1 ← ++ (byte) play_remove_lines::y#8 -- vbuz1=_inc_vbuz1 inc.z y // [357] if((byte) play_remove_lines::y#1!=(const byte) PLAYFIELD_LINES-(byte) 1+(byte) 1) goto play_remove_lines::@1 -- vbuz1_neq_vbuc1_then_la1 @@ -26171,7 +26171,7 @@ play_lock_current: { // xp++; // [372] (byte) play_lock_current::xp#1 ← ++ (byte) play_lock_current::xp#2 -- vbuz1=_inc_vbuz1 inc.z xp - // for(byte c:0..3) + // for(char c:0..3) // [373] (byte) play_lock_current::c#1 ← ++ (byte) play_lock_current::c#2 -- vbuxx=_inc_vbuxx inx // [374] if((byte) play_lock_current::c#1!=(byte) 4) goto play_lock_current::@7 -- vbuxx_neq_vbuc1_then_la1 @@ -26181,7 +26181,7 @@ play_lock_current: { // yp++; // [375] (byte) play_lock_current::yp#1 ← ++ (byte) play_lock_current::yp#2 -- vbuz1=_inc_vbuz1 inc.z yp - // for(byte l:0..3) + // for(char l:0..3) // [376] (byte) play_lock_current::l#1 ← ++ (byte) play_lock_current::l#6 -- vbuz1=_inc_vbuz1 inc.z l // [377] if((byte) play_lock_current::l#1!=(byte) 4) goto play_lock_current::@6 -- vbuz1_neq_vbuc1_then_la1 @@ -26610,7 +26610,7 @@ play_init: { lax.z idx axs #-[PLAYFIELD_COLS] stx.z idx - // for(byte j:0..PLAYFIELD_LINES-1) + // for(char j:0..PLAYFIELD_LINES-1) // [464] (byte) play_init::j#1 ← ++ (byte) play_init::j#2 -- vbuyy=_inc_vbuyy iny // [465] if((byte) play_init::j#1!=(const byte) PLAYFIELD_LINES-(byte) 1+(byte) 1) goto play_init::@1 -- vbuyy_neq_vbuc1_then_la1 @@ -26649,7 +26649,7 @@ play_init: { sta score_add_bcd+2,y lda SCORE_BASE_BCD+3,y sta score_add_bcd+3,y - // for(byte b: 0..4) + // for(char b: 0..4) // [471] (byte) play_init::b#1 ← ++ (byte) play_init::b#2 -- vbuxx=_inc_vbuxx inx // [472] if((byte) play_init::b#1!=(byte) 5) goto play_init::@3 -- vbuxx_neq_vbuc1_then_la1 @@ -26765,7 +26765,7 @@ sprites_init: { lax.z xpos axs #-[$18] stx.z xpos - // for(byte s:0..3) + // for(char s:0..3) // [495] (byte) sprites_init::s#1 ← ++ (byte) sprites_init::s#2 -- vbuyy=_inc_vbuyy iny // [496] if((byte) sprites_init::s#1!=(byte) 4) goto sprites_init::@1 -- vbuyy_neq_vbuc1_then_la1 @@ -26892,7 +26892,7 @@ render_init: { bcc !+ inc.z li_2+1 !: - // for(byte i:0..PLAYFIELD_LINES-1) + // for(char i:0..PLAYFIELD_LINES-1) // [517] (byte) render_init::i#1 ← ++ (byte) render_init::i#2 -- vbuyy=_inc_vbuyy iny // [518] if((byte) render_init::i#1!=(const byte) PLAYFIELD_LINES-(byte) 1+(byte) 1) goto render_init::@1 -- vbuyy_neq_vbuc1_then_la1 @@ -27062,7 +27062,7 @@ render_screen_original: { cpx #$28 bne __b4 // render_screen_original::@5 - // for(byte y:0..24) + // for(char y:0..24) // [545] (byte) render_screen_original::y#1 ← ++ (byte) render_screen_original::y#6 -- vbuz1=_inc_vbuz1 inc.z y // [546] if((byte) render_screen_original::y#1!=(byte) $19) goto render_screen_original::@1 -- vbuz1_neq_vbuc1_then_la1 From acb71114e22b712c957a679569b0706ab681b369 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Wed, 30 Oct 2019 08:32:11 +0100 Subject: [PATCH 2/2] Changed to standard C syntax. --- src/test/kc/complex/tetris/sid.kc | 28 ++++---- src/test/kc/complex/tetris/test-sprites.kc | 6 +- src/test/kc/complex/tetris/tetris-data.kc | 20 +++--- src/test/kc/complex/tetris/tetris-pieces.kc | 20 +++--- src/test/kc/complex/tetris/tetris-play.kc | 24 +++---- src/test/kc/complex/tetris/tetris-render.kc | 24 +++---- src/test/kc/complex/tetris/tetris-sprites.kc | 2 +- src/test/kc/complex/tetris/tetris.kc | 4 +- src/test/ref/complex/tetris/tetris.asm | 12 ++-- src/test/ref/complex/tetris/tetris.log | 74 ++++++++++---------- 10 files changed, 107 insertions(+), 107 deletions(-) diff --git a/src/test/kc/complex/tetris/sid.kc b/src/test/kc/complex/tetris/sid.kc index 94afd4f7e..e31a74d3a 100644 --- a/src/test/kc/complex/tetris/sid.kc +++ b/src/test/kc/complex/tetris/sid.kc @@ -1,21 +1,21 @@ // SID registers for random number generation -const word* SID_VOICE3_FREQ = $d40e; -const char* SID_VOICE3_FREQ_LOW = $d40e; -const char* SID_VOICE3_FREQ_HIGH = $d40f; -const char* SID_VOICE3_CONTROL = $d412; -const char SID_CONTROL_NOISE = $80; -const char SID_CONTROL_PULSE = $40; -const char SID_CONTROL_SAWTOOTH = $20; -const char SID_CONTROL_TRIANGLE = $10; -const char SID_CONTROL_TEST = $08; -const char SID_CONTROL_RING = $04; -const char SID_CONTROL_SYNC = $02; -const char SID_CONTROL_GATE = $01; -const char* SID_VOICE3_OSC = $d41b; +const unsigned int* SID_VOICE3_FREQ = 0xd40e; +const char* SID_VOICE3_FREQ_LOW = 0xd40e; +const char* SID_VOICE3_FREQ_HIGH = 0xd40f; +const char* SID_VOICE3_CONTROL = 0xd412; +const char SID_CONTROL_NOISE = 0x80; +const char SID_CONTROL_PULSE = 0x40; +const char SID_CONTROL_SAWTOOTH = 0x20; +const char SID_CONTROL_TRIANGLE = 0x10; +const char SID_CONTROL_TEST = 0x08; +const char SID_CONTROL_RING = 0x04; +const char SID_CONTROL_SYNC = 0x02; +const char SID_CONTROL_GATE = 0x01; +const char* SID_VOICE3_OSC = 0xd41b; // Initialize SID voice 3 for random number generation void sid_rnd_init() { - *SID_VOICE3_FREQ = $ffff; + *SID_VOICE3_FREQ = 0xffff; *SID_VOICE3_CONTROL = SID_CONTROL_NOISE; } diff --git a/src/test/kc/complex/tetris/test-sprites.kc b/src/test/kc/complex/tetris/test-sprites.kc index 94f1c9fd6..48dcd5127 100644 --- a/src/test/kc/complex/tetris/test-sprites.kc +++ b/src/test/kc/complex/tetris/test-sprites.kc @@ -7,7 +7,7 @@ char[256] SIN = kickasm {{ } }}; -char* SIN_SPRITE = $2800; +char* SIN_SPRITE = 0x2800; kickasm(pc SIN_SPRITE) {{ .fill $40, $ff }} @@ -19,7 +19,7 @@ void main() { *D018 = toD018(PLAYFIELD_SCREEN_1, PLAYFIELD_CHARSET); sprites_init(); - *SPRITES_ENABLE = $ff; + *SPRITES_ENABLE = 0xff; char xpos = 24; char ypos = 50; @@ -40,7 +40,7 @@ void main() { void loop() { while(true) { - do {} while (*RASTER!=$ff); + do {} while (*RASTER!=0xff); char idx = sin_idx; for(char s:4..7) { SPRITES_YPOS[s*2] = SIN[idx]; diff --git a/src/test/kc/complex/tetris/tetris-data.kc b/src/test/kc/complex/tetris/tetris-data.kc index d7f86487b..6c5ed6eb1 100644 --- a/src/test/kc/complex/tetris/tetris-data.kc +++ b/src/test/kc/complex/tetris/tetris-data.kc @@ -2,21 +2,21 @@ // Memory Layout and Shared Data // Address of the first screen -const char* PLAYFIELD_SCREEN_1 = $0400; +const char* PLAYFIELD_SCREEN_1 = 0x0400; // Address of the second screen -const char* PLAYFIELD_SCREEN_2 = $2c00; +const char* PLAYFIELD_SCREEN_2 = 0x2c00; // Screen Sprite pointers on screen 1 const char* PLAYFIELD_SPRITE_PTRS_1 = (PLAYFIELD_SCREEN_1+SPRITE_PTRS); // Screen Sprite pointers on screen 2 const char* PLAYFIELD_SPRITE_PTRS_2 = (PLAYFIELD_SCREEN_2+SPRITE_PTRS); // Address of the original playscreen chars -const char* PLAYFIELD_SCREEN_ORIGINAL = $1800; +const char* PLAYFIELD_SCREEN_ORIGINAL = 0x1800; // Address of the original playscreen colors -const char* PLAYFIELD_COLORS_ORIGINAL = $1c00; +const char* PLAYFIELD_COLORS_ORIGINAL = 0x1c00; // Address of the sprites covering the playfield -const char* PLAYFIELD_SPRITES = $2000; +const char* PLAYFIELD_SPRITES = 0x2000; // Address of the charset -const char* PLAYFIELD_CHARSET = $2800; +const char* PLAYFIELD_CHARSET = 0x2800; // The size of the playfield const char PLAYFIELD_LINES = 22; @@ -36,11 +36,11 @@ char current_piece_char; char current_xpos; char current_ypos; -// The screen currently being rendered to. $00 for screen 1 / $20 for screen 2. -char render_screen_render = $20; -// The screen currently to show next to the user. $00 for screen 1 / $20 for screen 2. +// The screen currently being rendered to. 0x00 for screen 1 / 0x20 for screen 2. +char render_screen_render = 0x20; +// The screen currently to show next to the user. 0x00 for screen 1 / 0x20 for screen 2. char render_screen_show = 0; -// The screen currently being showed to the user. $00 for screen 1 / $20 for screen 2. +// The screen currently being showed to the user. 0x00 for screen 1 / 0x20 for screen 2. volatile char render_screen_showing = 0; // Current score in BCD-format diff --git a/src/test/kc/complex/tetris/tetris-pieces.kc b/src/test/kc/complex/tetris/tetris-pieces.kc index b14ba85a1..1d9fc6dbe 100644 --- a/src/test/kc/complex/tetris/tetris-pieces.kc +++ b/src/test/kc/complex/tetris/tetris-pieces.kc @@ -2,7 +2,7 @@ // The tetris pieces // The T-piece -align($40) char[4*4*4] PIECE_T = { +align(0x40) char[4*4*4] PIECE_T = { 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, @@ -25,7 +25,7 @@ align($40) char[4*4*4] PIECE_T = { }; // The S-piece -align($40) char[4*4*4] PIECE_S = { +align(0x40) char[4*4*4] PIECE_S = { 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, @@ -49,7 +49,7 @@ align($40) char[4*4*4] PIECE_S = { }; // The Z-piece -align($40) char[4*4*4] PIECE_Z = { +align(0x40) char[4*4*4] PIECE_Z = { 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, @@ -73,7 +73,7 @@ align($40) char[4*4*4] PIECE_Z = { }; // The L-piece -align($40) char[4*4*4] PIECE_L = { +align(0x40) char[4*4*4] PIECE_L = { 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, @@ -97,7 +97,7 @@ align($40) char[4*4*4] PIECE_L = { }; // The J-piece -align($40) char[4*4*4] PIECE_J = { +align(0x40) char[4*4*4] PIECE_J = { 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, @@ -121,7 +121,7 @@ align($40) char[4*4*4] PIECE_J = { }; // The O-piece -align($40) char[4*4*4] PIECE_O = { +align(0x40) char[4*4*4] PIECE_O = { 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, @@ -145,7 +145,7 @@ align($40) char[4*4*4] PIECE_O = { }; // The I-piece -align($40) char[4*4*4] PIECE_I = { +align(0x40) char[4*4*4] PIECE_I = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, @@ -169,13 +169,13 @@ align($40) char[4*4*4] PIECE_I = { }; // The different pieces -word[] PIECES = { (word)PIECE_T, (word)PIECE_S, (word)PIECE_Z, (word)PIECE_J, (word)PIECE_O, (word)PIECE_I, (word)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 = { $65, $66, $a6, $66, $65, $65, $a6 }; +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 = { $63, $64, $a4, $64, $63, $63, $a4 }; +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 }; diff --git a/src/test/kc/complex/tetris/tetris-play.kc b/src/test/kc/complex/tetris/tetris-play.kc index 30e695813..e72ae4fe1 100644 --- a/src/test/kc/complex/tetris/tetris-play.kc +++ b/src/test/kc/complex/tetris/tetris-play.kc @@ -17,7 +17,7 @@ char next_piece_idx = 0; // The current moving piece. Points to the start of the piece definition. char* current_piece = 0; -// The curent piece orientation - each piece have 4 orientations (00/$10/$20/$30). +// The curent piece orientation - each piece have 4 orientations (00/0x10/0x20/0x30). // The orientation chooses one of the 4 sub-graphics of the piece. char current_orientation = 0; @@ -36,7 +36,7 @@ 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 = { $0000, $0040, $0100, $0300, $1200 }; +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 @@ -65,7 +65,7 @@ void play_init() { } // Perform any movement of the current piece -// key_event is the next keyboard_event() og $ff if no keyboard event is pending +// key_event is the next keyboard_event() og 0xff if no keyboard event is pending // Returns a byte signaling whether rendering is needed. (0 no render, >0 render needed) char play_movement(char key_event) { char render = 0; @@ -141,11 +141,11 @@ char play_move_leftright(char key_event) { // Return non-zero if a render is needed char play_move_rotate(char key_event) { // Handle keyboard events - char orientation = $80; + char orientation = 0x80; if(key_event==KEY_Z) { - orientation = (current_orientation-$10)&$3f; + orientation = (current_orientation-0x10)&0x3f; } else if(key_event==KEY_X) { - orientation = (current_orientation+$10)&$3f; + orientation = (current_orientation+0x10)&0x3f; } else { return 0; } @@ -183,7 +183,7 @@ char play_collision(char xpos, char ypos, char orientation) { // Below the playfield bottom return COLLISION_BOTTOM; } - if((xp&$80)!=0) { + if((xp&0x80)!=0) { // Beyond left side of the playfield return COLLISION_LEFT; } @@ -273,7 +273,7 @@ char play_remove_lines() { } // Write zeros in the rest of the lines - while(w!=$ff) { + while(w!=0xff) { playfield[w--] = 0; } // Return the number of removed lines @@ -283,7 +283,7 @@ char play_remove_lines() { // Update the score based on the number of lines removed void play_update_score(char removed) { if(removed!=0){ - char lines_before = lines_bcd, 1); render_bcd( screen, lines_offset+1, > 4); } - *screen_pos++ = ZERO_CHAR + (bcd & $0f); + *screen_pos++ = ZERO_CHAR + (bcd & 0x0f); } // Copy the original screen data to the passed screen -// Also copies colors to $d800 +// Also copies colors to 0xd800 void render_screen_original(char* screen) { char SPACE = 0; char* oscr = PLAYFIELD_SCREEN_ORIGINAL+32*2; diff --git a/src/test/kc/complex/tetris/tetris-sprites.kc b/src/test/kc/complex/tetris/tetris-sprites.kc index 144aa058b..f59a30696 100644 --- a/src/test/kc/complex/tetris/tetris-sprites.kc +++ b/src/test/kc/complex/tetris/tetris-sprites.kc @@ -59,7 +59,7 @@ void sprites_irq_init() { // Disable CIA 1 Timer IRQ *CIA1_INTERRUPT = CIA_INTERRUPT_CLEAR; // Set raster line - *VIC_CONTROL &=$7f; + *VIC_CONTROL &=0x7f; *RASTER = IRQ_RASTER_FIRST; // Enable Raster Interrupt *IRQ_ENABLE = IRQ_RASTER; diff --git a/src/test/kc/complex/tetris/tetris.kc b/src/test/kc/complex/tetris/tetris.kc index 6944975be..8f705a761 100644 --- a/src/test/kc/complex/tetris/tetris.kc +++ b/src/test/kc/complex/tetris/tetris.kc @@ -25,8 +25,8 @@ void main() { render_next(); while(true) { // Wait for a frame to pass - while(*RASTER!=$ff) {} - //*BORDERCOL = render_screen_show/$10; + while(*RASTER!=0xff) {} + //*BORDERCOL = render_screen_show/0x10; // Update D018 to show the selected screen render_show(); // Scan keyboard events diff --git a/src/test/ref/complex/tetris/tetris.asm b/src/test/ref/complex/tetris/tetris.asm index 40ba1e199..032f579d0 100644 --- a/src/test/ref/complex/tetris/tetris.asm +++ b/src/test/ref/complex/tetris/tetris.asm @@ -146,7 +146,7 @@ .label current_piece_gfx_1 = $24 .label current_piece_char_1 = $f __b1: - // The screen currently being showed to the user. $00 for screen 1 / $20 for screen 2. + // The screen currently being showed to the user. 0x00 for screen 1 / 0x20 for screen 2. lda #0 sta.z render_screen_showing // Current score in BCD-format @@ -551,7 +551,7 @@ render_playfield: { rts } // Perform any movement of the current piece -// key_event is the next keyboard_event() og $ff if no keyboard event is pending +// key_event is the next keyboard_event() og 0xff if no keyboard event is pending // Returns a byte signaling whether rendering is needed. (0 no render, >0 render needed) // play_movement(byte zeropage($20) key_event) play_movement: { @@ -948,7 +948,7 @@ play_increase_level: { and.z level_bcd cmp #$a bne __b2 - // If level low nybble hits $a change to $10 + // If level low nybble hits 0xa change to 0x10 lax.z level_bcd axs #-[6] stx.z level_bcd @@ -1224,7 +1224,7 @@ keyboard_matrix_read: { eor #$ff rts } -// Update $D018 to show the current screen (used for double buffering) +// Update 0xD018 to show the current screen (used for double buffering) render_show: { .const toD0181_return = (>(PLAYFIELD_SCREEN_1&$3fff)*4)|(>PLAYFIELD_CHARSET)/4&$f .const toD0182_return = (>(PLAYFIELD_SCREEN_2&$3fff)*4)|(>PLAYFIELD_CHARSET)/4&$f @@ -1437,7 +1437,7 @@ render_init: { rts } // Copy the original screen data to the passed screen -// Also copies colors to $d800 +// Also copies colors to 0xd800 // render_screen_original(byte* zeropage($24) screen) render_screen_original: { .const SPACE = 0 @@ -1683,7 +1683,7 @@ sprites_irq: { // These values are updated based on the players level and the base values from SCORE_BASE_BCD score_add_bcd: .fill 4*5, 0 // Pointers to the screen address for rendering each playfield line - // The lines for screen 1 is aligned with $80 and screen 2 with $40 - so XOR'ing with $40 gives screen 2 lines. + // The lines for screen 1 is aligned with 0x80 and screen 2 with 0x40 - so XOR'ing with 0x40 gives screen 2 lines. .align $80 screen_lines_1: .fill 2*PLAYFIELD_LINES, 0 .align $40 diff --git a/src/test/ref/complex/tetris/tetris.log b/src/test/ref/complex/tetris/tetris.log index 3ed4d9ad4..3ad56b19c 100644 --- a/src/test/ref/complex/tetris/tetris.log +++ b/src/test/ref/complex/tetris/tetris.log @@ -13792,7 +13792,7 @@ __bbegin: // @1 __b1: // [1] (byte) render_screen_showing#0 ← (byte) 0 -- vbuz1=vbuc1 - // The screen currently being showed to the user. $00 for screen 1 / $20 for screen 2. + // The screen currently being showed to the user. 0x00 for screen 1 / 0x20 for screen 2. lda #0 sta.z render_screen_showing // [2] (dword) score_bcd#0 ← (byte) 0 -- vduz1=vbuc1 @@ -14847,7 +14847,7 @@ render_playfield: { } // play_movement // Perform any movement of the current piece -// key_event is the next keyboard_event() og $ff if no keyboard event is pending +// key_event is the next keyboard_event() og 0xff if no keyboard event is pending // Returns a byte signaling whether rendering is needed. (0 no render, >0 render needed) // play_movement(byte zeropage($7c) key_event) play_movement: { @@ -15907,7 +15907,7 @@ play_increase_level: { // play_increase_level::@4 __b4: // [330] (byte) level_bcd#8 ← (byte) level_bcd#21 + (byte) 6 -- vbuz1=vbuz1_plus_vbuc1 - // If level low nybble hits $a change to $10 + // If level low nybble hits 0xa change to 0x10 lax.z level_bcd axs #-[6] stx.z level_bcd @@ -16648,7 +16648,7 @@ keyboard_matrix_read: { rts } // render_show -// Update $D018 to show the current screen (used for double buffering) +// Update 0xD018 to show the current screen (used for double buffering) render_show: { .const toD0181_return = (>(PLAYFIELD_SCREEN_1&$3fff)*4)|(>PLAYFIELD_CHARSET)/4&$f .const toD0182_return = (>(PLAYFIELD_SCREEN_2&$3fff)*4)|(>PLAYFIELD_CHARSET)/4&$f @@ -17064,7 +17064,7 @@ render_init: { } // render_screen_original // Copy the original screen data to the passed screen -// Also copies colors to $d800 +// Also copies colors to 0xd800 // render_screen_original(byte* zeropage($70) screen) render_screen_original: { .const SPACE = 0 @@ -17514,7 +17514,7 @@ sprites_irq: { // These values are updated based on the players level and the base values from SCORE_BASE_BCD score_add_bcd: .fill 4*5, 0 // Pointers to the screen address for rendering each playfield line - // The lines for screen 1 is aligned with $80 and screen 2 with $40 - so XOR'ing with $40 gives screen 2 lines. + // The lines for screen 1 is aligned with 0x80 and screen 2 with 0x40 - so XOR'ing with 0x40 gives screen 2 lines. .align $80 screen_lines_1: .fill 2*PLAYFIELD_LINES, 0 .align $40 @@ -18904,7 +18904,7 @@ __bbegin: // @1 __b1: // [1] (byte) render_screen_showing#0 ← (byte) 0 -- vbuz1=vbuc1 - // The screen currently being showed to the user. $00 for screen 1 / $20 for screen 2. + // The screen currently being showed to the user. 0x00 for screen 1 / 0x20 for screen 2. lda #0 sta.z render_screen_showing // [2] (dword) score_bcd#0 ← (byte) 0 -- vduz1=vbuc1 @@ -19866,7 +19866,7 @@ render_playfield: { } // play_movement // Perform any movement of the current piece -// key_event is the next keyboard_event() og $ff if no keyboard event is pending +// key_event is the next keyboard_event() og 0xff if no keyboard event is pending // Returns a byte signaling whether rendering is needed. (0 no render, >0 render needed) // play_movement(byte zeropage($20) key_event) play_movement: { @@ -20785,7 +20785,7 @@ play_increase_level: { // play_increase_level::@4 __b4: // [330] (byte) level_bcd#8 ← (byte) level_bcd#21 + (byte) 6 -- vbuz1=vbuz1_plus_vbuc1 - // If level low nybble hits $a change to $10 + // If level low nybble hits 0xa change to 0x10 lax.z level_bcd axs #-[6] stx.z level_bcd @@ -21441,7 +21441,7 @@ keyboard_matrix_read: { rts } // render_show -// Update $D018 to show the current screen (used for double buffering) +// Update 0xD018 to show the current screen (used for double buffering) render_show: { .const toD0181_return = (>(PLAYFIELD_SCREEN_1&$3fff)*4)|(>PLAYFIELD_CHARSET)/4&$f .const toD0182_return = (>(PLAYFIELD_SCREEN_2&$3fff)*4)|(>PLAYFIELD_CHARSET)/4&$f @@ -21830,7 +21830,7 @@ render_init: { } // render_screen_original // Copy the original screen data to the passed screen -// Also copies colors to $d800 +// Also copies colors to 0xd800 // render_screen_original(byte* zeropage($24) screen) render_screen_original: { .const SPACE = 0 @@ -22244,7 +22244,7 @@ sprites_irq: { // These values are updated based on the players level and the base values from SCORE_BASE_BCD score_add_bcd: .fill 4*5, 0 // Pointers to the screen address for rendering each playfield line - // The lines for screen 1 is aligned with $80 and screen 2 with $40 - so XOR'ing with $40 gives screen 2 lines. + // The lines for screen 1 is aligned with 0x80 and screen 2 with 0x40 - so XOR'ing with 0x40 gives screen 2 lines. .align $80 screen_lines_1: .fill 2*PLAYFIELD_LINES, 0 .align $40 @@ -24178,7 +24178,7 @@ Score: 3353851 __b1: // render_screen_showing = 0 // [1] (byte) render_screen_showing#0 ← (byte) 0 -- vbuz1=vbuc1 - // The screen currently being showed to the user. $00 for screen 1 / $20 for screen 2. + // The screen currently being showed to the user. 0x00 for screen 1 / 0x20 for screen 2. lda #0 sta.z render_screen_showing // score_bcd = 0 @@ -24386,7 +24386,7 @@ main: { // Wait for a frame to pass // main::@2 __b2: - // while(*RASTER!=$ff) + // while(*RASTER!=0xff) // [41] if(*((const byte*) RASTER)!=(byte) $ff) goto main::@2 -- _deref_pbuc1_neq_vbuc2_then_la1 lda #$ff cmp RASTER @@ -24499,12 +24499,12 @@ main: { // render_screen_swap // Swap rendering to the other screen (used for double buffering) render_screen_swap: { - // render_screen_render ^= $20 + // render_screen_render ^= 0x20 // [72] (byte) render_screen_render#11 ← (byte) render_screen_render#18 ^ (byte) $20 -- vbuz1=vbuz1_bxor_vbuc1 lda #$20 eor.z render_screen_render sta.z render_screen_render - // render_screen_show ^= $20 + // render_screen_show ^= 0x20 // [73] (byte) render_screen_show#13 ← (byte) render_screen_show#16 ^ (byte) $20 -- vbuz1=vbuz1_bxor_vbuc1 lda #$20 eor.z render_screen_show @@ -24704,15 +24704,15 @@ render_bcd: { // [104] phi (byte*) render_bcd::screen_pos#3 = (byte*) render_bcd::screen_pos#0 [phi:render_bcd/render_bcd::@2->render_bcd::@1#0] -- register_copy // render_bcd::@1 __b1: - // bcd & $0f + // bcd & 0x0f // [105] (byte~) render_bcd::$3 ← (byte) render_bcd::bcd#6 & (byte) $f -- vbuaa=vbuxx_band_vbuc1 txa and #$f - // ZERO_CHAR + (bcd & $0f) + // ZERO_CHAR + (bcd & 0x0f) // [106] (byte~) render_bcd::$4 ← (const byte) render_bcd::ZERO_CHAR + (byte~) render_bcd::$3 -- vbuaa=vbuc1_plus_vbuaa clc adc #ZERO_CHAR - // *screen_pos++ = ZERO_CHAR + (bcd & $0f) + // *screen_pos++ = ZERO_CHAR + (bcd & 0x0f) // [107] *((byte*) render_bcd::screen_pos#3) ← (byte~) render_bcd::$4 -- _deref_pbuz1=vbuaa ldy #0 sta (screen_pos),y @@ -25047,7 +25047,7 @@ render_playfield: { } // play_movement // Perform any movement of the current piece -// key_event is the next keyboard_event() og $ff if no keyboard event is pending +// key_event is the next keyboard_event() og 0xff if no keyboard event is pending // Returns a byte signaling whether rendering is needed. (0 no render, >0 render needed) // play_movement(byte zeropage($20) key_event) play_movement: { @@ -25136,11 +25136,11 @@ play_move_rotate: { rts // play_move_rotate::@2 __b2: - // current_orientation+$10 + // current_orientation+0x10 // [187] (byte~) play_move_rotate::$5 ← (byte) current_orientation#20 + (byte) $10 -- vbuxx=vbuz1_plus_vbuc1 lax.z current_orientation axs #-[$10] - // orientation = (current_orientation+$10)&$3f + // orientation = (current_orientation+0x10)&0x3f // [188] (byte) play_move_rotate::orientation#2 ← (byte~) play_move_rotate::$5 & (byte) $3f -- vbuz1=vbuxx_band_vbuc1 lda #$3f sax.z orientation @@ -25199,11 +25199,11 @@ play_move_rotate: { rts // play_move_rotate::@1 __b1: - // current_orientation-$10 + // current_orientation-0x10 // [200] (byte~) play_move_rotate::$7 ← (byte) current_orientation#20 - (byte) $10 -- vbuxx=vbuz1_minus_vbuc1 lax.z current_orientation axs #$10 - // orientation = (current_orientation-$10)&$3f + // orientation = (current_orientation-0x10)&0x3f // [201] (byte) play_move_rotate::orientation#1 ← (byte~) play_move_rotate::$7 & (byte) $3f -- vbuz1=vbuxx_band_vbuc1 lda #$3f sax.z orientation @@ -25283,11 +25283,11 @@ play_collision: { rts // play_collision::@4 __b4: - // xp&$80 + // xp&0x80 // [212] (byte~) play_collision::$5 ← (byte) play_collision::xp#2 & (byte) $80 -- vbuaa=vbuz1_band_vbuc1 lda #$80 and.z xp - // if((xp&$80)!=0) + // if((xp&0x80)!=0) // [213] if((byte~) play_collision::$5==(byte) 0) goto play_collision::@5 -- vbuaa_eq_0_then_la1 cmp #0 beq __b5 @@ -25808,7 +25808,7 @@ play_update_score: { // play_remove_lines::@7#0] -- register_copy // Write zeros in the rest of the lines // play_remove_lines::@7 - // while(w!=$ff) + // while(w!=0xff) // [359] if((byte) play_remove_lines::w#6!=(byte) $ff) goto play_remove_lines::@8 -- vbuxx_neq_vbuc1_then_la1 cpx #$ff bne __b8 @@ -26516,7 +26516,7 @@ keyboard_matrix_read: { rts } // render_show -// Update $D018 to show the current screen (used for double buffering) +// Update 0xD018 to show the current screen (used for double buffering) render_show: { .const toD0181_return = (>(PLAYFIELD_SCREEN_1&$3fff)*4)|(>PLAYFIELD_CHARSET)/4&$f .const toD0182_return = (>(PLAYFIELD_SCREEN_2&$3fff)*4)|(>PLAYFIELD_CHARSET)/4&$f @@ -26688,7 +26688,7 @@ sprites_irq_init: { // Disable CIA 1 Timer IRQ lda #CIA_INTERRUPT_CLEAR sta CIA1_INTERRUPT - // *VIC_CONTROL &=$7f + // *VIC_CONTROL &=0x7f // [480] *((const byte*) VIC_CONTROL) ← *((const byte*) VIC_CONTROL) & (byte) $7f -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 // Set raster line lda #$7f @@ -26905,7 +26905,7 @@ render_init: { } // render_screen_original // Copy the original screen data to the passed screen -// Also copies colors to $d800 +// Also copies colors to 0xd800 // render_screen_original(byte* zeropage($24) screen) render_screen_original: { .const SPACE = 0 @@ -27077,7 +27077,7 @@ render_screen_original: { // sid_rnd_init // Initialize SID voice 3 for random number generation sid_rnd_init: { - // *SID_VOICE3_FREQ = $ffff + // *SID_VOICE3_FREQ = 0xffff // [548] *((const word*) SID_VOICE3_FREQ) ← (word) $ffff -- _deref_pwuc1=vwuc2 lda #<$ffff sta SID_VOICE3_FREQ @@ -27335,7 +27335,7 @@ sprites_irq: { // These values are updated based on the players level and the base values from SCORE_BASE_BCD score_add_bcd: .fill 4*5, 0 // Pointers to the screen address for rendering each playfield line - // The lines for screen 1 is aligned with $80 and screen 2 with $40 - so XOR'ing with $40 gives screen 2 lines. + // The lines for screen 1 is aligned with 0x80 and screen 2 with 0x40 - so XOR'ing with 0x40 gives screen 2 lines. .align $80 screen_lines_1: .fill 2*PLAYFIELD_LINES, 0 .align $40