1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-09-08 17:54:40 +00:00

Changed to standard C syntax.

This commit is contained in:
jespergravgaard 2019-10-30 08:32:11 +01:00
parent 7f9fd7b46a
commit acb71114e2
10 changed files with 107 additions and 107 deletions

View File

@ -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;
}

View File

@ -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];

View File

@ -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

View File

@ -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 };

View File

@ -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&$f0;
char lines_before = <lines_bcd&0xf0;
unsigned long add_bcd = score_add_bcd[removed];
asm { sed }
@ -292,7 +292,7 @@ void play_update_score(char removed) {
asm { cld }
// If line 10-part updated increase the level
char lines_after = <lines_bcd&$f0;
char lines_after = <lines_bcd&0xf0;
if(lines_before!=lines_after) {
play_increase_level();
}
@ -311,8 +311,8 @@ void play_increase_level() {
}
// Increase BCD-format level
level_bcd++;
if((level_bcd&$f)==$a) {
// If level low nybble hits $a change to $10
if((level_bcd&0xf)==0xa) {
// If level low nybble hits 0xa change to 0x10
level_bcd += 6;
}
// Increase the score values gained

View File

@ -40,9 +40,9 @@ char[] PIECES_COLORS_2 = {
};
// 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.
align($80) char*[PLAYFIELD_LINES] screen_lines_1;
align($40) char*[PLAYFIELD_LINES] screen_lines_2;
// 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;
// Initialize rendering
void render_init() {
@ -71,10 +71,10 @@ void render_init() {
// Show showing screen 1 and rendering to screen 2
render_screen_show = 0;
render_screen_render = $20;
render_screen_render = 0x20;
}
// Update $D018 to show the current screen (used for double buffering)
// Update 0xD018 to show the current screen (used for double buffering)
void render_show() {
char d018val = 0;
if(render_screen_show==0) {
@ -90,8 +90,8 @@ void render_show() {
// Swap rendering to the other screen (used for double buffering)
void render_screen_swap() {
render_screen_render ^= $20;
render_screen_show ^= $20;
render_screen_render ^= 0x20;
render_screen_show ^= 0x20;
}
// Show the current score
@ -104,16 +104,16 @@ void render_score() {
}
char* score_bytes = (byte*)(&score_bcd);
unsigned int score_offset = 40*$05 + $1c;
unsigned int score_offset = 40*0x05 + 0x1c;
render_bcd( screen, score_offset, score_bytes[2], 0);
render_bcd( screen, score_offset+2, score_bytes[1], 0);
render_bcd( screen, score_offset+4, score_bytes[0], 0);
unsigned int lines_offset = 40*$01 + $16;
unsigned int lines_offset = 40*0x01 + 0x16;
render_bcd( screen, lines_offset, >lines_bcd, 1);
render_bcd( screen, lines_offset+1, <lines_bcd, 0);
unsigned int level_offset = 40*19 + $1f;
unsigned int level_offset = 40*19 + 0x1f;
render_bcd( screen, level_offset, level_bcd, 0);
}
@ -129,11 +129,11 @@ void render_bcd(char* screen, unsigned int offset, char bcd, char only_low) {
if(only_low==0) {
*screen_pos++ = ZERO_CHAR + (bcd >> 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;

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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: {
// <lines_bcd
// [308] (byte~) play_update_score::$2 ← < (word) lines_bcd#19 -- vbuaa=_lo_vwuz1
lda.z lines_bcd
// lines_before = <lines_bcd&$f0
// lines_before = <lines_bcd&0xf0
// [309] (byte) play_update_score::lines_before#0 ← (byte~) play_update_score::$2 & (byte) $f0 -- vbuz1=vbuaa_band_vbuc1
and #$f0
sta.z lines_before
@ -25860,7 +25860,7 @@ play_update_score: {
// <lines_bcd
// [316] (byte~) play_update_score::$4 ← < (word) lines_bcd#29 -- vbuaa=_lo_vwuz1
lda.z lines_bcd
// lines_after = <lines_bcd&$f0
// lines_after = <lines_bcd&0xf0
// [317] (byte) play_update_score::lines_after#0 ← (byte~) play_update_score::$4 & (byte) $f0 -- vbuaa=vbuaa_band_vbuc1
and #$f0
// if(lines_before!=lines_after)
@ -25915,18 +25915,18 @@ play_increase_level: {
// level_bcd++;
// [327] (byte) level_bcd#21 ← ++ (byte) level_bcd#11 -- vbuz1=_inc_vbuz1
inc.z level_bcd
// level_bcd&$f
// level_bcd&0xf
// [328] (byte~) play_increase_level::$1 ← (byte) level_bcd#21 & (byte) $f -- vbuaa=vbuz1_band_vbuc1
lda #$f
and.z level_bcd
// if((level_bcd&$f)==$a)
// if((level_bcd&0xf)==0xa)
// [329] if((byte~) play_increase_level::$1!=(byte) $a) goto play_increase_level::@2 -- vbuaa_neq_vbuc1_then_la1
cmp #$a
bne __b2
// play_increase_level::@4
// level_bcd += 6
// [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
@ -26090,7 +26090,7 @@ play_remove_lines: {
// [358] phi (byte) play_remove_lines::w#6 = (byte) play_remove_lines::w#11 [phi:play_remove_lines::@6/play_remove_lines::@8->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