Module libc

Module libc 

Source
Expand description

Bindings for the MEGA65-libc library

This exposes the mega65-libc library to Rust via automatically generated bindings. While all required 65c02 opcodes are present in llvm-mos, they have not yet made it into rust-mos. For this reason, routines in fileio.h are currently unavailable.

Example:

unsafe {
    mega65::libc::mega65_fast();
    let address = mega65::libc::getscreenaddr();
}

Structs§

dmagic_dmalist
m65_dirent
m65_tm
tagRECT

Constants§

ATTRIB_BLINK
ATTRIB_HIGHLIGHT
ATTRIB_REVERSE
ATTRIB_UNDERLINE
BOX_STYLE_INNER
BOX_STYLE_MID
BOX_STYLE_NONE
BOX_STYLE_OUTER
BOX_STYLE_ROUND
CINPUT_ACCEPT_ALL
CINPUT_ACCEPT_ALPHA
CINPUT_ACCEPT_LETTER
CINPUT_ACCEPT_NUMERIC
CINPUT_NO_AUTOTRANSLATE
COLOUR_BLACK
COLOUR_BLUE
COLOUR_BROWN
COLOUR_CYAN
COLOUR_DARKGREY
COLOUR_GREEN
COLOUR_GREY
COLOUR_GREY1
COLOUR_GREY2
COLOUR_GREY3
COLOUR_LIGHTBLUE
COLOUR_LIGHTGREEN
COLOUR_LIGHTGREY
COLOUR_MEDIUMGREY
COLOUR_ORANGE
COLOUR_PINK
COLOUR_PURPLE
COLOUR_RED
COLOUR_WHITE
COLOUR_YELLOW
HLINE_STYLE_BTM1_8
HLINE_STYLE_BTM3_8
HLINE_STYLE_BTM_NORMAL
HLINE_STYLE_BTM_THIN
HLINE_STYLE_CHECKER
HLINE_STYLE_MID
HLINE_STYLE_TOP1_8
HLINE_STYLE_TOP3_8
HLINE_STYLE_TOP_NORMAL
HLINE_STYLE_TOP_THIN
KEYMOD_ALT
KEYMOD_CAPSLOCK
KEYMOD_CTRL
KEYMOD_LSHIFT
KEYMOD_MEGA
KEYMOD_NOSCRL
KEYMOD_RSHIFT
TARGET_MEGA65R1
TARGET_MEGA65R2
TARGET_MEGA65R3
TARGET_MEGAPHONER1
TARGET_MEGAPHONER4
TARGET_NEXYS4
TARGET_NEXYS4DDR
TARGET_NEXYS4DDRWIDGET
TARGET_SIMULATION
TARGET_UNKNOWN
TARGET_WUKONG
TEST_DONEALL
TEST_ERROR
TEST_FAIL
TEST_LOG
TEST_PASS
TEST_SETNAME
TEST_SKIP
TEST_START
VLINE_STYLE_CHECKER
VLINE_STYLE_LEFT_NORMAL
VLINE_STYLE_MID
VLINE_STYLE_RIGHT_NORMAL

Statics§

dma_byte
dmalist
sector_buffer

Functions§

_cprintf
altpal
\m65libsummary{altpal}{Enable the alternate-palette attribute} \m65libsyntax {void altpal(unsigned char c)} \m65libparam {enable}{0 to disable, 1 to enable} \m65libremarks {Extended attributes mode must be active. See setextendedattrib.}
bgcolor
\m65libsummary{bgcolor}{Sets the current screen (background) color} \m65libsyntax {void bgcolor(unsigned char c)} \m65libparam {c}{The color to set}
blink
\m65libsummary{blink}{Enable the blink attribute} \m65libsyntax {void blink(unsigned char c)} \m65libparam {enable}{0 to disable, 1 to enable} \m65libremarks {Extended attributes mode must be active. See setextendedattrib.}
bordercolor
\m65libsummary{bordercolor}{Sets the current border color} \m65libsyntax {void bordercolor(unsigned char c)} \m65libparam {c}{The color to set}
box_
\m65libsummary{box}{Draws a box with graphic characters} \m65libsyntax {void box(const RECT *rc, unsigned char color, unsigned char style, unsigned char clear, unsigned char shadow)} \m65libparam {rc}{A RECT structure specifying the box coordinates} \m65libparam {color}{The color to use for the graphic characters} \m65libparam {style}{The style for the box borders. Can be set to BOX_STYLE_NONE, BOX_STYLE_ROUNDED, BOX_STYLE_INNER, BOX_STYLE_OUTER, BOX_STYLE_MID } \m65libparam {clear}{Set to 1 to clear the box interior with the selected color} \m65libparam {shadow}{Set to 1 to draw a drop shadow} \m65libremarks {No screen bounds checks are performed; out of screen behavior is undefined }
cellcolor
\m65libsummary{cellcolor}{Sets the color of a character cell} \m65libsyntax {void cellcolor(unsigned char x, unsigned char y, unsigned char c)} \m65libparam {x}{The cell X-coordinate} \m65libparam {y}{The cell Y-coordinate} \m65libparam {c}{The color to set} \m65libremarks {No screen bounds checks are performed; out of screen behavior is undefined }
cgetc
\m65libsummary{cgetc}{ Waits until a character is in the keyboard buffer and returns it } \m65libsyntax {unsigned char cgetc (void);} \m65libretval {The last character in the keyboard buffer } \m65libremarks {Returned values are ASCII character codes}
chdir
chdirroot
cinput
\m65libsummary{cinput}{Get input from keyboard, printing incoming characters at current position.} \m65libsyntax {unsigned char cinput(char* buffer, unsigned char buflen, unsigned char flags)} \m65libparam {buffer}{Target character buffer preallocated by caller} \m65libparam {buflen}{Target buffer length in characters, including the null character terminator} \m65libparam {flags}{Flags for input: (default is accept all printable characters) %< \texttt{CINPUT_ACCEPT_NUMERIC} \ Accepts numeric characters. \ \ \texttt{CINPUT_ACCEPT_LETTER} \ Accepts letters. \ \ \texttt{CINPUT_ACCEPT_SYM} \ Accepts symbols. \ \ \texttt{CINPUT_ACCEPT_ALL}\ Accepts all. Equals to \texttt{CINPUT_ACCEPT_NUMERIC \textbar CINPUT_ACCEPT_LETTER \textbar CINPUT_ACCEPT_SYM} \ \ \texttt{CINPUT_ACCEPT_ALPHA} \ Accepts alphanumeric characters. Equals to \texttt{CINPUT_ACCEPT_NUMERIC \textbar CINPUT_ACCEPT_LETTER} \ \ \texttt{CINPUT_NO_AUTOTRANSLATE}\ Disables the feature that makes cinput to autodisplay uppercase characters when standard lowercase character set is selected and the user enters letters without the SHIFT key, that would display graphic characters instead of alphabetic ones. \ %>}
clearattr
\m65libsummary{clearattr}{Clear all text attributes} \m65libsyntax {void clearattr())} \m65libremarks {Extended attributes mode must be active. See setextendedattrib.}
close
closeall
closedir
clrscr
\m65libsummary{clrscr}{Clear the text screen. } \m65libsyntax {void clrscr(void)} \m65example { // Clear screen to white textcolor(COLOUR_WHITE); clrscr(); } \m65libremarks{Color RAM will be cleared with current text color}
conioinit
\m65libsummary{conionit}{Initialises the library internal state} \m65libsyntax {void conioinit(void)} \m65libremarks{This must be called before using any conio library function.}
cputc
\m65libsummary{cputc}{Output a single screen code character to screen at current position} \m65libsyntax {void cputc(unsigned char c)} \m65libparam {c}{The screen code of the character to output}
cputcxy
\m65libsummary{cputcxy}{Output a single character at X,Y coordinates} \m65libsyntax {void cputcxy (unsigned char x, unsigned char y, unsigned char c)} \m65libparam {x}{The X coordinate where character will be printed} \m65libparam {y}{The Y coordinate where character will be printed} \m65libparam {c}{The screen code of the character to print}
cputdec
\m65libsummary{cputdec}{Output a decimal number at current position} \m65libsyntax {void cputdec(long n, unsigned char padding, unsigned char leadingZ)} \m65libparam {n}{The number to write} \m65libparam {padding}{The padding space to add before number} \m65libparam {leadingZ}{The leading zeros to print}
cputhex
\m65libsummary{cputhex}{Output an hex-formatted number at current position} \m65libsyntax {void cputhex(long n, unsigned char prec)} \m65libparam {n}{The number to write} \m65libparam {prec}{The precision of the hex number, in digits. Leading zeros will be printed accordingly} \m65libremarks {The $ symbol will be automatically added at beginning of string}
cputnc
\m65libsummary{cputnc}{Output N copies of a character at current position} \m65libsyntax {void cputnc(unsigned char count, unsigned char c)} \m65libparam {c}{The screen code of the characters to output} \m65libparam {count}{The count of characters to print}
cputncxy
\m65libsummary{cputncxy}{Output N copies of a single character at X,Y coordinates} \m65libsyntax {void cputncxy (unsigned char x, unsigned char y, unsigned char count, unsigned char c)} \m65libparam {x}{The X coordinate where character will be printed} \m65libparam {y}{The Y coordinate where character will be printed} \m65libparam {count}{The number of characters to output} \m65libparam {c}{The screen code of the characters to print}
cputs
\m65libsummary{cputs}{Output screen codes at current position} \m65libsyntax {void cputs(const unsigned char* s)} \m65libparam {s}{Am array of screen codes to print} \m65libremarks {This function works with screen codes only. To output ordinary ASCII/PETSCII strings, use the “pcputs” macro. No pointer check is performed. If s is null or invalid, behavior is undefined. }
cputsxy
\m65libsummary{cputsxy}{Output multiple screen codes at X,Y coordinates} \m65libsyntax {void cputsxy (unsigned char x, unsigned char y, const unsigned char* s)} \m65libparam {x}{The X coordinate where string will be printed} \m65libparam {y}{The Y coordinate where string will be printed} \m65libparam {s}{An array of screen codes to print} \m65libremarks {This function works with screen codes only. To output ordinary ASCII/PETSCII strings, use the “pcputsxy” macro. No pointer check is performed. If s is null or invalid, behavior is undefined. }
debug_msg
detect_target
fillrect
\m65libsummary{fillrect}{Fill a rectangular area with character and color value} \m65libsyntax {void fillrect(const RECT *rc, unsigned char ch, unsigned char col)} \m65libparam {rc}{A RECT structure specifying the box coordinates} \m65libparam {ch}{A char code to fill the rectangle} \m65libparam {col}{The color to fill} \m65libremarks {No screen bounds checks are performed; out of screen behavior is undefined }
flushkeybuf
\m65libsummary{flushkeybuf}{Flush the keyboard buffer} \m65libsyntax {void flushkeybuf(void)}
getcharsetaddr
\m65libsummary{getcharsetaddr}{Returns the current character set start address} \m65libsyntax {long getscreenaddr(void);} \m65libretval {The current character set start address.}
getcolramoffset
\m65libsummary{getcolramoffset}{Returns the color RAM start offset value} \m65libsyntax {long getscreenaddr(void);} \m65libretval {The current color RAM start offset value.}
getkeymodstate
\m65libsummary{getkeymodstate}{ Return the key modifiers state.} \m65libsyntax {unsigned char getkeymodstate(void)} \m65libretval {A byte with the key modifier state bits, where bits: %< \begin{tabular}{lll} \textbf{Bit} & \textbf{Meaning} & \textbf{Constant} \ 0 & Right SHIFT State & \texttt{KEYMOD_RSHIFT} \ 1 & Left SHIFT state & \texttt{KEYMOD_LSHIFT} \ 2 & CTRL state & \texttt{KEYMOD_CTRL} \ 3 & MEGA state & \texttt{KEYMOD_MEGA} \ 4 & ALT state & \texttt{KEYMOD_ALT} \ 5 & NOSCRL state & \texttt{KEYMOD_NOSCRL} \ 6 & CAPSLOCK state & \texttt{KEYMOD_CAPSLOCK} \ 7 & Reserved & - \ \end{tabular} %>}
getmapedpal
\m65libsummary{getmapedpal}{Get maped-in palette bank at $D100-$D3FF.} \m65libsyntax {unsigned char getmapedpal(void)}
getpalbank
\m65libsummary{getpalbank}{Get selected text/bitmap palette bank.} \m65libsyntax {unsigned char getpalbank(void)} \m65libremarks {Use getpalbanka to get alternate text/bitmap selected palette} \m65libretval {The current selected main text/bitmap palette bank.}
getpalbanka
\m65libsummary{getpalbanka}{Get selected alternate text/bitmap palette bank.} \m65libsyntax {unsigned char getpalbanka(void)} \m65libremarks {Use getpalbank to get main text/bitmap selected palette} \m65libretval {The current selected alternate text/bitmap palette bank.}
getrtc
getscreenaddr
\m65libsummary{getscreenaddr}{Returns the screen RAM start address} \m65libsyntax {long getscreenaddr(void);} \m65libretval {The current screen RAM address start address.}
getscreensize
\m65libsummary{getscreensize}{Returns the dimensions of the text screen} \m65libsyntax {void getscreensize(unsigned char* width, unsigned char* height)} \m65libparam {width}{Pointer to location where width will be returned} \m65libparam {height}{Pointer to location where height will be returned}
gohome
\m65libsummary{gohome}{Set the current position at home (0,0 coordinate)} \m65libsyntax {void gohome(void)}
gotox
\m65libsummary{gotox}{Set the current position X-coordinate} \m65libsyntax {void gotox(unsigned char x)} \m65libparam {x}{The new X-coordinate} \m65libremarks {No screen bounds checks are performed; out of screen behavior is undefined }
gotoxy
\m65libsummary{gotoxy}{Set the current position at X,Y coordinates} \m65libsyntax {void gotoxy(unsigned char x, unsigned char y)} \m65libparam {x}{The new X-coordinate} \m65libparam {y}{The new Y-coordinate} \m65libremarks {No screen bounds checks are performed; out of screen behavior is undefined }
gotoy
\m65libsummary{gotoy}{Set the current position Y-coordinate} \m65libsyntax {void gotoy(unsigned char y)} \m65libparam {y}{The new Y-coordinate} \m65libremarks {No screen bounds checks are performed; out of screen behavior is undefined }
highlight
\m65libsummary{highlight}{Enable the highlight attribute} \m65libsyntax {void highlight(unsigned char c)} \m65libparam {enable}{0 to disable, 1 to enable} \m65libremarks {Extended attributes mode must be active. See setextendedattrib.}
hline
\m65libsummary{hline}{Draws an horizontal line.} \m65libsyntax {void hline(unsigned char x, unsigned char y, unsigned char len, unsigned char style)} \m65libparam {x}{The line start X-coordinate} \m65libparam {y}{The line start Y-coordinate} \m65libparam {len}{The line length} \m65libparam {style}{The style for the line. See HLINE_ constants for available styles. } \m65libremarks {No screen bounds checks are performed; out of screen behavior is undefined }
kbhit
\m65libsummary{kbhit}{ Returns the character in the keyboard buffer } \m65libsyntax {unsigned char kbhit (void);} \m65libretval {The character code in the keyboard buffer, 0 otherwise. } \m65libremarks {Returned values are ASCII character codes}
lcopy
lfill
lfill_skip
lpeek
lpeek_debounced
lpoke
mega65_clear_sector_buffer
mega65_fast
mega65_io_enable
mega65_sdcard_erase
mega65_sdcard_map_sector_buffer
mega65_sdcard_open
mega65_sdcard_readsector
mega65_sdcard_reset
mega65_sdcard_unmap_sector_buffer
mega65_sdcard_writesector
movedown
\m65libsummary{movedown}{Move current position down} \m65libsyntax {void movedown(unsigned char count)} \m65libparam {count}{The number of positions to move} \m65libremarks {No screen bounds checks are performed; out of screen behavior is undefined }
moveleft
\m65libsummary{moveleft}{Move current position left} \m65libsyntax {void moveleft(unsigned char count)} \m65libparam {count}{The number of positions to move} \m65libremarks {No screen bounds checks are performed; out of screen behavior is undefined }
moveright
\m65libsummary{moveright}{Move current position right} \m65libsyntax {void moveright(unsigned char count)} \m65libparam {count}{The number of positions to move} \m65libremarks {No screen bounds checks are performed; out of screen behavior is undefined }
moveup
\m65libsummary{moveup}{Move current position up} \m65libsyntax {void moveup(unsigned char count)} \m65libparam {count}{The number of positions to move} \m65libremarks {No screen bounds checks are performed; out of screen behavior is undefined }
open
opendir
petsciitoscreencode
petsciitoscreencode_s
rand8
rand16
rand32
random8
random16
random32
read512
readdir
revers
\m65libsummary{revers}{Enable the reverse attribute} \m65libsyntax {void revers(unsigned char c)} \m65libparam {enable}{0 to disable, 1 to enable} \m65libremarks {Extended attributes mode must be active. See setextendedattrib.}
set16bitcharmode
\m65libsummary{set16bitcharmode}{Sets or clear the 16-bit character mode} \m65libsyntax {void set16bitcharmode(unsigned char f)} \m65libparam {f}{Set true to set the 16-bit character mode} \m65libremarks {This will trigger a video parameter reset if HOTREG is ENABLED. See sethotregs function.}
setcharsetaddr
\m65libsummary{setcharsetaddr}{Sets the character set start address} \m65libsyntax {void setcharsetaddr(long addr);} \m65libparam {addr}{The address to set as start of character set} \m65libremarks {No bounds check is performed on the selected address}
setcolramoffset
\m65libsummary{setcolramoffset}{Sets the color RAM start offset value} \m65libsyntax {void setcolramoffset(long offset);} \m65libparam {addr}{The offset from the beginning of the color RAM address ($FF80000)} \m65libremarks{No bounds check is performed on the resulting address. Do not exceed the available Color RAM size}
setextendedattrib
\m65libsummary{setextendedattrib}{Sets or clear the VIC-III extended attributes mode to support blink, underline, bold and highlight.} \m65libsyntax {void setextendedattrib(unsigned char f)} \m65libparam {f}{Set true to set the extended attributes mode}
sethotregs
\m65libsummary{sethotregs}{Sets or clear the hot-register behavior of the VIC-IV chip.} \m65libsyntax {void set16bitcharmode(unsigned char f)} \m65libparam {f}{Set true to enable the hotreg behavior} \m65libremarks {When this mode is ENABLED a video mode reset will be triggered when touching $D011, $D016, $D018, $D031 or the VIC-II bank bits of $DD00. }
setlowercase
\m65libsummary{togglecase}{Set lower case character set} \m65libsyntax {void setlowercase(void)}
setmapedpal
\m65libsummary{setmapedpal}{Set maped-in palette bank at $D100-$D3FF.} \m65libsyntax {void setmapedpal(unsigned char bank)} \m65libparam {bank}{The palette bank to map-in. Valid values are 0, 1, 2 or 3.}
setpalbank
\m65libsummary{setpalbank}{Set current text/bitmap palette bank (BTPALSEL).} \m65libsyntax {void setpalbank(unsigned char bank)} \m65libparam {bank}{The palette bank to set. Valid values are 0, 1, 2 or 3.} \m65libremarks {Use setpalbanka to set alternate text/bitmap palette}
setpalbanka
\m65libsummary{setpalbanka}{Set alternate text/bitmap palette bank.} \m65libsyntax {void setpalbanka(unsigned char bank)} \m65libparam {bank}{The palette bank to set. Valid values are 0, 1, 2 or 3.} \m65libremarks {Use setpalbank to set main text/bitmap palette}
setpalentry
\m65libsummary{setpalentry}{Set color entry for the maped-in palette} \m65libsyntax {void setpalentry(unsigned char c, unsigned char r, unsigned char g, unsigned char b)} \m65libparam {c}{The palette entry index (0-255)} \m65libparam {r}{The red component value} \m65libparam {g}{The green component value} \m65libparam {b}{The blue component value} \m65libremarks {Use setmapedmal to bank-in the palette to modify}
setrtc
setscreenaddr
\m65libsummary{setscreenaddr}{Sets the screen RAM start address} \m65libsyntax {void setscreenaddr(long addr);} \m65libparam {addr}{The address to set as start of screen RAM} \m65example { // Set beginning of screen RAM at $48000 setscreenaddr(0x48000UL); } \m65libremarks{No bounds check is performed on the selected address}
setscreensize
\m65libsummary{setscreensize}{Sets the dimensions of the text screen} \m65libsyntax {void setscreensize(unsigned char width, unsigned char height)} \m65libparam {width}{The width in columns (40 or 80)} \m65libparam {height}{The height in rows (25 or 50)} \m65libremarks {Currently only 40/80 and 25/50 are accepted. Other values are ignored.}
setuppercase
\m65libsummary{togglecase}{Set upper case character set} \m65libsyntax {void setuppercase(void)}
srand
textcolor
\m65libsummary{textcolor}{Sets the current text color} \m65libsyntax {void textcolor(unsigned char c)} \m65libparam {c}{The color to set} \m65libremarks {This function preserves attributes in the upper 4-bits if extended attributes are enabled. See setextendedattrib. }
toggle_rom_write_protect
togglecase
\m65libsummary{togglecase}{Toggle the current character set case} \m65libsyntax {void togglecase(void)}
underline
\m65libsummary{underline}{Enable the underline attribute} \m65libsyntax {void underline(unsigned char c)} \m65libparam {enable}{0 to disable, 1 to enable} \m65libremarks {Extended attributes mode must be active. See setextendedattrib.}
unit_test_done
\brief Finish test procedure and tell m65 to exit
unit_test_fail
\brief Report a failed test with a optional message \param msg Description of the failed test (NULL uses global testName)
unit_test_log
\brief Logs a message on the host machine \param msg The message to be logged
unit_test_ok
\brief Report a successful test with a optional message \param msg Description of the successful test (NULL uses global testName)
unit_test_report
\brief Reports unit test result to the host machine \param issue The issue number that identifies the test issue \param sub The sub issue number (for multiple tests per issue) \param status The test status to be sent
unit_test_set_current_name
\brief Reports current test name to the host machine \param name The human-readable name of the current test
unit_test_setup
\brief Setup of the unit test reporting to the host machine \param param testName Human readable name of the test \param issueNum The mega65-core issue number that identifies the test issue
usleep
vline
\m65libsummary{vline}{Draws a vertical line.} \m65libsyntax {void vline(unsigned char x, unsigned char y, unsigned char len, unsigned char style)} \m65libparam {x}{The line start X-coordinate} \m65libparam {y}{The line start Y-coordinate} \m65libparam {len}{The line length} \m65libparam {style}{The style for the line. See VLINE_ constants for available styles. } \m65libremarks {No screen bounds checks are performed; out of screen behavior is undefined }
wherex
\m65libsummary{wherex}{Return the current position X coordinate} \m65libsyntax {unsigned char wherex(void)} \m65libretval {The current position X coordinate}
wherey
\m65libsummary{wherey}{Return the current position Y coordinate} \m65libsyntax {unsigned char wherey(void)} \m65libretval {The current position Y coordinate}

Type Aliases§

RECT
int_fast8_t
int_fast16_t
int_fast32_t
int_fast64_t
int_least8_t
int_least16_t
int_least32_t
int_least64_t
intmax_t
uint_fast8_t
uint_fast16_t
uint_fast32_t
uint_fast64_t
uint_least8_t
uint_least16_t
uint_least32_t
uint_least64_t
uintmax_t