wonx/WWTimer.c
Hiroaki Sakai c0b964b4f4 Added dummy function of _asm_*().
Set FP_OFF ​(), FP_SEG() for the callback function at interrupt setting in WonderWitch
Adjust appropriately according to the setting method.  (Fit to wwterm)

UNIXTimer.c: UNIXTimer_Unpause()
((unix_timer -> pause == 1) && (unix_timer -> interrupt_in_pause == 0))
Fixed a bug that was not unix_timer-> pause--; when it was.
(It was not unposted when interrupt was not applied during pause)

Serial receive interrupt, keyboard interrupt added.  (corresponding to wwterm, operation confirmed)
Added UNIXSerialPort class.

With this, at WonderWitch,
com_intvector.callback = (void (near *) ()) FP_OFF ​​(com_handler);
com_intvector.cs = _ asm_inline ("\tmov \tax, cs");
com_intvector.ds = _ asm_inline ("\tmov \tax, ds");
sys_interrupt_set_hook (SYS_INT_RECEIVEREADY,
& com_intvector, & com_last_intvector);
Interrupt setting like that shown in Fig.

For warning, add WonX_Warning ().
Move WonX_Error () to WonX.c.

comm_send_string (), text_put_string (), text_put_substring () When executed
Fix output message.

Implement cursor display function.  (Add WWCursor class) (Do not blink. Display only)
When displaying the cursor, text information inside WWDisplay_DrawLCDPanel ()
Since we need to be able to read it, we will discontinue the WonXText class and add the WWText class
I moved to a member of the WWDisplay class.

In palette_get_color (), transparent color is displayed when executing WWPalette_GetMappedColors ()
Since it was not considered to be returned as -1, palette_get_color ()
Fixed a bug where return value was wrong value.

Character color palette, LCD color palette initial value, with WonderWitch
It was made to coincide with the initial value.

As a sample, add wwterm - b 05.  (Add wwterm target to Makefile)

Version 1.1 - from wonx-1.1.tar.gz
2018-03-07 23:07:04 +00:00

115 lines
3.8 KiB
C

/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#include "WWTimerP.h"
#include "WonX.h"
/*****************************************************************************/
/* メンバ関数の定義 */
/*****************************************************************************/
int WWTimer_ON( WWTimer ww_timer) { return (ww_timer->timer_on = 1); }
int WWTimer_OFF( WWTimer ww_timer) { return (ww_timer->timer_on = 0); }
int WWTimer_IsON( WWTimer ww_timer) { return (ww_timer->timer_on != 0); }
int WWTimer_IsOFF(WWTimer ww_timer) { return (ww_timer->timer_on == 0); }
int WWTimer_GetAutoPreset(WWTimer ww_timer)
{ return (ww_timer->auto_preset); }
int WWTimer_GetPresetCounter(WWTimer ww_timer)
{ return (ww_timer->preset_counter); }
int WWTimer_GetCounter(WWTimer ww_timer)
{ return (ww_timer->counter); }
int WWTimer_IsAutoPresetOFF(WWTimer ww_timer)
{ return (WWTimer_GetAutoPreset(ww_timer) == 0); }
int WWTimer_IsAutoPresetON(WWTimer ww_timer)
{ return (WWTimer_GetAutoPreset(ww_timer) == 1); }
int WWTimer_SetAutoPreset(WWTimer ww_timer, int auto_preset)
{ return (ww_timer->auto_preset = auto_preset); }
int WWTimer_SetPresetCounter(WWTimer ww_timer, int preset_counter)
{ return (ww_timer->preset_counter = preset_counter); }
int WWTimer_SetCounter(WWTimer ww_timer, int counter)
{ return (ww_timer->counter = counter); }
int WWTimer_SetAutoPresetOFF(WWTimer ww_timer)
{ return (WWTimer_SetAutoPreset(ww_timer, 0)); }
int WWTimer_SetAutoPresetON(WWTimer ww_timer)
{ return (WWTimer_SetAutoPreset(ww_timer, 1)); }
int WWTimer_Reset(WWTimer ww_timer)
{
int counter;
counter = WWTimer_GetCounter(ww_timer);
WWTimer_SetCounter(ww_timer, WWTimer_GetPresetCounter(ww_timer));
return (counter);
}
int WWTimer_Count(WWTimer ww_timer)
{
int ret;
int counter;
if (WWTimer_IsOFF(ww_timer)) return (0);
counter = WWTimer_GetCounter(ww_timer);
counter--;
if (counter <= 0) {
ret = 1;
if (WWTimer_IsAutoPresetON(ww_timer))
WWTimer_Reset(ww_timer);
else
WWTimer_OFF(ww_timer);
} else {
ret = 0;
WWTimer_SetCounter(ww_timer, counter);
}
return (ret);
}
/*---------------------------------------------------------------------------*/
/* オブジェクトの作成 */
/*---------------------------------------------------------------------------*/
WWTimer WWTimer_Create(int auto_preset, int preset)
{
WWTimer ww_timer;
ww_timer = (WWTimer)malloc(sizeof(_WWTimer));
if (ww_timer == NULL)
WonX_Error("WWTimer_Create", "Cannot allocate memory.");
WWTimer_OFF(ww_timer);
WWTimer_SetAutoPreset(ww_timer, auto_preset);
WWTimer_SetPresetCounter(ww_timer, preset);
WWTimer_Reset(ww_timer);
return (ww_timer);
}
/*---------------------------------------------------------------------------*/
/* オブジェクトの削除 */
/*---------------------------------------------------------------------------*/
WWTimer WWTimer_Destroy(WWTimer ww_timer)
{
if (ww_timer == NULL)
WonX_Error("WWTimer_Destroy", "Object is not created.");
free(ww_timer);
return (NULL);
}
/*****************************************************************************/
/* ここまで */
/*****************************************************************************/
/*****************************************************************************/
/* End of File. */
/*****************************************************************************/