wonx/WWCharacter.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

153 lines
4.2 KiB
C
Raw 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 "WWCharacterP.h"
#include "WonX.h"
/*****************************************************************************/
/* メンバ関数の定義 */
/*****************************************************************************/
int WWCharacter_GetNumber(WWCharacter c)
{
if (c == NULL) WonX_Error("WWCharacter_GetNumber()", "WWCharacter is NULL.");
return (c->number);
}
int WWCharacter_SetNumber(WWCharacter c, int n)
{
if ((n < 0) || (n >= 512))
WonX_Error("WWCharacter_SetNumber()", "Invalid range.");
return (c->number = n);
}
WWCharacter WWCharacter_Create(int number, unsigned char * bitmap)
{
WWCharacter character;
character = (WWCharacter)malloc(sizeof(_WWCharacter));
if (character == NULL)
WonX_Error("WWCharacter_Create", "Cannot allocate memory.");
WWCharacter_SetNumber(character, number);
WWCharacter_SetBitmap(character, bitmap);
return (character);
}
WWCharacter WWCharacter_Destroy(WWCharacter character)
{
if (character == NULL)
WonX_Error("WWCharacter_Destroy()", "WWCharacter is NULL.");
free(character);
return (NULL);
}
unsigned char * WWCharacter_GetBitmap(WWCharacter character)
{
return (character->bitmap);
}
int WWCharacter_SetBitmap(WWCharacter character, unsigned char * bitmap)
{
int i;
if (character == NULL)
WonX_Error("WWCharacter_SetBitmap()", "WWCharacter is NULL.");
for (i = 0; i < 16; i++) {
if (bitmap == NULL) {
character->bitmap[i] = 0x00;
} else {
character->bitmap[i] = bitmap[i];
}
}
return (0);
}
int WWCharacter_GetPixel(WWCharacter character, int x, int y)
{
if (character == NULL)
WonX_Error("WWCharacter_GetPixel()", "WWCharacter is NULL.");
if ((x < 0) || (x > 7))
WonX_Error("WWCharacter_GetPixel()", "x is invalid value.");
if ((y < 0) || (y > 7))
WonX_Error("WWCharacter_GetPixel()", "y is invalid value.");
/* ビットマップは2ビットでぴとつのピクセルに対応する */
/* 2ビットの値がpalette の色に対応する. */
/* bitmap は unsigned char bitmap[16]; に定義してある. */
/* パレット色(03)を返す */
return ( (character->bitmap[y * 2 + x / 4] >> ((x % 4) * 2)) & 0x03 );
}
int WWCharacter_SetPixel(WWCharacter character, int x, int y, int pixel)
{
unsigned char p;
if (character == NULL)
WonX_Error("WWCharacter_SetPixel()", "WWCharacter is NULL.");
if ((x < 0) || (x > 7))
WonX_Error("WWCharacter_SetPixel()", "x is invalid value.");
if ((y < 0) || (y > 7))
WonX_Error("WWCharacter_SetPixel()", "y is invalid value.");
if ((pixel < 0) || (pixel > 3))
WonX_Error("WWCharacter_SetPixel()", "Invalid pixel.");
p = ((unsigned char)pixel) & 0x03;
p = p << ((x % 4) * 2);
character->bitmap[y * 2 + x / 4] &= ~(0x03 << ((x % 4) * 2));
character->bitmap[y * 2 + x / 4] |= p;
return (pixel);
}
int WWCharacter_CopyBitmap(WWCharacter dst, WWCharacter src)
{
return (WWCharacter_SetBitmap(dst, src->bitmap));
}
int WWCharacter_PrintData(WWCharacter character, FILE * f)
{
int x, y, i, n;
n = WWCharacter_GetNumber(character);
fprintf(f, "\n");
fprintf(f, "character[%d] :\tnumber = %d\n",
n, WWCharacter_GetNumber(character));
for (i = 0; i < 16; i++) {
fprintf(f, "character[%d] :\tbitmap[%d] = 0x%02x\n",
n, i, (int)(WWCharacter_GetBitmap(character)[i]));
}
for (y = 0; y < 8; y++) {
fprintf(f, "character[%d] :\tbitmap : ", n);
for (x = 0; x < 8; x++) {
fprintf(f, "%d", WWCharacter_GetPixel(character, x, y));
}
fprintf(f, "\n");
}
fflush(f);
return (0);
}
/*****************************************************************************/
/* ここまで */
/*****************************************************************************/
/*****************************************************************************/
/* End of File. */
/*****************************************************************************/