diff --git a/src/main/kc/include/conio.h b/src/main/kc/include/conio.h index caf43c900..0fc7d0182 100644 --- a/src/main/kc/include/conio.h +++ b/src/main/kc/include/conio.h @@ -1,6 +1,9 @@ // Provides provide console input/output // Implements similar functions as conio.h from CC65 for compatibility // See https://github.com/cc65/cc65/blob/master/include/conio.h +// +// Currently only the C64 platform is supported + // clears the screen and moves the cursor to the upper left-hand corner of the screen. void clrscr(void); @@ -17,6 +20,12 @@ unsigned char wherey(void); // Return the current screen size. void screensize(unsigned char* x, unsigned char* y); +// Return the current screen size X width. +char screensizex(); + +// Return the current screen size Y height. +char screensizey(); + // Output one character at the current cursor position void cputc(char c); @@ -58,7 +67,6 @@ unsigned char kbhit (void); // The function returns the old cursor setting. unsigned char cursor(unsigned char onoff); - // The horizontal line character const char CH_HLINE = 0x40; // The vertical line character diff --git a/src/main/kc/lib/conio.c b/src/main/kc/lib/conio.c index 07f98c5ab..91a563e52 100644 --- a/src/main/kc/lib/conio.c +++ b/src/main/kc/lib/conio.c @@ -1,6 +1,8 @@ // Provides provide console input/output // Implements similar functions as conio.h from CC65 for compatibility // See https://github.com/cc65/cc65/blob/master/include/conio.h +// +// Currently only the C64 platform is supported #include // The text screen address @@ -71,6 +73,16 @@ void screensize(unsigned char* x, unsigned char* y) { *y = CONIO_HEIGHT; } +// Return the current screen size X width. +inline char screensizex() { + return CONIO_WIDTH; +} + +// Return the current screen size Y height. +inline char screensizey() { + return CONIO_HEIGHT; +} + // Return the X position of the cursor inline unsigned char wherex(void) { return conio_cursor_x; @@ -159,8 +171,7 @@ unsigned char bgcolor(unsigned char color) { } // Set the color for the border. The old color setting is returned. -unsigned char bordercolor(unsigned char color) -{ +unsigned char bordercolor(unsigned char color) { char old = *CONIO_BORDERCOLOR; *CONIO_BORDERCOLOR = color; return old; diff --git a/src/test/ref/examples/conio/nacht-screen.log b/src/test/ref/examples/conio/nacht-screen.log index df8462544..9158793ff 100644 --- a/src/test/ref/examples/conio/nacht-screen.log +++ b/src/test/ref/examples/conio/nacht-screen.log @@ -22,43 +22,45 @@ Culled Empty Block (label) @2 Culled Empty Block (label) @3 Culled Empty Block (label) @4 Culled Empty Block (label) @5 +Culled Empty Block (label) @6 +Culled Empty Block (label) @7 Culled Empty Block (label) cputc::@6 Culled Empty Block (label) cputc::@7 Culled Empty Block (label) cputc::@2 Culled Empty Block (label) cputc::@8 -Culled Empty Block (label) @6 -Culled Empty Block (label) @7 +Culled Empty Block (label) @8 +Culled Empty Block (label) @9 Culled Empty Block (label) cputs::@4 Culled Empty Block (label) cputs::@3 Culled Empty Block (label) cputs::@5 Culled Empty Block (label) cputs::@6 -Culled Empty Block (label) @8 -Culled Empty Block (label) @9 +Culled Empty Block (label) @10 +Culled Empty Block (label) @11 Culled Empty Block (label) chline::@4 Culled Empty Block (label) chline::@3 Culled Empty Block (label) chline::@5 Culled Empty Block (label) chline::@6 -Culled Empty Block (label) @10 +Culled Empty Block (label) @12 Culled Empty Block (label) cvline::@4 Culled Empty Block (label) cvline::@3 Culled Empty Block (label) cvline::@5 Culled Empty Block (label) cvline::@6 -Culled Empty Block (label) @11 -Culled Empty Block (label) @12 -Culled Empty Block (label) textcolor::@1 Culled Empty Block (label) @13 -Culled Empty Block (label) bgcolor::@1 Culled Empty Block (label) @14 -Culled Empty Block (label) bordercolor::@1 +Culled Empty Block (label) textcolor::@1 Culled Empty Block (label) @15 -Culled Empty Block (label) kbhit::@1 +Culled Empty Block (label) bgcolor::@1 Culled Empty Block (label) @16 -Culled Empty Block (label) cursor::@1 +Culled Empty Block (label) bordercolor::@1 Culled Empty Block (label) @17 +Culled Empty Block (label) kbhit::@1 Culled Empty Block (label) @18 +Culled Empty Block (label) cursor::@1 Culled Empty Block (label) @19 Culled Empty Block (label) @20 Culled Empty Block (label) @21 +Culled Empty Block (label) @22 +Culled Empty Block (label) @23 Culled Empty Block (label) strlen::@4 Culled Empty Block (label) strlen::@5 Culled Empty Block (label) strlen::@6 @@ -67,8 +69,8 @@ Culled Empty Block (label) main::@2 Culled Empty Block (label) main::@4 Culled Empty Block (label) main::@5 Culled Empty Block (label) main::@6 -Culled Empty Block (label) @23 -Culled Empty Block (label) @24 +Culled Empty Block (label) @25 +Culled Empty Block (label) @26 Culled Empty Block (label) MakeNiceScreen::@4 Culled Empty Block (label) MakeNiceScreen::@3 Culled Empty Block (label) MakeNiceScreen::@5 @@ -82,7 +84,7 @@ CONTROL FLOW GRAPH SSA (byte*) conio_cursor_color#0 ← (const nomodify byte*) CONIO_SCREEN_COLORS (byte) conio_textcolor#0 ← (const nomodify byte) CONIO_TEXTCOLOR_DEFAULT (byte) conio_display_cursor#0 ← (byte) 0 - to:@22 + to:@24 (void()) clrscr() clrscr: scope:[clrscr] from MakeNiceScreen::@9 main::@3 @@ -747,7 +749,7 @@ strlen::@return: scope:[strlen] from strlen::@3 (word) strlen::return#1 ← (word) strlen::return#3 return to:@return -@22: scope:[] from @begin +@24: scope:[] from @begin (byte) conio_display_cursor#25 ← phi( @begin/(byte) conio_display_cursor#0 ) (byte*) conio_cursor_color#117 ← phi( @begin/(byte*) conio_cursor_color#0 ) (byte*) conio_cursor_text#117 ← phi( @begin/(byte*) conio_cursor_text#0 ) @@ -756,16 +758,16 @@ strlen::@return: scope:[strlen] from strlen::@3 (byte) conio_textcolor#37 ← phi( @begin/(byte) conio_textcolor#0 ) (volatile byte) XSize ← (byte) 0 (volatile byte) YSize ← (byte) 0 - to:@25 + to:@27 (void()) main() -main: scope:[main] from @25 - (byte) conio_display_cursor#20 ← phi( @25/(byte) conio_display_cursor#19 ) - (byte*) conio_cursor_color#113 ← phi( @25/(byte*) conio_cursor_color#109 ) - (byte*) conio_cursor_text#113 ← phi( @25/(byte*) conio_cursor_text#109 ) - (byte) conio_cursor_y#113 ← phi( @25/(byte) conio_cursor_y#110 ) - (byte) conio_cursor_x#113 ← phi( @25/(byte) conio_cursor_x#110 ) - (byte) conio_textcolor#33 ← phi( @25/(byte) conio_textcolor#23 ) +main: scope:[main] from @27 + (byte) conio_display_cursor#20 ← phi( @27/(byte) conio_display_cursor#19 ) + (byte*) conio_cursor_color#113 ← phi( @27/(byte*) conio_cursor_color#109 ) + (byte*) conio_cursor_text#113 ← phi( @27/(byte*) conio_cursor_text#109 ) + (byte) conio_cursor_y#113 ← phi( @27/(byte) conio_cursor_y#110 ) + (byte) conio_cursor_x#113 ← phi( @27/(byte) conio_cursor_x#110 ) + (byte) conio_textcolor#33 ← phi( @27/(byte) conio_textcolor#23 ) *((const nomodify byte*) VIC_MEMORY) ← (number) $17 (byte*) screensize::x#0 ← &(volatile byte) XSize (byte*) screensize::y#0 ← &(volatile byte) YSize @@ -1219,22 +1221,22 @@ MakeNiceScreen::@return: scope:[MakeNiceScreen] from MakeNiceScreen::@1 (byte) conio_display_cursor#6 ← (byte) conio_display_cursor#13 return to:@return -@25: scope:[] from @22 - (byte) conio_display_cursor#19 ← phi( @22/(byte) conio_display_cursor#25 ) - (byte*) conio_cursor_color#109 ← phi( @22/(byte*) conio_cursor_color#117 ) - (byte*) conio_cursor_text#109 ← phi( @22/(byte*) conio_cursor_text#117 ) - (byte) conio_cursor_y#110 ← phi( @22/(byte) conio_cursor_y#117 ) - (byte) conio_cursor_x#110 ← phi( @22/(byte) conio_cursor_x#117 ) - (byte) conio_textcolor#23 ← phi( @22/(byte) conio_textcolor#37 ) +@27: scope:[] from @24 + (byte) conio_display_cursor#19 ← phi( @24/(byte) conio_display_cursor#25 ) + (byte*) conio_cursor_color#109 ← phi( @24/(byte*) conio_cursor_color#117 ) + (byte*) conio_cursor_text#109 ← phi( @24/(byte*) conio_cursor_text#117 ) + (byte) conio_cursor_y#110 ← phi( @24/(byte) conio_cursor_y#117 ) + (byte) conio_cursor_x#110 ← phi( @24/(byte) conio_cursor_x#117 ) + (byte) conio_textcolor#23 ← phi( @24/(byte) conio_textcolor#37 ) call main - to:@26 -@26: scope:[] from @25 - (byte) conio_display_cursor#14 ← phi( @25/(byte) conio_display_cursor#4 ) - (byte*) conio_cursor_color#88 ← phi( @25/(byte*) conio_cursor_color#27 ) - (byte*) conio_cursor_text#88 ← phi( @25/(byte*) conio_cursor_text#27 ) - (byte) conio_cursor_y#90 ← phi( @25/(byte) conio_cursor_y#27 ) - (byte) conio_cursor_x#90 ← phi( @25/(byte) conio_cursor_x#28 ) - (byte) conio_textcolor#16 ← phi( @25/(byte) conio_textcolor#4 ) + to:@28 +@28: scope:[] from @27 + (byte) conio_display_cursor#14 ← phi( @27/(byte) conio_display_cursor#4 ) + (byte*) conio_cursor_color#88 ← phi( @27/(byte*) conio_cursor_color#27 ) + (byte*) conio_cursor_text#88 ← phi( @27/(byte*) conio_cursor_text#27 ) + (byte) conio_cursor_y#90 ← phi( @27/(byte) conio_cursor_y#27 ) + (byte) conio_cursor_x#90 ← phi( @27/(byte) conio_cursor_x#28 ) + (byte) conio_textcolor#16 ← phi( @27/(byte) conio_textcolor#4 ) (byte) conio_textcolor#7 ← (byte) conio_textcolor#16 (byte) conio_cursor_x#46 ← (byte) conio_cursor_x#90 (byte) conio_cursor_y#45 ← (byte) conio_cursor_y#90 @@ -1242,14 +1244,14 @@ MakeNiceScreen::@return: scope:[MakeNiceScreen] from MakeNiceScreen::@1 (byte*) conio_cursor_color#45 ← (byte*) conio_cursor_color#88 (byte) conio_display_cursor#7 ← (byte) conio_display_cursor#14 to:@end -@end: scope:[] from @26 +@end: scope:[] from @28 SYMBOL TABLE SSA (const byte*) $0::Msg[(number) $28] = { fill( $28, 0) } (byte) $0::Y -(label) @22 -(label) @25 -(label) @26 +(label) @24 +(label) @27 +(label) @28 (label) @begin (label) @end (const nomodify byte) CH_HLINE = (byte) $40 @@ -3107,8 +3109,8 @@ Added new block during phi lifting cputc::@11(between cputc::@3 and cputc::@retu Added new block during phi lifting cputc::@12(between cputc::@4 and cputc::@return) Fixing phi predecessor for conio_cursor_x#52 to new block ( cputc::@4 -> cputc::@12 ) during phi lifting. Adding NOP phi() at start of @begin -Adding NOP phi() at start of @25 -Adding NOP phi() at start of @26 +Adding NOP phi() at start of @27 +Adding NOP phi() at start of @28 Adding NOP phi() at start of @end Adding NOP phi() at start of main::@7 Adding NOP phi() at start of main::@8 @@ -3242,7 +3244,7 @@ Coalesced [255] gotoxy::y#14 ← gotoxy::y#5 Coalesced [258] cvline::i#6 ← cvline::i#1 Coalesced [259] cvline::y#7 ← cvline::y#1 Coalesced down to 24 phi equivalence classes -Culled Empty Block (label) @26 +Culled Empty Block (label) @28 Culled Empty Block (label) main::@8 Culled Empty Block (label) main::@10 Culled Empty Block (label) clrscr::@3 @@ -3260,8 +3262,8 @@ Culled Empty Block (label) strlen::@3 Culled Empty Block (label) MakeTeeLine::@3 Culled Empty Block (label) cputcxy::@2 Culled Empty Block (label) cvlinexy::@2 -Renumbering block @22 to @1 -Renumbering block @25 to @2 +Renumbering block @24 to @1 +Renumbering block @27 to @2 Renumbering block clrscr::@4 to clrscr::@2 Renumbering block clrscr::@5 to clrscr::@3 Renumbering block clrscr::@6 to clrscr::@4