Implement SACT.PeekKey and SACT.MessagePeek

Used in Rakuen Yuki.
This commit is contained in:
kichikuou
2025-01-08 10:04:28 +09:00
parent 7da9e64ab6
commit c280fc719b
3 changed files with 34 additions and 3 deletions
+14 -3
View File
@@ -1086,15 +1086,24 @@ static void WaitKeySprite() {
/**
* SACT.PeekKey (1.2~)
* ?????
* Get the status of the key
* @param nKeyCode:
* @param vResult:
*/
static void PeekKey() {
static int prevKeyCode = NUM_KEYCODES;
int nKeyCode = getCaliValue();
int *vResult = getCaliVariable();
TRACE_UNIMPLEMENTED("SACT.PeekKey %d,%p:", nKeyCode, vResult);
// This function is called successively with different nKeyCodes.
// Only the first call hits the scheduler.
if (nKeyCode <= prevKeyCode)
sys_getKeyInfo();
prevKeyCode = nKeyCode;
*vResult = RawKeyInfo[nKeyCode] ? 1 : 0;
TRACE("SACT.PeekKey %d,%p:", nKeyCode, vResult);
}
/**
@@ -1320,7 +1329,9 @@ static void MessagePeek() {
int *vCount = getCaliVariable();
int nTopStringNum = getCaliValue();
TRACE_UNIMPLEMENTED("SACT.MessagePeek %p,%d:", vCount, nTopStringNum);
*vCount = smsg_peek(nTopStringNum);
TRACE("SACT.MessagePeek %p,%d:", vCount, nTopStringNum);
}
/**
+1
View File
@@ -89,6 +89,7 @@ extern void smsg_newline(int wNum, int size);
extern void smsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB, int wFont, int wSpeed, int wLineSpace, int wAlign, int wRSize, int wRFont, int wRLineSpace, int *wLength);
extern void smsg_clear(int wNum);
extern int smsg_is_empty();
extern int smsg_peek(int nTopStringNum);
extern int smsg_keywait(int sp1, int sp2, int timeout);
extern int smsg_update(sprite_t *sp);
+19
View File
@@ -385,6 +385,25 @@ int smsg_is_empty() {
return (sact.msgbuf[0] == '\0');
}
int smsg_peek(int nTopStringNum) {
char *p = sact.msgbuf;
int i;
for (i = 0; *p; i++) {
char *q = strchr(p, '\n');
if (q)
*q = '\0';
svar_set(nTopStringNum + i, p);
if (q) {
*q = '\n';
p = q + 2;
} else {
i++;
break;
}
}
return i;
}
/*
メッセージキー入力待ち
@param wNum1: スプライト番号1(アニメーションスプライト)