wonx/wonx.c
Hiroaki Sakai 103ffe29f1 We implemented mmap (). Specifically, see README.
Added service function.  (A service function dumping information for debugging,
Added service function for screen drawing ON / OFF control) Specifically, see README.

Make the object's destructor called from bios_exit ()
Add appropriate Destroy function to each object.  Delete objects properly
We have checked the termination process as a whole, as done.

Fix to accept interrupts even during key_wait ().
(Previously, only key input was accepted)

Some timer interrupts are improved.  (UNIXTimer.c)

Change the wonx_include directory to wonx.

Changed to search the full path to perl automatically and insert it at the beginning of perl script.

Makefile review, improvement.

Changed ON / OFF of screen drawing to switch according to display level.
(See README for details.)
Also change to display level lowered by F9 and display level raised by F10.
In accordance with that, we have reviewed a part of ON / OFF part of drawing and key input event processing.

Fixed to display message when pressing key.

Obj ObjListData_GetPrev (ObjListData data)
Obj ObjListData_GetNext (ObjListData data)
To
ObjListData ObjListData_GetPrev (ObjListData data)
ObjListData ObjListData_GetNext (ObjListData data)
Fixed to.

Added install, uninstall target to Makefile.  Fixed challsrc.sh.

Version 2.2 - from wonx-2.2.tar.gz
2018-03-07 23:07:30 +00:00

367 lines
9.1 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
#include <stdlib.h>
#include "wonx/wonx.h"
#include "WonX.h"
#include "WonXDisplay.h"
#include "WWDisplay.h"
#include "XDisplay.h"
#include "WWColorMap.h"
#include "WWPalette.h"
#include "WWCharacter.h"
#include "WWSprite.h"
/*****************************************************************************/
/* 外部に公開する WonX のサービス関数 */
/*****************************************************************************/
/*
* Xサーバとの同期の整合性がとれなくなるなどの問題が考えられるので
* 互換関数の内部は UNIXTimer_Pause(), UNIXTimer_Unpause() でくくり,
* タイマ割り込みを一時停止して処理を行うまたunpause するまえに,
* かならず sync するようにする.
*/
/*
* タイマの一時停止の2重解除の問題が出てくるので,
* 互換関数から互換関数を呼んではいけない.
* (一時停止はネストされるが,いちおう)
* 似たような処理をする関数の場合は,必ず static な別関数に処理をまとめ,
* そっちを呼び出すようにすること.
* 引数の表示の問題もあるしね.
*/
/* カラーマップ情報の出力 */
void wonx_print_colormap_data(void)
{
WWDisplay ww_display;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_print_colormap_data() : \n");
fflush(stdout);
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
WWColorMap_PrintData(WWDisplay_GetColorMap(ww_display), stdout);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : wonx_print_colormap_data() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
/* パレット情報の出力用内部関数 */
static void _print_palette_data(int n)
{
WWDisplay ww_display;
WWPalette ww_palette;
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
ww_palette = WWDisplay_GetPalette(ww_display, n);
WWPalette_PrintData(ww_palette, ww_display, stdout);
return;
}
/* パレット情報の出力 */
void wonx_print_palette_data(int n)
{
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_print_palette_data() : number = %d\n", n);
fflush(stdout);
if ((n < 0) || (n > 16 - 1))
WonX_Error("wonx_print_palette_data", "number is out of range.");
_print_palette_data(n);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : wonx_print_palette_data() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
/* すべてのパレット情報を出力 */
void wonx_print_all_palette_data(void)
{
int n;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_print_all_palette_data() : \n");
fflush(stdout);
for (n = 0; n < 16; n++) _print_palette_data(n);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : wonx_print_all_palette_data() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
/* キャラクタ情報の出力用内部関数 */
static void _print_character_data(int n)
{
WWDisplay ww_display;
WWCharacter ww_character;
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
ww_character = WWDisplay_GetCharacter(ww_display, n);
WWCharacter_PrintData(ww_character, ww_display, stdout);
return;
}
/* キャラクタ情報の出力 */
void wonx_print_character_data(int n)
{
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_print_character_data() : number = %d\n", n);
fflush(stdout);
if ((n < 0) || (n > 512 - 1))
WonX_Error("wonx_print_character_data", "number is out of range.");
_print_character_data(n);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : wonx_print_character_data() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
/* すべてのキャラクタ情報を出力 */
void wonx_print_all_character_data(void)
{
int n;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_print_all_character_data() : \n");
fflush(stdout);
for (n = 0; n < 512; n++) _print_character_data(n);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : wonx_print_all_character_data() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
/* スプライト情報の出力用内部関数 */
static void _print_sprite_data(int n)
{
WWDisplay ww_display;
WWSprite ww_sprite;
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
ww_sprite = WWDisplay_GetSprite(ww_display, n);
WWSprite_PrintData(ww_sprite, stdout);
return;
}
/* スプライト情報の出力 */
void wonx_print_sprite_data(int n)
{
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_print_sprite_data() : number = %d\n", n);
fflush(stdout);
if ((n < 0) || (n > 128 - 1))
WonX_Error("wonx_print_sprite_data", "number is out of range.");
_print_sprite_data(n);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : wonx_print_sprite_data() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
/* すべてのスプライト情報を出力 */
void wonx_print_all_sprite_data(void)
{
int n;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_print_all_sprite_data() : \n");
fflush(stdout);
for (n = 0; n < 128; n++) _print_sprite_data(n);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : wonx_print_all_sprite_data() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
/* 現在の表示/非表示のレベルの取得.(1以上で表示0以下で非表示) */
int wonx_get_lcddraw_level(void)
{
XDisplay x_display;
int ret;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_get_lcddraw_level() : \n");
fflush(stdout);
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
ret = XDisplay_GetLCDDrawLevel(x_display);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : wonx_get_lcddraw_level() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
/* 現在の表示/非表示のレベルの設定 */
int wonx_set_lcddraw_level(int level)
{
XDisplay x_display;
int ret;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_set_lcddraw_level() : level = %d\n", level);
fflush(stdout);
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
ret = XDisplay_SetLCDDrawLevel(x_display, level);
WonXDisplay_Flush(WonX_GetWonXDisplay());
printf("call : wonx_set_lcddraw_level() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
/* 表示レベルを下げる */
int wonx_lcddraw_level_down(void)
{
XDisplay x_display;
int ret;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_lcddraw_level_down() : \n");
fflush(stdout);
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
ret = XDisplay_LCDDrawLevelDown(x_display);
WonXDisplay_Flush(WonX_GetWonXDisplay());
printf("call : wonx_lcddraw_level_down() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
/* 表示レベルを上げる */
int wonx_lcddraw_level_up(void)
{
XDisplay x_display;
int ret;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : wonx_lcddraw_level_up() : \n");
fflush(stdout);
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
ret = XDisplay_LCDDrawLevelUp(x_display);
WonXDisplay_Flush(WonX_GetWonXDisplay());
printf("call : wonx_lcddraw_level_up() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
/*****************************************************************************/
/* End of File. */
/*****************************************************************************/