📄 pc.c
字号:
/*Example,porting ucosii to simuos 20041123*/
/*Author:lmjx
**Email :limiao@yeah.net
**You can FREE use this copy for LEARN or EDUCATE purpose.
**For more information access www.mshowtec.com
**/
#include "../../simulator/export.h"
#include "../example/includes.h"
/*
*********************************************************************************************************
* CHECK AND GET KEYBOARD KEY
*
* Description: This function checks to see if a key has been pressed at the keyboard and returns TRUE if
* so. Also, if a key is pressed, the key is read and copied where the argument is pointing
* to.
*
* Arguments : c is a pointer to where the read key will be stored.
*
* Returns : TRUE if a key was pressed
* FALSE otherwise
*********************************************************************************************************
*/
BOOLEAN PC_GetKey(INT16S * c)
{
return 1;
}
/*
*********************************************************************************************************
* DISPLAY A STRING AT 'X' & 'Y' COORDINATE
*
* Description : This function writes an ASCII string anywhere on the PC's screen. This function writes
* directly to video RAM instead of using the BIOS for speed reasons. It assumed that the
* video adapter is VGA compatible. Video RAM starts at absolute address 0x000B8000. Each
* character on the screen is composed of two bytes: the ASCII character to appear on the
* screen followed by a video attribute. An attribute of 0x07 displays the character in
* WHITE with a black background.
*
* Arguments : x corresponds to the desired column on the screen. Valid columns numbers are from
* 0 to 79. Column 0 corresponds to the leftmost column.
* y corresponds to the desired row on the screen. Valid row numbers are from 0 to 24.
* Line 0 corresponds to the topmost row.
* s Is the ASCII string to display. You can also specify a string containing
* characters with numeric values higher than 128. In this case, special character
* based graphics will be displayed.
* color specifies the foreground/background color to use (see PC.H for available choices)
*
* Returns : None
*********************************************************************************************************
*/
void PC_DispStr(INT8U x, INT8U y, INT8U * s, INT8U color)
{
}
/*
*********************************************************************************************************
* DISPLAY A SINGLE CHARACTER AT 'X' & 'Y' COORDINATE
*
* Description : This function writes a single character anywhere on the PC's screen. This function
* writes directly to video RAM instead of using the BIOS for speed reasons. It assumed
* that the video adapter is VGA compatible. Video RAM starts at absolute address
* 0x000B8000. Each character on the screen is composed of two bytes: the ASCII character
* to appear on the screen followed by a video attribute. An attribute of 0x07 displays
* the character in WHITE with a black background.
*
* Arguments : x corresponds to the desired column on the screen. Valid columns numbers are from
* 0 to 79. Column 0 corresponds to the leftmost column.
* y corresponds to the desired row on the screen. Valid row numbers are from 0 to 24.
* Line 0 corresponds to the topmost row.
* c Is the ASCII character to display. You can also specify a character with a
* numeric value higher than 128. In this case, special character based graphics
* will be displayed.
* color specifies the foreground/background color to use (see PC.H for available choices)
*
* Returns : None
*********************************************************************************************************
*/
void PC_DispChar(INT8U x, INT8U y, INT8U c, INT8U color)
{
}
/*
*********************************************************************************************************
* CLEAR SCREEN
*
* Description : This function clears the PC's screen by directly accessing video RAM instead of using
* the BIOS. It assumed that the video adapter is VGA compatible. Video RAM starts at
* absolute address 0x000B8000. Each character on the screen is composed of two bytes:
* the ASCII character to appear on the screen followed by a video attribute. An attribute
* of 0x07 displays the character in WHITE with a black background.
*
* Arguments : color specifies the foreground/background color combination to use
* (see PC.H for available choices)
*
* Returns : None
*********************************************************************************************************
*/
void PC_DispClrScr(INT8U color)
{
}
/*
*********************************************************************************************************
* ELAPSED TIME INITIALIZATION
*
* Description : This function initialize the elapsed time module by determining how long the START and
* STOP functions take to execute. In other words, this function calibrates this module
* to account for the processing time of the START and STOP functions.
* Needs to be called only once before any of the timers is started with PC_ElapsedStart().
*
* Arguments : None.
*
* Returns : None.
*********************************************************************************************************
*/
static INT16U PC_ElapsedOverhead=0;
void PC_ElapsedInit(void)
{
static BOOLEAN initDone=FALSE;
if (initDone)
return;
PC_ElapsedOverhead = 0; // Measure the overhead of PC_ElapsedStart
PC_ElapsedStart(); // ... and PC_ElapsedStop
PC_ElapsedOverhead = (INT16U) PC_ElapsedStop();
initDone=TRUE;
}
/*
*********************************************************************************************************
* START A TIMER FOR EXECUTION TIME MEASUREMENT
*
* Description : Trigger the timer to be used to measure the time between events.
* Timer will be running when the function returns.
* Time measurement needs to be initalized before by calling PC_ElapsedInit, only
* needed once for all timers together.
*
* Arguments : n=0...NTIMERS-1 number of timer
*
* Returns : None.
*********************************************************************************************************
*/
void PC_ElapsedStart()
{
INT32U ms;
ms = 1000/OS_TICKS_PER_SEC;
starttimer(ms);
}
/*
*********************************************************************************************************
* STOP A TIMER FOR EXECUTION TIMER MEASUREMENT
*
* Description : This function stops the the timer for execution time measurement and computes the
* time in microseconds since the timer was started with PC_ElapsedStart.
*
* Arguments : n=0...NTIMERS-1 number of timer.
*
* Returns : The number of micro-seconds since the timer was last started.
*
* Notes : - The returned time accounts for the processing time of the START and STOP functions.
*
*********************************************************************************************************
*/
INT32U PC_ElapsedStop()
{
stoptimer();
return curTick*(1000/OS_TICKS_PER_SEC);;
}
/*
*********************************************************************************************************
* SET THE PC'S TICK FREQUENCY
*
*********************************************************************************************************
*/
void PC_SetTickRate (INT32U tickPerSec)
{
INT32U ms;
ms = 1000/tickPerSec;
curTick = 0;
PC_ElapsedOverhead = 0;
starttimer(ms);
}
/*
*********************************************************************************************************
* GET THE CURRENT DATE AND TIME
*
* Description: This function obtains the current date and time from the PC.
*
* Arguments : s is a pointer to where the ASCII string of the current date and time will be stored.
* You must allocate at least 21 bytes (includes the NUL) of storage in the return
* string. The date and time will be formatted as follows:
*
* "YYYY-MM-DD HH:MM:SS"
*
* Returns : none
*********************************************************************************************************
*/
void PC_GetDateTime(char *s)
{
}
/*
*********************************************************************************************************
* INSTALL INTERRUPT VECTOR
*
* Description: This function sets an interrupt vector in the "simulated" interrupt vector table.
*
* Arguments : vect is the desired interrupt vector number, a number between 1 and 7.
* isr is a pointer to a function to execute when the interrupt or exception occurs.
*
* Interrupt 0 cannot be set, because it is reserved for the timer interrupt.
*
* Returns : none
*********************************************************************************************************
*/
void PC_IntVectSet(INT8U irq, void (*isr)(void))
{ if ((irq >=0) && (irq < 8))
IntVetTbl[irq]=isr;
}
/*
*********************************************************************************************************
* OBTAIN INTERRUPT VECTOR
*
* Description: This function reads the pointer stored at the specified vector.
*
* Arguments : vect is the desired interrupt vector number, a number between 0 and 7.
*
* Returns : The address of the Interrupt handler stored at the desired vector location.
*********************************************************************************************************
*/
void *PC_IntVectGet(INT8U irq)
{ if (irq < 8)
return IntVetTbl[irq];
else
return NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -