1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-12-24 15:29:29 +00:00

Synchronize C PLASM compiler with PLASMA PLASM compiler

This commit is contained in:
David Schmenk 2014-11-19 22:24:05 -08:00
parent 766c856eed
commit f94755aaa4
3 changed files with 270 additions and 235 deletions

2
src/FIRE.PLA#040000 Executable file
View File

@ -0,0 +1,2 @@
CONST FALSE = 0 CONST TRUE = NOT FALSE CONST SHOWLORES = $C056 CONST KEYBOARD = $C000 CONST KEYSTROBE = $C010 CONST EMPTY = 0 CONST TREE = 4 CONST FIRE = 13 CONST FORESTSIZE = 42*42 BYTE HELLOMSG[] = "PRESS ANY KEY TO BEGIN..." BYTE EXITMSG[] = "PRESS ANY KEY TO EXIT." BYTE GOODBYE[] = "THAT'S ALL FOLKS!" BYTE TREES1[FORESTSIZE] BYTE TREES2[FORESTSIZE] WORD RNDNUM DEF TEXTMODE CALL($FB39, 0, 0, 0, 0) END DEF HOME CALL($FC58, 0, 0, 0, 0) END DEF GOTOXY(X, Y) ^($24) = X CALL($FB5B, Y, 0, 0, 0) END DEF GRMODE CALL($FB40, 0, 0, 0, 0) DROP ^SHOWLORES END DEF RANDOMIZE(SEED) RNDNUM = (SEED >> 8) + (SEED << 8) + SEED END DEF RND RNDNUM = (RNDNUM << 8) + RNDNUM + 12345 RETURN RNDNUM & $7FFF END DEF BYFIRE(TREEPTR) IF ^(TREEPTR - 43) == FIRE RETURN TRUE ELSIF ^(TREEPTR - 42) == FIRE RETURN TRUE ELSIF ^(TREEPTR - 41) == FIRE RETURN TRUE ELSIF ^(TREEPTR - 1) == FIRE RETURN TRUE ELSIF ^(TREEPTR + 1) == FIRE RETURN TRUE ELSIF ^(TREEPTR + 41) == FIRE RETURN TRUE ELSIF ^(TREEPTR + 42) == FIRE RETURN TRUE ELSIF ^(TREEPTR + 43) == FIRE RETURN TRUE FIN RETURN FALSE END DEF FORESTFIRE WORD NEWTREES, OLDTREES, NEWTREE, OLDTREE, YROW BYTE X, Y MEMSET(@TREES1, FORESTSIZE, EMPT) MEMSET(@TREES2, FORESTSIZE, EMPTY) OLDTREES = @TREES1 NEWTREES = @TREES2 FOR Y = 1 TO 40 YROW = Y * 42 FOR X = 1 TO 40 IF RND < 8000 ^(OLDTREES + X + YROW) = TREE FIN NEXT NEXT WHILE ^$C000 < 128 FOR Y = 1 TO 40 YROW = Y * 42 FOR X = 1 TO 40 OLDTREE = OLDTREES + X + YROW NEWTREE = NEWTREES + X + YROW WHEN ^OLDTREE IS EMPTY IF RND < 5000 ^NEWTREE = TREE ELSE ^NEWTREE = EMPTY FIN BREAK IS TREE IF RND < 5 OR BYFIRE(OLDTREE) ^NEWTREE = FIRE ELSE ^NEWTREE = TREE FIN BREAK IS FIRE ^NEWTREE = EMPTY WEND CALL($F864, ^NEWTREE, 0, 0, 0) CALL($F800, Y - 1, 0, X - 1, 0) NEXT NEXT YROW = NEWTREES NEWTREES = OLDTREES OLDTREES = YROW LOOP ^$C010 END PRSTR(@HELLOMSG) WHILE ^$C000 < 128 RNDNUM = RNDNUM + 1 LOOP RANDOMIZE(RNDNUM) ^$C010 GRMODE HOME GOTOXY(10,22) PRSTR(@EXITMSG) FORESTFIRE TEXTMODE HOME PRSTR(@GOODBYE) DONE

View File

@ -355,8 +355,8 @@ int parse_value(int rvalue)
}
else
(type & BPTR_TYPE) ? emit_lb() : emit_lw();
}
emit_value = 1;
}
type &= ~(VAR_TYPE | ADDR_TYPE);
type |= WORD_TYPE;
scantoken = scantoken == PTRB_TOKEN ? DOT_TOKEN : COLON_TOKEN;
@ -387,6 +387,7 @@ int parse_value(int rvalue)
else // FUNC_TYPE
{
emit_globaladdr(value, elem_offset, type);
elem_offset = 0;
emit_value = 1;
}
}
@ -416,8 +417,9 @@ int parse_value(int rvalue)
}
else if (type & CONST_TYPE)
{
emit_const(value);
emit_const(value + elem_offset);
}
elem_offset = 0;
emit_value = 1;
}
while (parse_expr())
@ -442,7 +444,7 @@ int parse_value(int rvalue)
parse_error("Invalid member offset");
return (0);
}
type = elem_type; //(type & ~(ADDR_TYPE | CONST_TYPE)) | elem_type;
type = elem_type;
break;
case OPEN_PAREN_TOKEN:
/*
@ -867,10 +869,16 @@ int parse_stmnt(void)
int i;
for (i = 0; i < stack_loop; i++)
emit_drop();
if (!parse_expr())
emit_const(0);
emit_leave();
}
else
{
if (!parse_expr())
emit_const(0);
emit_ret();
}
break;
case EOL_TOKEN:
case COMMENT_TOKEN:

File diff suppressed because it is too large Load Diff