Files
kichikuou_xsystem35-sdl2/src/scenario.h
T
2023-02-10 20:56:53 +09:00

110 lines
3.3 KiB
C

/*
* scenario.h シナリオ管理実行
*
* Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
* 1998- <masaki-c@is.aist-nara.ac.jp>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/* $Id: scenario.h,v 1.14 2003/04/22 16:34:28 chikama Exp $ */
#ifndef __SCENARIO__
#define __SCENARIO__
#include "portab.h"
#include "system.h"
struct VarRef;
// Warning: changing these enum values will break savedata compatibility.
enum stack_frame_type {
STACK_NEARJMP = 1,
STACK_FARJMP = 2,
STACK_VARIABLE = 3,
STACK_TXXSTATE = 4
};
enum txx_type {
TxxTEXTCOLOR = 1,
TxxTEXTSIZE = 2,
TxxTEXTLOC = 3
};
struct stack_info {
int top_attr; // always zero?
int page_calls;
int label_calls;
int var_pushes;
int label_calls_after_page_call;
int var_pushes_after_call;
};
// Use functions below instead of accessing these variables directly.
extern const uint8_t *sl_sco; // scenario page buffer
extern int sl_page; // current scenario page (0-based)
extern int sl_index; // cureent scenario address
boolean sl_init(void);
boolean sl_reinit(void);
int sl_getw(void);
#define sl_getdw sl_getaddr
int sl_getdAt(int address);
int sl_getwAt(int address);
int sl_getcAt(int address);
int sl_getaddr(void);
void sl_ungetc(void);
const char *sl_getString(char term);
const char *sl_getConstString(void);
void sl_jmpNear(int address);
boolean sl_jmpFar(int page);
boolean sl_jmpFar2(int page, int address);
void sl_callNear(int address);
void sl_retNear(void);
void sl_callFar(int page);
void sl_callFar2(int page, int address);
void sl_retFar(void);
void sl_clearStack(bool restore);
void sl_dropLabelCalls(int cnt);
void sl_dropPageCalls(int cnt);
void sl_pushVar(struct VarRef *vref, int cnt);
void sl_popVar(struct VarRef *vref, int cnt);
int *sl_getStack(int *size);
void sl_putStack(int *data, int size);
void sl_getStackInfo(struct stack_info *info);
void sl_pushState(enum txx_type type, int val1, int val2);
void sl_popState(enum txx_type expected_type);
void *sl_setDataTable(int page, int index);
void sl_returnGoto(int address);
static inline int sl_getIndex(void) { return sl_index; }
static inline int sl_getPage(void) { return sl_page; }
static inline int sl_getc(void) { return sl_sco[sl_index++]; }
#ifdef DEBUG
#define DEBUG_COMMAND_YET(fmt, ...) \
sys_message(2, "%d,%x: " fmt "\n", sl_getPage(), sl_getIndex(), ##__VA_ARGS__)
#define DEBUG_COMMAND(fmt, ...) \
sys_message(5, "%d,%x: " fmt "\n", sl_getPage(), sl_getIndex(), ##__VA_ARGS__)
#define DEBUG_MESSAGE(...) sys_message(6, __VA_ARGS__)
#else
#define DEBUG_COMMAND(...)
#define DEBUG_COMMAND_YET(...)
#define DEBUG_MESSAGE(...)
#endif
#endif /* !__SCENARIO_ */