Browse Source

- Transfer to WonderSwan Color development kit
- Add colormode, palette, color statement, hardarch system variable
- Add a digression to the document

Version 0.06 - from wonbe006.lzh

Kawamata Akira 23 years ago
parent
commit
7d4a34e405
8 changed files with 195 additions and 16 deletions
  1. 11 0
      colordemo.wb
  2. 12 7
      keywords.h
  3. 1 1
      makefile
  4. 23 0
      makefile.tc
  5. 120 5
      wonbe.c
  6. BIN
      wonbe.exe
  7. BIN
      wonbe.fx
  8. 28 3
      wonbe.txt

+ 11 - 0
colordemo.wb

@@ -0,0 +1,11 @@
+100 rem draw random characters
+110 if hardarch = 0 then print "Try in WonerSwanColor":a=wait:end
+120 colormode 128
+200 for i=0 to 1000
+300 locate rnd(28), rnd(17):color rnd(4), rnd(4):print chr(rnd(256));
+400 next
+450 locate 0,0:color 3,0:print "Push START to exit...."
+500 rem palette random
+600 palette rnd(4), rnd(16), rnd(16), rnd(16)
+700 waitvb 30
+800 goto 500

+ 12 - 7
keywords.h

@@ -34,12 +34,15 @@
 #define	KEYWORD_INT			0x9b
 #define	KEYWORD_TRON		0x9c
 #define	KEYWORD_TROFF		0x9d
+#define KEYWORD_COLORMODE	0x9e
+#define KEYWORD_PALETTE		0x9f
+#define KEYWORD_COLOR		0xa0
 
-#define	KEYWORD_AND			0xa0
-#define	KEYWORD_OR			0xa1
-#define	KEYWORD_XOR			0xa2
+#define	KEYWORD_AND			0xb0
+#define	KEYWORD_OR			0xb1
+#define	KEYWORD_XOR			0xb2
 
-#define	KEYWORD_NOT			0xb0
+#define	KEYWORD_NOT			0xb8
 #define	KEYWORD_SCAN		0xc0
 #define	KEYWORD_WAIT		0xc1
 #define	KEYWORD_RND			0xc2
@@ -62,6 +65,7 @@
 #define	KEYWORD_SCAN_Y2		0xd7
 #define	KEYWORD_SCAN_Y3		0xd8
 #define	KEYWORD_SCAN_Y4		0xd9
+#define KEYWORD_HARDARCH	0xda
 
 #define	KEYWORD_AX			0xe0
 #define	KEYWORD_BX			0xe1
@@ -79,9 +83,9 @@
 #define	KEYWORD_STEP		0xf3
 
 #define KEYWORDS_STATEMENT_FROM 0x80
-#define KEYWORDS_STATEMENT_TO 0x9d
-#define KEYWORDS_2OP_FROM 0xa0
-#define KEYWORDS_2OP_TO 0xa2
+#define KEYWORDS_STATEMENT_TO 0xa0
+#define KEYWORDS_2OP_FROM 0xb0
+#define KEYWORDS_2OP_TO 0xb2
 
 /*
 WONBE 中間言語フォーマット
@@ -93,6 +97,7 @@ WONBE 
  1行の構造
 
 WORD 行番号 (1-32767)
+WORD 行の長さ
 任意の中間コードの列
 BYTE 0x0d 行末ターミネータ
 

+ 1 - 1
makefile

@@ -1,7 +1,7 @@
 INCLUDE=C:\vshare\ww\dev\WWitch\include
 LIB=..\COMMON
 
-LIBS=libww.lib runtime.lib
+LIBS=libww.lib libwwc.lib runtime.lib
 
 LINKER=..\..\vc15\bin\link
 CC=..\..\vc15\bin\cl

+ 23 - 0
makefile.tc

@@ -0,0 +1,23 @@
+
+# start up routine
+C0WW_JAPANESE2=..\common\c0wwjpn2.obj
+
+C0WW=$(C0WW_JAPANESE2)
+
+LIBWW=@..\common\libww.rsp
+
+CFLAGS=-DWW -ms -zPCGROUP -zSDGROUP -zGDGROUP
+
+all:	wonbe.fx
+
+wonbe.fx:	wonbe.bin
+	mkfent wonbe.cf
+
+wonbe.bin:	wonbe.obj
+	tlink /m /c $(C0WW) wonbe, wonbe, wonbe, $(LIBWW)
+	exe2fbin wonbe.exe wonbe.bin
+
+wonbe.obj:	wonbe.c
+	tcc -c $(CFLAGS) $(DEFINES) -IC:\vshare\ww\dev\WWitch\include wonbe.c
+
+

+ 120 - 5
wonbe.c

@@ -21,6 +21,7 @@
 #include <sys/process.h>
 #include <sys/fcntl.h>
 #include <sys/bios.h>
+#include <sys/libwwc.h>
 #define assert(x)
 #endif
 #include "keywords.h"
@@ -33,7 +34,7 @@
 #include <stdarg.h>
 #endif
 
-char myVersion[] = "0.05";
+char myVersion[] = "0.06";
 
 #ifdef WW
 #define NEWLINE "\xa\xd"
@@ -90,6 +91,13 @@ void fatalExit( const char * msg )
 }
 #endif
 
+#ifdef WW
+BOOL isWonderSwanColor()
+{
+	return wwc_get_hardarch() != HARDARCH_WS;
+}
+#endif
+
 BOOL commonPrint( FILE FAR * fp, const char * msg,... )
 {
 #ifdef WW
@@ -184,6 +192,8 @@ KEYWORDITEM keywordsC[] = {
 	{ KEYWORD_CALL, "call" },
 	{ KEYWORD_CSEG, "cseg" },
 	{ KEYWORD_CX,"cx" },
+	{ KEYWORD_COLORMODE,"colormode" },
+	{ KEYWORD_COLOR,"color" },
 	{ 0,NULL }
 };
 
@@ -216,6 +226,11 @@ KEYWORDITEM keywordsG[] = {
 	{ 0,NULL }
 };
 
+KEYWORDITEM keywordsH[] = {
+	{ KEYWORD_HARDARCH,"hardarch" },
+	{ 0,NULL }
+};
+
 KEYWORDITEM keywordsI[] = {
 	{ KEYWORD_IF,"if" },
 	{ KEYWORD_INT, "int" },
@@ -250,6 +265,7 @@ KEYWORDITEM keywordsP[] = {
 	{ KEYWORD_PLAY,"play" },
 	{ KEYWORD_PEEK, "peek" },
 	{ KEYWORD_POKE, "poke" },
+	{ KEYWORD_PALETTE, "palette" },
 	{ 0,NULL }
 };
 
@@ -309,7 +325,7 @@ KEYWORDITEM keywordsX[] = {
 
 KEYWORDITEM * keywordsIndex[26] = {
 	keywordsA, keywordsB, keywordsC, keywordsD, 
-	keywordsE, keywordsF, keywordsG, NULL, 
+	keywordsE, keywordsF, keywordsG, keywordsH, 
 	keywordsI, NULL,      NULL,      keywordsL, 
 	keywordsM, keywordsN, keywordsO, keywordsP, 
 	NULL,      keywordsR, keywordsS, keywordsT, 
@@ -506,14 +522,14 @@ void cantContinue()
 
 void saveError()
 {
-	commonPrint(NULL, "Save Erroor in %d\x7" NEWLINE, currentLineNumber );
+	commonPrint(NULL, "Save Error in %d\x7" NEWLINE, currentLineNumber );
 	bForceToReturnSuper = TRUE;
 	requestNextAction = REQUEST_INTERACTIVE;
 }
 
 void paramError()
 {
-	commonPrint(NULL, "Parameter Erroor in %d\x7" NEWLINE, currentLineNumber );
+	commonPrint(NULL, "Parameter Error in %d\x7" NEWLINE, currentLineNumber );
 	bForceToReturnSuper = TRUE;
 	requestNextAction = REQUEST_INTERACTIVE;
 }
@@ -1002,6 +1018,12 @@ SHORT calcValue()
 		return 1024;
 	case KEYWORD_SCAN_Y4:
 		return 2048;
+	case KEYWORD_HARDARCH:
+#ifdef WW
+		return wwc_get_hardarch();
+#else
+		return 0;	/* DUMMY VALUE */
+#endif
 	case KEYWORD_DEFSEG:
 		return defseg;
 	case KEYWORD_DSEG:
@@ -1961,6 +1983,96 @@ void st_troff()
 	traceFlag = FALSE;
 }
 
+void st_colormode()
+{
+	SHORT newmode;
+	newmode = expr();
+	if( bForceToReturnSuper ) return;
+#ifdef WW
+	if( isWonderSwanColor() ) {
+		/*SHORT result;*/
+		/*result =*/ wwc_set_color_mode( newmode );
+		/*if( result != newmode ) {*/
+		/*	paramError();*/	/* 値の設定に失敗したとき */
+		/*	return;*/
+		/*}*/
+	}
+#else
+	printf("colormode: %d\n", newmode );
+#endif
+}
+
+void st_palette()
+{
+	SHORT index, r, g, b;
+	BYTE ch;
+	index = expr();
+	if( bForceToReturnSuper ) return;
+	while( TRUE ) {
+		ch = *executionPointer++;
+		if( ch != ' ' && ch != '\t' ) break;
+	}
+	if( ch != ',' ) {
+		syntaxError();
+		return;
+	}
+	r = expr();
+	if( bForceToReturnSuper ) return;
+
+	while( TRUE ) {
+		ch = *executionPointer++;
+		if( ch != ' ' && ch != '\t' ) break;
+	}
+	if( ch != ',' ) {
+		syntaxError();
+		return;
+	}
+	g = expr();
+	if( bForceToReturnSuper ) return;
+
+	while( TRUE ) {
+		ch = *executionPointer++;
+		if( ch != ' ' && ch != '\t' ) break;
+	}
+	if( ch != ',' ) {
+		syntaxError();
+		return;
+	}
+	b = expr();
+	if( bForceToReturnSuper ) return;
+
+#ifdef WW
+	if( isWonderSwanColor() ) {
+		wwc_palette_set_color(0, index, ((r << 8)&0xf00) | ((g << 4)&0xf0) | (b&0xf)  );
+	}
+#else
+	printf("palette: %d (%d,%d,%d)\n", index, r, g, b );
+#endif
+}
+
+void st_color()
+{
+	SHORT fore, back;
+	BYTE ch;
+	fore = expr();
+	if( bForceToReturnSuper ) return;
+	while( TRUE ) {
+		ch = *executionPointer++;
+		if( ch != ' ' && ch != '\t' ) break;
+	}
+	if( ch != ',' ) {
+		syntaxError();
+		return;
+	}
+	back = expr();
+	if( bForceToReturnSuper ) return;
+#ifdef WW
+	font_set_color( (fore & 0x03) | ((back << 2) & 0x0c));
+#else
+	printf("color: %d %d\n", fore & 3, back & 3 );
+#endif
+}
+
 /* 行エディタ */
 void editLine()
 {
@@ -2243,7 +2355,10 @@ NEARPROC statements[KEYWORDS_STATEMENT_TO-KEYWORDS_STATEMENT_FROM+1] = {
 	st_call,
 	st_int,
 	st_tron,
-	st_troff
+	st_troff,
+	st_colormode,
+	st_palette,
+	st_color
 };
 
 void interpreterMain()

BIN
wonbe.exe


BIN
wonbe.fx


File diff suppressed because it is too large
+ 28 - 3
wonbe.txt


Some files were not shown because too many files changed in this diff