r2230 - in trunk/user/games

dslinux_gpf at dslinux.in-berlin.de dslinux_gpf at dslinux.in-berlin.de
Mon Apr 7 19:17:31 CEST 2008


Author: gpf
Date: 2008-04-07 19:17:30 +0200 (Mon, 07 Apr 2008)
New Revision: 2230

Log:
adding Noiz2sa, still need to either be rewritten to not use exceptions and rtti or those need to be enabled in uClibc++

Modified: trunk/user/games/Makefile
===================================================================
--- trunk/user/games/Makefile	2008-04-07 16:31:00 UTC (rev 2229)
+++ trunk/user/games/Makefile	2008-04-07 17:17:30 UTC (rev 2230)
@@ -16,6 +16,7 @@
 dir_$(CONFIG_USER_GAMES_RUBIK)          += rubik
 dir_$(CONFIG_USER_GAMES_SUDOKU)			+= sudoku
 dir_$(CONFIG_USER_GAMES_XRICK)             += xrick
+dir_$(CONFIG_USER_GAMES_NOIZ2SA)             += noiz2sa
 #dir_$(CONFIG_USER_GAMES_XMAME)		    += xmame
 
 all:

Copied: trunk/user/games/noiz2sa (from rev 2211, tags/noiz2sa/noiz2sa-0.51a)

Added: trunk/user/games/noiz2sa/Makefile

Modified: trunk/user/games/noiz2sa/noiz2sa_share/images/title_2.bmp
===================================================================
(Binary files differ)

Modified: trunk/user/games/noiz2sa/noiz2sa_share/images/title_a.bmp
===================================================================
(Binary files differ)

Modified: trunk/user/games/noiz2sa/noiz2sa_share/images/title_i.bmp
===================================================================
(Binary files differ)

Modified: trunk/user/games/noiz2sa/noiz2sa_share/images/title_n.bmp
===================================================================
(Binary files differ)

Modified: trunk/user/games/noiz2sa/noiz2sa_share/images/title_o.bmp
===================================================================
(Binary files differ)

Modified: trunk/user/games/noiz2sa/noiz2sa_share/images/title_s.bmp
===================================================================
(Binary files differ)

Modified: trunk/user/games/noiz2sa/noiz2sa_share/images/title_z.bmp
===================================================================
(Binary files differ)

Modified: trunk/user/games/noiz2sa/src/Makefile
===================================================================
--- tags/noiz2sa/noiz2sa-0.51a/src/Makefile	2008-04-05 00:17:39 UTC (rev 2211)
+++ trunk/user/games/noiz2sa/src/Makefile	2008-04-07 17:17:30 UTC (rev 2230)
@@ -1,32 +1,31 @@
-# Noiz2sa makefile(MinGW 2.0.0)
-# $Id: Makefile,v 1.4 2003/08/10 09:00:05 kenta Exp $
-
-NAME   = noiz2sa
-O      = o
-RM     = rm -f
-CC     = gcc
-CXX    = g++
-
-PROG        = $(NAME).exe
-
-DEFAULT_CFLAGS = `sdl-config --cflags`
-LDFLAGS        = `sdl-config --libs` -L. -lmingw32 -lmingwex -lSDL_mixer -lbulletml -mwindows -lstdc++
-
-MORE_CFLAGS = -O3
-
-CFLAGS  = $(DEFAULT_CFLAGS) $(MORE_CFLAGS)
-CPPFLAGS  = $(DEFAULT_CFLAGS) $(MORE_CFLAGS) -I./bulletml/
-
-OBJS =	$(NAME).$(O) ship.$(O) shot.$(O) frag.$(O) bonus.$(O) \
-	foe.$(O) foecommand.$(O) barragemanager.$(O) attractmanager.$(O) \
-	background.$(O) letterrender.$(O) \
-	screen.$(O) clrtbl.$(O) vector.$(O) degutil.$(O) rand.$(O) soundmanager.$(O) \
-	$(NAME)_res.$(O)
-
-$(PROG): $(OBJS) 
-	$(CC) $(CFLAGS) -o $(PROG) $(OBJS) $(LDFLAGS)
-
-$(NAME)_res.o: $(NAME).rc
-	windres -i $(NAME).rc -o $(NAME)_res.o
-clean:
-	$(RM) $(PROG) *.$(O)
+# Noiz2sa makefile(MinGW 2.0.0)
+# $Id: Makefile,v 1.4 2003/08/10 09:00:05 kenta Exp $
+
+NAME   = noiz2sa
+O      = o
+RM     = rm -f
+#CC     = gcc
+#CXX    = g++
+
+PROG        = $(NAME)
+
+DEFAULT_CFLAGS = -DSCREEN_DIVISOR=2 -I$(ROOTDIR)/include
+LDLIBS       += -L$(ROOTDIR)/lib -Lbulletml -lSDL_mixer -lvorbisidec -lbulletml -lSDL -lpthread -lm $(CXXLIBS)
+
+MORE_CFLAGS = 
+#CXXFLAGS = -O2 -g -fomit-frame-pointer -fno-common -fno-builtin -Wall -mswp-byte-writes -DCONFIG_NDS_ROM8BIT -mcpu=arm946e-s -mfpu=fpe3 -DEMBED -D__PIC__ -fpic -msingle-pic-base -Dlinux -D__linux__ -Dunix -D__uClinux__ -I /home/gpf/dslinux/lib/uClibc++/include -fno-builtin -nostdinc++ -DGCC_HASCLASSVISIBILITY -fexceptions -Wno-deprecated
+
+CFLAGS  += $(DEFAULT_CFLAGS) $(MORE_CFLAGS)
+CPPFLAGS  +=  $(DEFAULT_CFLAGS) $(MORE_CFLAGS) -I./bulletml/
+
+OBJS =	$(NAME).$(O) ship.$(O) shot.$(O) frag.$(O) bonus.$(O) \
+	foe.$(O) foecommand.$(O) barragemanager.$(O) attractmanager.$(O) \
+	background.$(O) letterrender.$(O) \
+	screen.$(O) clrtbl.$(O) vector.$(O) degutil.$(O) rand.$(O) soundmanager.$(O)
+
+$(PROG): $(OBJS) 
+	$(CXX) $(CXXFLAGS) -o $@ $(CRTBEGIN) $(LDFLAGS) $(OBJS) $(CXXLIBS) $(LDLIBS) $(CRTEND) 
+
+clean:
+	$(RM) $(PROG) $(PROG).gdb *.$(O) 
+

Modified: trunk/user/games/noiz2sa/src/attractmanager.c
===================================================================
--- tags/noiz2sa/noiz2sa-0.51a/src/attractmanager.c	2008-04-05 00:17:39 UTC (rev 2211)
+++ trunk/user/games/noiz2sa/src/attractmanager.c	2008-04-07 17:17:30 UTC (rev 2230)
@@ -1,475 +1,472 @@
-/*
- * $Id: attractmanager.c,v 1.4 2003/02/09 07:34:15 kenta Exp $
- *
- * Copyright 2002 Kenta Cho. All rights reserved.
- */
-
-/**
- * Attraction(score/title/gameover) manager.
- *
- * @version $Revision: 1.4 $
- */
-#include "SDL.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "noiz2sa.h"
-#include "screen.h"
-#include "letterrender.h"
-#include "attractmanager.h"
-#include "bonus.h"
-#include "brgmng_mtd.h"
-#include "soundmanager.h"
-#include "degutil.h"
-
-int score;
-static int nextExtend, neAdd;
-static int dsc;
-int left, stage;
-static int ssSc;
-static int hsScene, hsScSc, hsOfs;
-
-static HiScore hiScore;
-
-#define PREF_FILE "/.noiz2sa.prf"
-#define DEFAULT_HISCORE 100000
-#define DEFAULT_SCENE_HISCORE 10000
-
-static void initHiScore() {
-  int i, j;
-  for ( i=0 ; i<STAGE_NUM ; i++ ) {
-    hiScore.stageScore[i] = DEFAULT_HISCORE;
-    for ( j=0 ; j<SCENE_NUM ; j++ ) {
-      hiScore.sceneScore[i][j] = DEFAULT_SCENE_HISCORE;
-    }
-  }
-  for ( i=0 ; i<ENDLESS_STAGE_NUM ; i++ ) {
-    hiScore.stageScore[i+STAGE_NUM] = DEFAULT_HISCORE;
-  }
-  hiScore.stage = 0;
-}
-
-// Load preference.
-void loadPreference() {
-  FILE *fp;
-  int i, j;
-  int version;
-  char *tmpname;
-  char name[128];
-
-  tmpname = getenv("HOME");
-  strcpy(name, tmpname);
-  strcat(name, PREF_FILE);
-
-  if ( NULL == (fp = fopen(name,"rb")) ) {
-    initHiScore();
-    return;
-  }
-  version = getw(fp);
-  if ( version != VERSION_NUM ) {
-    initHiScore();
-    return;
-  }
-  for ( i=0 ; i<STAGE_NUM ; i++ ) {
-    hiScore.stageScore[i] = getw(fp);
-    for ( j=0 ; j<SCENE_NUM ; j++ ) {
-      hiScore.sceneScore[i][j] = getw(fp);
-    }
-  }
-  for ( i=0 ; i<ENDLESS_STAGE_NUM ; i++ ) {
-    hiScore.stageScore[i+STAGE_NUM] = getw(fp);
-  }
-  hiScore.stage = getw(fp);
-  fclose(fp);
-}
-
-// Save preference.
-void savePreference() {
-  FILE *fp;
-  int i, j;
-  char *tmpname;
-  char name[128];
-
-  tmpname = getenv("HOME");
-  strcpy(name, tmpname);
-  strcat(name, PREF_FILE);
-
-  if ( NULL == (fp = fopen(name,"wb")) ) return;
-  putw(VERSION_NUM, fp);
-  for ( i=0 ; i<STAGE_NUM ; i++ ) {
-    putw(hiScore.stageScore[i], fp);
-    for ( j=0 ; j<SCENE_NUM ; j++ ) {
-      putw(hiScore.sceneScore[i][j], fp);
-    }
-  }
-  for ( i=0 ; i<ENDLESS_STAGE_NUM ; i++ ) {
-    putw(hiScore.stageScore[i+STAGE_NUM], fp);
-  }
-  putw(hiScore.stage, fp);
-  fclose(fp);
-}
-
-void initGameState(int stg) {
-  score = 0; ssSc = 0;
-  nextExtend = 200000;
-  neAdd = 300000;
-  dsc = -1;
-  left = 2;
-  hiScore.stage = stage = stg;
-  hsScene = -1;
-  drawRPanel();
-}
-
-void addScore(int s) {
-  score += s;
-  if ( score >= nextExtend ) {
-    nextExtend += neAdd;
-    neAdd = 500000;
-    if ( extendShip() ) {
-      playChunk(6);
-    }
-  }
-}
-
-int extendShip() {
-  if ( left > 8 ) return 0;
-  left++;
-  drawRPanel();
-  return 1;
-}
-
-int decrementShip() {
-  left--;
-  drawRPanel();
-  if ( left < 0 ) return 1;
-  return 0;
-}
-
-void addLeftBonus() {
-  nextExtend = 999999999;
-  addScore(left*100000);
-}
-
-void setClearScore() {
-  int rss = hiScore.sceneScore[stage][scene];
-  int ss = score - ssSc;
-  hsScene = scene;
-  hsOfs = ss - rss;
-  hsScSc = ss;
-  if ( ss > rss ) {
-    hiScore.sceneScore[stage][scene] = ss;
-  }
-  drawRPanel();
-  ssSc = score;
-}
-
-void setHiScore() {
-  if ( score > hiScore.stageScore[stage] ) {
-    hiScore.stageScore[stage] = score;
-  }
-}
-
-void showScore() {
-  dsc = -1;
-}
-
-void drawScore() {
-  if ( dsc == score ) return;
-  dsc = score;
-  clearLPanel();
-  drawNum(score, 118, 24, 28, 16*1-12, 16*1-3);
-  drawNum(bonusScore, 24, 14, 16, 16*1-12, 16*1-3);
-}
-
-#define SCENE_STAT_X 77
-#define SCENE_STAT_SIZE 9
-
-void drawRPanel() {
-  int y;
-  char *str = "LEFT";
-  clearRPanel();
-  if ( left >= 0 ) {
-    drawString(str, 34, 272, 24, 3, 16*1-12, 16*1-3, rpbuf);
-    drawLetter(left, 34, 450, 24, 3, 16*2-10, 16*2-1, rpbuf);
-  }
-  y = 24;
-  if ( !endless ) {
-    y = drawNumRight(stage+1, 124, y, 24, 16*1-12, 16*1-3);
-    drawLetter(38, 124, y, 24, 3,  16*1-12, 16*1-3, rpbuf);
-    y += 24*1.7f;
-    if ( scene >= 10 ) {
-      drawLetter('E'-'A'+10, 124, y, 24, 3, 16*1-12, 16*1-3, rpbuf);
-      return;
-    }
-  }
-  drawNumRight(scene+1, 124, y, 24, 16*1-12, 16*1-3);
-  if ( hsScene >= 0 ) {
-    y = SCENE_STAT_SIZE;
-    y = drawNumRight(stage+1, SCENE_STAT_X, y, SCENE_STAT_SIZE, 16*1-12, 16*1-3);
-    drawLetter(38, SCENE_STAT_X, y, SCENE_STAT_SIZE, 3,  16*1-12, 16*1-3, rpbuf);
-    y += SCENE_STAT_SIZE*1.7f;
-    y = drawNumRight(hsScene+1, SCENE_STAT_X, y, SCENE_STAT_SIZE, 16*1-12, 16*1-3);
-    y += SCENE_STAT_SIZE*1.7f*2;
-    y = drawNumRight(hsScSc, SCENE_STAT_X, y, SCENE_STAT_SIZE, 16*1-12, 16*1-3);
-    y += SCENE_STAT_SIZE*1.7f;
-    if ( hsOfs >= 0 ) {
-      drawLetter(39, SCENE_STAT_X, y, SCENE_STAT_SIZE, 3,  16*2-12, 16*2-3, rpbuf);
-      y += SCENE_STAT_SIZE*1.7f;
-      drawNumRight(hsOfs, SCENE_STAT_X, y, SCENE_STAT_SIZE, 16*2-12, 16*2-3);
-    } else {
-      drawLetter(38, SCENE_STAT_X, y, SCENE_STAT_SIZE, 3,  16*4-12, 16*4-3, rpbuf);
-      y += SCENE_STAT_SIZE*1.7f;
-      drawNumRight(-hsOfs, SCENE_STAT_X, y, SCENE_STAT_SIZE, 16*4-12, 16*4-3);
-    }
-  }
-}
-
-#define STG_BOX_SIZE 40
-#define STG_BOX_NUM 15
-
-static int stageX[STG_BOX_NUM], stageY[STG_BOX_NUM];
-
-void initAttractManager() {
-  int i, j, x, y, s;
-  y = LAYER_HEIGHT/3+STG_BOX_SIZE/2;
-  s = 0;
-  for ( i=0 ; i<6 ; i++, y += STG_BOX_SIZE*1.2f ) {
-    x = STG_BOX_SIZE/2+STG_BOX_SIZE/2;
-    switch ( i ) {
-    case 0:
-    case 1:
-    case 2:
-    case 3:
-      for ( j=0 ; j<=i ; j++, s++, x+=STG_BOX_SIZE*1.2f ) {
-	stageX[s] = x; stageY[s] = y;
-      }
-      break;
-    case 4:
-      for ( j=0 ; j<=2 ; j++, s++, x+=STG_BOX_SIZE*1.2f ) {
-	stageX[s] = x; stageY[s] = y;
-      }
-      x += STG_BOX_SIZE*1.2f;
-      stageX[s] = x; stageY[s] = y;
-      s++;
-      break;
-    case 5:
-      y += STG_BOX_SIZE/3;
-      stageX[s] = x; stageY[s] = y;
-      break;
-    }
-  }
-}
-
-static int titleCnt;
-static int slcStg;
-static int mnp;
-
-int initTitleAtr() {
-  stopMusic();
-  titleCnt = 0;
-  slcStg = hiScore.stage;
-  mnp = 0;
-  return slcStg;
-}
-
-void drawTitle() {
-  int i;
-  for ( i=0 ; i<7 ; i++ ) {
-    drawSprite(i, 162+i*46, 16);
-  }
-}
-
-static int stgMv[STAGE_NUM+ENDLESS_STAGE_NUM+1][4] = {
-  {0, 0, 1, 0},
-  {-1, 1, 2, 0}, {0, 0, 2, -1},
-  {-2, 1, 3, 0}, {-2, 1, 3, -1}, {0, 0, 3, -1},
-  {-3, 1, 4, 0}, {-3, 1, 4, -1}, {-3, 1, 4, -1}, {0, 0, 3, -1},
-  {-4, 1, 4, 0}, {-4, 1, 3, -1}, {-4, 1, 2, -1},                {0, 0, 1, -1},
-  {-4, 0, 0, 0},
-};
-
-void moveTitleMenu() {
-  int pad = getPadState();
-  int btn = getButtonState();
-  int p = -1;
-  int sm;
-  if ( pad & PAD_DOWN ) {
-    p = 2;
-  } else if ( pad & PAD_UP ) {
-    p = 0;
-  } else if ( pad & PAD_RIGHT ) {
-    p = 1;
-  } else if ( pad & PAD_LEFT ) {
-    p = 3;
-  } else if ( btn == 0 ) {
-    mnp = 1;
-  }
-  if ( mnp && p >= 0 ) {
-    mnp = 0;
-    sm = stgMv[slcStg][p];
-    slcStg += sm;
-    if ( sm != 0 ) {
-      initTitleStage(slcStg);
-    }
-    titleCnt = 16;
-  }
-  if ( mnp && (btn & PAD_BUTTON1) ) {
-    if ( slcStg == STAGE_NUM+ENDLESS_STAGE_NUM ) {
-      quitLast();
-      return;
-    }
-    hiScore.stage = slcStg;
-    initGame(slcStg);
-  }
-  titleCnt++;
-}
-
-void drawTitleMenu() {
-  int i;
-  char *stgChr = "STAGE";
-  char *endlessChr = "ENDLESS";
-  char *hardChr = "HARD";
-  char *extChr = "EXTREME";
-  char *insChr = "INSANE";
-  char *quitChr = "QUIT";
-  for ( i=0 ; i<STG_BOX_NUM ; i++ ) {
-    if ( i == slcStg ) {
-      int sz = STG_BOX_SIZE+6+sctbl[(titleCnt*16)&(DIV-1)]/24;
-      drawBox(stageX[i], stageY[i], sz, sz, 16*2-14, 16*2-3, buf);
-      if ( i < STAGE_NUM ) {
-	drawStringBuf(stgChr, 180, 80, 12, 2, 16*1-14, 16*1-2, buf, 0);
-	drawNumCenter(i+1, 308, 80, 12, 16*1-14, 16*1-2);
-      } else {
-	switch ( i ) {
-	case 10:
-	  drawStringBuf(endlessChr, 188, 80, 12, 2, 16*1-14, 16*1-2, buf, 0);
-	  break;
-	case 11:
-	  drawStringBuf(endlessChr, 93, 80, 12, 2, 16*1-14, 16*1-2, buf, 0);
-	  drawStringBuf(hardChr, 248, 80, 12, 2, 16*1-14, 16*1-2, buf, 0);
-	  break;
-	case 12:
-	  drawStringBuf(endlessChr, 36, 80, 12, 2, 16*1-14, 16*1-2, buf, 0);
-	  drawStringBuf(extChr, 190, 80, 12, 2, 16*1-14, 16*1-2, buf, 0);
-	  break;
-	case 13:
-	  drawStringBuf(endlessChr, 56, 80, 12, 2, 16*1-14, 16*1-2, buf, 0);
-	  drawStringBuf(insChr, 210, 80, 12, 2, 16*1-14, 16*1-2, buf, 0);
-	  break;
-	case 14:
-	  drawStringBuf(quitChr, 230, 80, 12, 2, 16*1-14, 16*1-2, buf, 0);
-	  break;
-	}
-      }
-      if ( i < STAGE_NUM+ENDLESS_STAGE_NUM ) {
-	drawNumCenter(hiScore.stageScore[i], 308, 112, 12, 16*1-14, 16*1-2);
-      }
-    }
-    drawBox(stageX[i], stageY[i], STG_BOX_SIZE, STG_BOX_SIZE, 16*1-14, 16*1-3, buf);
-    if ( i < 9 ) {
-      drawNumCenter(i+1, stageX[i], stageY[i], 12, 16*1-16, 16*1-1);
-    } else {
-      switch ( i ) {
-      case 9:
-	drawNumCenter(10, stageX[i]+8, stageY[i], 12, 16*1-16, 16*1-1);
-	break;
-      case 10:
-	drawLetterBuf('E'-'A'+10, stageX[i], stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0);
-	break;
-      case 11:
-	drawLetterBuf('E'-'A'+10, stageX[i]-8, stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0);
-	drawLetterBuf('H'-'A'+10, stageX[i]+8, stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0);
-	break;
-      case 12:
-	drawLetterBuf('E'-'A'+10, stageX[i]-8, stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0);
-	drawLetterBuf('E'-'A'+10, stageX[i]+8, stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0);
-	break;
-      case 13:
-	drawLetterBuf('E'-'A'+10, stageX[i]-8, stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0);
-	drawLetterBuf('I'-'A'+10, stageX[i]+8, stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0);
-	break;
-      case 14:
-	drawLetterBuf('Q'-'A'+10, stageX[i], stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0);
-	break;
-      }
-    }
-  }
-}
-
-static int goCnt;
-
-void initGameoverAtr() {
-  goCnt = 0;
-  mnp = 0;
-  fadeMusic();
-}
-
-void moveGameover() {
-  int btn = getButtonState();
-  if ( goCnt > 900 || (goCnt > 128 && mnp && (btn & PAD_BUTTON1)) ) {
-    setHiScore();
-    initTitle();
-    return;
-  }
-  if ( btn == 0 ) {
-    mnp = 1;
-  }
-  goCnt++;
-}
-
-void drawGameover() {
-  char *goChr = "GAME OVER";
-  int y;
-  if ( goCnt < 128 ) {
-    y = LAYER_HEIGHT/3*goCnt/128;
-  } else {
-    y = LAYER_HEIGHT/3;
-  }
-  drawStringBuf(goChr, 24, y, 20, 2, 16*4-10, 16*1-1, buf, 0);
-}
-
-static int scCnt;
-
-void initStageClearAtr() {
-  scCnt = 0;
-  mnp = 0;
-  fadeMusic();
-}
-
-void moveStageClear() {
-  int btn = getButtonState();
-  if ( scCnt > 900 || (scCnt > 128 && mnp && (btn & PAD_BUTTON1)) ) {
-    setHiScore();
-    initTitle();
-    return;
-  }
-  if ( btn == 0 ) {
-    mnp = 1;
-  }
-  scCnt++;
-}
-
-void drawStageClear() {
-  char *scChr = "STAGE CLEAR";
-  int y;
-  if ( scCnt < 128 ) {
-    y = LAYER_HEIGHT - LAYER_HEIGHT/3*2*scCnt/128;
-  } else {
-    y = LAYER_HEIGHT/3;
-  }
-  drawStringBuf(scChr, 24, y, 16, 2, 16*3-10, 16*1-1, buf, 0);
-}
-
-static int psCnt = 0;
-
-void movePause() {
-  psCnt++;
-}
-
-void drawPause() {
-  char *psChr = "PAUSE";
-  if ( (psCnt&63) < 32 ) {
-    drawStringBuf(psChr, 92, LAYER_HEIGHT/3, 20, 2, 16*2-10, 16*1-1, buf, 0);
-  }
-}
+/*
+ * $Id: attractmanager.c,v 1.4 2003/02/09 07:34:15 kenta Exp $
+ *
+ * Copyright 2002 Kenta Cho. All rights reserved.
+ */
+
+/**
+ * Attraction(score/title/gameover) manager.
+ *
+ * @version $Revision: 1.4 $
+ */
+#include "SDL.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "noiz2sa.h"
+#include "screen.h"
+#include "letterrender.h"
+#include "attractmanager.h"
+#include "bonus.h"
+#include "brgmng_mtd.h"
+#include "soundmanager.h"
+#include "degutil.h"
+
+int score;
+static int nextExtend, neAdd;
+static int dsc;
+int left, stage;
+static int ssSc;
+static int hsScene, hsScSc, hsOfs;
+
+static HiScore hiScore;
+
+#define PREF_FILE "/.noiz2sa.prf"
+#define DEFAULT_HISCORE 100000
+#define DEFAULT_SCENE_HISCORE 10000
+
+static void initHiScore() {
+  int i, j;
+  for ( i=0 ; i<STAGE_NUM ; i++ ) {
+    hiScore.stageScore[i] = DEFAULT_HISCORE;
+    for ( j=0 ; j<SCENE_NUM ; j++ ) {
+      hiScore.sceneScore[i][j] = DEFAULT_SCENE_HISCORE;
+    }
+  }
+  for ( i=0 ; i<ENDLESS_STAGE_NUM ; i++ ) {
+    hiScore.stageScore[i+STAGE_NUM] = DEFAULT_HISCORE;
+  }
+  hiScore.stage = 0;
+}
+
+// Load preference.
+void loadPreference() {
+  FILE *fp;
+  int i, j;
+  int version;
+  char *tmpname;
+  char name[128];
+
+  tmpname = getenv("HOME");
+  strcpy(name, tmpname);
+  strcat(name, PREF_FILE);
+
+  if ( NULL == (fp = fopen(name,"rb")) ) {
+    initHiScore();
+    return;
+  }
+  version = getw(fp);
+  if ( version != VERSION_NUM ) {
+    initHiScore();
+    return;
+  }
+  for ( i=0 ; i<STAGE_NUM ; i++ ) {
+    hiScore.stageScore[i] = getw(fp);
+    for ( j=0 ; j<SCENE_NUM ; j++ ) {
+      hiScore.sceneScore[i][j] = getw(fp);
+    }
+  }
+  for ( i=0 ; i<ENDLESS_STAGE_NUM ; i++ ) {
+    hiScore.stageScore[i+STAGE_NUM] = getw(fp);
+  }
+  hiScore.stage = getw(fp);
+  fclose(fp);
+}
+
+// Save preference.
+void savePreference() {
+  FILE *fp;
+  int i, j;
+  char *tmpname;
+  char name[128];
+
+  tmpname = getenv("HOME");
+  strcpy(name, tmpname);
+  strcat(name, PREF_FILE);
+
+  if ( NULL == (fp = fopen(name,"wb")) ) return;
+  putw(VERSION_NUM, fp);
+  for ( i=0 ; i<STAGE_NUM ; i++ ) {
+    putw(hiScore.stageScore[i], fp);
+    for ( j=0 ; j<SCENE_NUM ; j++ ) {
+      putw(hiScore.sceneScore[i][j], fp);
+    }
+  }
+  for ( i=0 ; i<ENDLESS_STAGE_NUM ; i++ ) {
+    putw(hiScore.stageScore[i+STAGE_NUM], fp);
+  }
+  putw(hiScore.stage, fp);
+  fclose(fp);
+}
+
+void initGameState(int stg) {
+  score = 0; ssSc = 0;
+  nextExtend = 200000;
+  neAdd = 300000;
+  dsc = -1;
+  left = 2;
+  hiScore.stage = stage = stg;
+  hsScene = -1;
+  drawRPanel();
+}
+
+void addScore(int s) {
+  score += s;
+  if ( score >= nextExtend ) {
+    nextExtend += neAdd;
+    neAdd = 500000;
+    if ( extendShip() ) {
+      playChunk(6);
+    }
+  }
+}
+
+int extendShip() {
+  if ( left > 8 ) return 0;
+  left++;
+  drawRPanel();
+  return 1;
+}
+
+int decrementShip() {
+  left--;
+  drawRPanel();
+  if ( left < 0 ) return 1;
+  return 0;
+}
+
+void addLeftBonus() {
+  nextExtend = 999999999;
+  addScore(left*100000);
+}
+
+void setClearScore() {
+  int rss = hiScore.sceneScore[stage][scene];
+  int ss = score - ssSc;
+  hsScene = scene;
+  hsOfs = ss - rss;
+  hsScSc = ss;
+  if ( ss > rss ) {
+    hiScore.sceneScore[stage][scene] = ss;
+  }
+  drawRPanel();
+  ssSc = score;
+}
+
+void setHiScore() {
+  if ( score > hiScore.stageScore[stage] ) {
+    hiScore.stageScore[stage] = score;
+  }
+}
+
+void showScore() {
+  dsc = -1;
+}
+
+void drawScore() {
+  if ( dsc == score ) return;
+  dsc = score;
+  clearLPanel();
+  drawNum(score, 118 / SCREEN_DIVISOR, 24 / SCREEN_DIVISOR, 28, 16*1-12, 16*1-3);
+  drawNum(bonusScore, 24 / SCREEN_DIVISOR, 14 / SCREEN_DIVISOR, 16, 16*1-12, 16*1-3);
+}
+
+#define SCENE_STAT_X (77 / SCREEN_DIVISOR)
+#define SCENE_STAT_SIZE (9 / SCREEN_DIVISOR)
+
+void drawRPanel() {
+  int y;
+  char *str = "LEFT";
+  clearRPanel();
+  if ( left >= 0 ) {
+    drawString(str, 34 / SCREEN_DIVISOR, 272 / SCREEN_DIVISOR, 24, 3, 16*1-12, 16*1-3, rpbuf);
+    drawLetter(left, 34 / SCREEN_DIVISOR, 450 / SCREEN_DIVISOR, 24, 3, 16*2-10, 16*2-1, rpbuf);
+  }
+  y = 24 / SCREEN_DIVISOR;
+  if ( !endless ) {
+    y = drawNumRight(stage+1, 124 / SCREEN_DIVISOR, y, 24, 16*1-12, 16*1-3);
+    drawLetter(38, 124 / SCREEN_DIVISOR, y, 24, 3,  16*1-12, 16*1-3, rpbuf);
+    y += (24*1.7f) / (float)SCREEN_DIVISOR;
+    if ( scene >= 10 ) {
+      drawLetter('E'-'A'+10, 124 / SCREEN_DIVISOR, y, 24, 3, 16*1-12, 16*1-3, rpbuf);
+      return;
+    }
+  }
+  drawNumRight(scene+1, 124 / SCREEN_DIVISOR, y, 24, 16*1-12, 16*1-3);
+  if ( hsScene >= 0 ) {
+    y = SCENE_STAT_SIZE;
+    y = drawNumRight(stage+1, SCENE_STAT_X, y, SCENE_STAT_SIZE, 16*1-12, 16*1-3);
+    drawLetter(38, SCENE_STAT_X, y, SCENE_STAT_SIZE, 3,  16*1-12, 16*1-3, rpbuf);
+    y += SCENE_STAT_SIZE*1.7f;
+    y = drawNumRight(hsScene+1, SCENE_STAT_X, y, SCENE_STAT_SIZE, 16*1-12, 16*1-3);
+    y += SCENE_STAT_SIZE*1.7f*2;
+    y = drawNumRight(hsScSc, SCENE_STAT_X, y, SCENE_STAT_SIZE, 16*1-12, 16*1-3);
+    y += SCENE_STAT_SIZE*1.7f;
+    if ( hsOfs >= 0 ) {
+      drawLetter(39, SCENE_STAT_X, y, SCENE_STAT_SIZE, 3,  16*2-12, 16*2-3, rpbuf);
+      y += SCENE_STAT_SIZE*1.7f;
+      drawNumRight(hsOfs, SCENE_STAT_X, y, SCENE_STAT_SIZE, 16*2-12, 16*2-3);
+    } else {
+      drawLetter(38, SCENE_STAT_X, y, SCENE_STAT_SIZE, 3,  16*4-12, 16*4-3, rpbuf);
+      y += SCENE_STAT_SIZE*1.7f;
+      drawNumRight(-hsOfs, SCENE_STAT_X, y, SCENE_STAT_SIZE, 16*4-12, 16*4-3);
+    }
+  }
+}
+
+#define STG_BOX_SIZE (40 / SCREEN_DIVISOR)
+#define STG_BOX_NUM 15
+
+static int stageX[STG_BOX_NUM], stageY[STG_BOX_NUM];
+
+void initAttractManager() {
+  int i, j, x, y, s;
+  y = LAYER_HEIGHT/3+STG_BOX_SIZE/2;
+  s = 0;
+  for ( i=0 ; i<6 ; i++, y += STG_BOX_SIZE*1.2f ) {
+    x = STG_BOX_SIZE/2+STG_BOX_SIZE/2;
+    switch ( i ) {
+    case 0:
+    case 1:
+    case 2:
+    case 3:
+      for ( j=0 ; j<=i ; j++, s++, x+=STG_BOX_SIZE*1.2f ) {
+	stageX[s] = x; stageY[s] = y;
+      }
+      break;
+    case 4:
+      for ( j=0 ; j<=2 ; j++, s++, x+=STG_BOX_SIZE*1.2f ) {
+	stageX[s] = x; stageY[s] = y;
+      }
+      x += STG_BOX_SIZE*1.2f;
+      stageX[s] = x; stageY[s] = y;
+      s++;
+      break;
+    case 5:
+      y += STG_BOX_SIZE/3;
+      stageX[s] = x; stageY[s] = y;
+      break;
+    }
+  }
+}
+
+static int titleCnt;
+static int slcStg;
+static int mnp;
+
+int initTitleAtr() {
+  stopMusic();
+  titleCnt = 0;
+  slcStg = hiScore.stage;
+  mnp = 0;
+  return slcStg;
+}
+
+void drawTitle() {
+  int i;
+  for ( i=0 ; i<7 ; i++ ) {
+    drawSprite(i, (162+i*46) / SCREEN_DIVISOR, 16 / SCREEN_DIVISOR);
+  }
+}
+
+static int stgMv[STAGE_NUM+ENDLESS_STAGE_NUM+1][4] = {
+  {0, 0, 1, 0},
+  {-1, 1, 2, 0}, {0, 0, 2, -1},
+  {-2, 1, 3, 0}, {-2, 1, 3, -1}, {0, 0, 3, -1},
+  {-3, 1, 4, 0}, {-3, 1, 4, -1}, {-3, 1, 4, -1}, {0, 0, 3, -1},
+  {-4, 1, 4, 0}, {-4, 1, 3, -1}, {-4, 1, 2, -1},                {0, 0, 1, -1},
+  {-4, 0, 0, 0},
+};
+
+void moveTitleMenu() {
+  int pad = getPadState();
+  int btn = getButtonState();
+  int p = -1;
+  int sm;
+  if ( pad & PAD_DOWN ) {
+    p = 2;
+  } else if ( pad & PAD_UP ) {
+    p = 0;
+  } else if ( pad & PAD_RIGHT ) {
+    p = 1;
+  } else if ( pad & PAD_LEFT ) {
+    p = 3;
+  } else if ( btn == 0 ) {
+    mnp = 1;
+  }
+  if ( mnp && p >= 0 ) {
+    mnp = 0;
+    sm = stgMv[slcStg][p];
+    slcStg += sm;
+    if ( sm != 0 ) {
+      initTitleStage(slcStg);
+    }
+    titleCnt = 16;
+  }
+  if ( mnp && (btn & PAD_BUTTON1) ) {
+    if ( slcStg == STAGE_NUM+ENDLESS_STAGE_NUM ) {
+      quitLast();
+      return;
+    }
+    hiScore.stage = slcStg;
+    initGame(slcStg);
+  }
+  titleCnt++;
+}
+
+void drawTitleMenu() {
+  int i;
+  char *stgChr = "STAGE";
+  char *endlessChr = "ENDLESS";
+  char *hardChr = "HARD";
+  char *extChr = "EXTREME";
+  char *insChr = "INSANE";
+  char *quitChr = "QUIT";
+  for ( i=0 ; i<STG_BOX_NUM ; i++ ) {
+    if ( i == slcStg ) {
+      int sz = STG_BOX_SIZE+(6+sctbl[(titleCnt*16)&(DIV-1)]/24)/SCREEN_DIVISOR;
+      drawBox(stageX[i], stageY[i], sz, sz, 16*2-14, 16*2-3, buf);
+      if ( i < STAGE_NUM ) {
+	drawStringBuf(stgChr, 180 / SCREEN_DIVISOR, 80 / SCREEN_DIVISOR, 12, 2, 16*1-14, 16*1-2, buf, 0);
+	drawNumCenter(i+1, 308 / SCREEN_DIVISOR, 80 / SCREEN_DIVISOR, 12, 16*1-14, 16*1-2);
+      } else {
+	switch ( i ) {
+	case 10:
+	  drawStringBuf(endlessChr, 188 / SCREEN_DIVISOR, 80 / SCREEN_DIVISOR, 12, 2, 16*1-14, 16*1-2, buf, 0);
+	  break;
+	case 11:
+	  drawStringBuf(endlessChr, 93 / SCREEN_DIVISOR, 80 / SCREEN_DIVISOR, 12, 2, 16*1-14, 16*1-2, buf, 0);
+	  drawStringBuf(hardChr, 248 / SCREEN_DIVISOR, 80 / SCREEN_DIVISOR, 12, 2, 16*1-14, 16*1-2, buf, 0);
+	  break;
+	case 12:
+	  drawStringBuf(endlessChr, 36 / SCREEN_DIVISOR, 80 / SCREEN_DIVISOR, 12, 2, 16*1-14, 16*1-2, buf, 0);
+	  drawStringBuf(extChr, 190 / SCREEN_DIVISOR, 80 / SCREEN_DIVISOR, 12, 2, 16*1-14, 16*1-2, buf, 0);
+	  break;
+	case 13:
+	  drawStringBuf(endlessChr, 56 / SCREEN_DIVISOR, 80 / SCREEN_DIVISOR, 12, 2, 16*1-14, 16*1-2, buf, 0);
+	  drawStringBuf(insChr, 210 / SCREEN_DIVISOR, 80 / SCREEN_DIVISOR, 12, 2, 16*1-14, 16*1-2, buf, 0);
+	  break;
+	case 14:
+  	  drawStringBuf(quitChr, 230 / SCREEN_DIVISOR, 80 / SCREEN_DIVISOR, 12, 2, 16*1-14, 16*1-2, buf, 0);
+	  break;
+	}
+      }
+      if ( i < STAGE_NUM+ENDLESS_STAGE_NUM ) {
+	drawNumCenter(hiScore.stageScore[i], 308 / SCREEN_DIVISOR, 120 / SCREEN_DIVISOR, 12, 16*1-14, 16*1-2);
+      }
+    }
+    drawBox(stageX[i], stageY[i], STG_BOX_SIZE, STG_BOX_SIZE, 16*1-14, 16*1-3, buf);
+    if ( i < 9 ) {
+      drawNumCenter(i+1, stageX[i], stageY[i], 12, 16*1-16, 16*1-1);
+    } else {
+      switch ( i ) {
+      case 9:
+	drawNumCenter(10, stageX[i]+(8 / SCREEN_DIVISOR), stageY[i], 12, 16*1-16, 16*1-1);
+	break;
+      case 10:
+	drawLetterBuf('E'-'A'+10, stageX[i], stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0);
+	break;
+      case 11:
+	drawLetterBuf('E'-'A'+10, stageX[i]-(8 / SCREEN_DIVISOR), stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0);
+	drawLetterBuf('H'-'A'+10, stageX[i]+(8 / SCREEN_DIVISOR), stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0);
+	break;
+      case 12:
+	drawLetterBuf('E'-'A'+10, stageX[i]-(8 / SCREEN_DIVISOR), stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0);
+	drawLetterBuf('E'-'A'+10, stageX[i]+(8 / SCREEN_DIVISOR), stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0);
+	break;
+      case 13:
+	drawLetterBuf('E'-'A'+10, stageX[i]-(8 / SCREEN_DIVISOR), stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0);
+	drawLetterBuf('I'-'A'+10, stageX[i]+(8 / SCREEN_DIVISOR), stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0);
+	break;
+      }
+    }
+  }
+}
+
+static int goCnt;
+
+void initGameoverAtr() {
+  goCnt = 0;
+  mnp = 0;
+  fadeMusic();
+}
+
+void moveGameover() {
+  int btn = getButtonState();
+  if ( goCnt > 900 || (goCnt > 128 && mnp && (btn & PAD_BUTTON1)) ) {
+    setHiScore();
+    initTitle();
+    return;
+  }
+  if ( btn == 0 ) {
+    mnp = 1;
+  }
+  goCnt++;
+}
+
+void drawGameover() {
+  char *goChr = "GAME OVER";
+  int y;
+  if ( goCnt < 128 ) {
+    y = LAYER_HEIGHT/3*goCnt/128;
+  } else {
+    y = LAYER_HEIGHT/3;
+  }
+  drawStringBuf(goChr, 24 / SCREEN_DIVISOR, y, 20, 2, 16*4-10, 16*1-1, buf, 0);
+}
+
+static int scCnt;
+
+void initStageClearAtr() {
+  scCnt = 0;
+  mnp = 0;
+  fadeMusic();
+}
+
+void moveStageClear() {
+  int btn = getButtonState();
+  if ( scCnt > 900 || (scCnt > 128 && mnp && (btn & PAD_BUTTON1)) ) {
+    setHiScore();
+    initTitle();
+    return;
+  }
+  if ( btn == 0 ) {
+    mnp = 1;
+  }
+  scCnt++;
+}
+
+void drawStageClear() {
+  char *scChr = "STAGE CLEAR";
+  int y;
+  if ( scCnt < 128 ) {
+    y = LAYER_HEIGHT - LAYER_HEIGHT/3*2*scCnt/128;
+  } else {
+    y = LAYER_HEIGHT/3;
+  }
+  drawStringBuf(scChr, 24 / SCREEN_DIVISOR, y, 16, 2, 16*3-10, 16*1-1, buf, 0);
+}
+
+static int psCnt = 0;
+
+void movePause() {
+  psCnt++;
+}
+
+void drawPause() {
+  char *psChr = "PAUSE";
+  if ( (psCnt&63) < 32 ) {
+    drawStringBuf(psChr, 92 / SCREEN_DIVISOR, LAYER_HEIGHT/3, 20, 2, 16*2-10, 16*1-1, buf, 0);
+  }
+}

Modified: trunk/user/games/noiz2sa/src/background.c
===================================================================
--- tags/noiz2sa/noiz2sa-0.51a/src/background.c	2008-04-05 00:17:39 UTC (rev 2211)
+++ trunk/user/games/noiz2sa/src/background.c	2008-04-07 17:17:30 UTC (rev 2230)
@@ -1,190 +1,191 @@
-/*
- * $Id: background.c,v 1.2 2002/12/31 09:34:34 kenta Exp $
- *
- * Copyright 2002 Kenta Cho. All rights reserved.
- */
-
-/**
- * Handle background graphics.
- *
- * @version $Revision: 1.2 $
- */
-#include "SDL.h"
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "noiz2sa.h"
-#include "screen.h"
-#include "vector.h"
-#include "background.h"
-
-static Board board[BOARD_MAX];
-
-void initBackground() {
-  int i;
-  for ( i=0 ; i<BOARD_MAX ; i++ ) {
-    board[i].width = NOT_EXIST;
-  }
-}
-
-static int bdIdx;
-static int boardMx, boardMy;
-static int boardRepx, boardRepy;
-static int boardRepXn, boardRepYn;
-
-static void addBoard(int x, int y, int z, int width, int height) {
-  if ( bdIdx >= BOARD_MAX ) return;
-  board[bdIdx].x = x;
-  board[bdIdx].y = y;
-  board[bdIdx].z = z;
-  board[bdIdx].width = width/z;
-  board[bdIdx].height = height/z;
-  bdIdx++;
-}
-
-void setStageBackground(int bn) {
-  int i, j, k;
-  bdIdx = 0;
-
-  switch ( bn ) {
-  case 0:
-  case 6:
-    addBoard(9000, 9000, 500, 25000, 25000);
-    for ( i=0 ; i<4 ; i++ ) {
-      for ( j=0 ; j<4 ; j++ ) {
-	if ( i > 1 || j > 1 ) {
-	  addBoard(i*16384, j*16384, 500, 10000+(i*12345)%3000, 10000+(j*54321)%3000);
-	}
-      }
-    }
-    for ( j=0 ; j<8 ; j++ ) {
-      for ( i=0 ; i<4 ; i++ ) {
-	addBoard(0, i*16384, 500-j*50, 20000-j*1000, 12000-j*500);
-      }
-    }
-    for ( i=0 ; i<8 ; i++ ) {
-      addBoard(0, i*8192, 100, 20000, 6400);
-    }
-    if ( bn == 0 ) {
-      boardMx = 40; boardMy = 300;
-    } else {
-      boardMx = -40; boardMy = 480;
-    }
-    boardRepx = boardRepy = 65536;
-    boardRepXn = boardRepYn = 4;
-    break;
-  case 1:
-    addBoard(12000, 12000, 400, 48000, 48000);
-    addBoard(12000, 44000, 400, 48000, 8000);
-    addBoard(44000, 12000, 400, 8000, 48000);
-    for ( i=0 ; i<16 ; i++ ) {
-      addBoard(0, 0, 400-i*10, 16000, 16000);
-      if ( i < 6 ) {
-	addBoard(9600, 16000, 400-i*10, 40000, 16000);
-      }
-    }
-    boardMx = 128; boardMy = 512;
-    boardRepx = boardRepy = 65536;
-    boardRepXn = boardRepYn = 4;
-    break;
-  case 2:
-    for ( i=0 ; i<16 ; i++ ) {
-      addBoard(7000+i*3000, 0, 1600-i*100, 24000, 5000);
-      addBoard(7000+i*3000, 50000, 1600-i*100, 4000, 10000);
-      addBoard(-7000-i*3000, 0, 1600-i*100, 24000, 5000);
-      addBoard(-7000-i*3000, 50000, 1600-i*100, 4000, 10000);
-    }
-    boardMx = 0; boardMy = 1200;
-    boardRepx = 0;
-    boardRepy = 65536;
-    boardRepXn = 1;
-    boardRepYn = 10;
-    break;
-  case 3:
-    addBoard(9000, 9000, 500, 30000, 30000);
-    for ( i=0 ; i<4 ; i++ ) {
-      for ( j=0 ; j<4 ; j++ ) {
-	if ( i > 1 || j > 1 ) {
-	  addBoard(i*16384, j*16384, 500, 12000+(i*12345)%3000, 12000+(j*54321)%3000);
-	}
-      }
-    }
-    for ( i=0 ; i<4 ; i++ ) {
-      for ( j=0 ; j<4 ; j++ ) {
-	if ( (i > 1 || j > 1) && (i+j)%3 == 0 ) {
-	  addBoard(i*16384, j*16384, 480, 9000+(i*12345)%3000, 9000+(j*54321)%3000);
-	}
-      }
-    }
-    addBoard(9000, 9000, 480, 20000, 20000);
-    addBoard(9000, 9000, 450, 20000, 20000);
-    addBoard(32768, 40000, 420, 65536, 5000);
-    addBoard(30000, 32768, 370, 4800, 65536);
-    addBoard(32768, 0, 8, 65536, 10000);
-    boardMx = 10; boardMy = 100;
-    boardRepx = boardRepy = 65536;
-    boardRepXn = boardRepYn = 4;
-    break;
-  case 4:
-    addBoard(32000, 12000, 160, 48000, 48000);
-    addBoard(32000, 44000, 160, 48000, 8000);
-    addBoard(64000, 12000, 160, 8000, 48000);
-    for ( i=0 ; i<16 ; i++ ) {
-      addBoard(20000, 0, 160-i*10, 16000, 16000);
-      if ( i < 6 ) {
-	addBoard(29600, 16000, 160-i*10, 40000, 16000);
-      }
-    }
-    boardMx = 0; boardMy = 128;
-    boardRepx = boardRepy = 65536;
-    boardRepXn = 2; boardRepYn = 2;
-    break;
-  case 5:
-    for ( k=0 ; k<5 ; k++ ) {
-      j = 0;
-      for ( i=0 ; i<16 ; i++ ) {
-	addBoard(j, i*4096, 200-k*10, 16000, 4096);
-	addBoard(j+16000-j*2, i*4096, 200-k*10, 16000, 4096);
-	if ( i < 4 ) j += 2000;
-	else if ( i < 6 ) j -= 3500;
-	else if ( i < 12 ) j += 1500;
-	else j -= 2000;
-      }
-    }
-    boardMx = -10; boardMy = 25;
-    boardRepx = boardRepy = 65536;
-    boardRepXn = boardRepYn = 2;
-    break;
-  }
-}
-
-void moveBackground() {
-  int i;
-  Board *bd;
-  for ( i=0 ; i<BOARD_MAX ; i++ ) {
-    if ( board[i].width == NOT_EXIST ) continue;
-    bd = &(board[i]);
-    bd->x += boardMx; bd->y += boardMy;
-    bd->x &= (boardRepx-1); bd->y &= (boardRepy-1);
-  }
-}
-
-void drawBackground() {
-  int i;
-  Board *bd;
-  int ox, oy, osx, osy, rx, ry;
-  osx = -boardRepx * (boardRepXn/2);
-  osy = -boardRepy * (boardRepYn/2);
-  for ( i=0 ; i<BOARD_MAX ; i++ ) {
-    if ( board[i].width == NOT_EXIST ) continue;
-    bd = &(board[i]);
-    ox = osx; 
-    for ( rx = 0 ; rx < boardRepXn ; rx++, ox += boardRepx ) {
-      oy = osy;
-      for ( ry = 0 ; ry < boardRepYn ; ry++, oy += boardRepy ) {
-	drawBox((bd->x+ox)/bd->z+LAYER_WIDTH/2, (bd->y+oy)/bd->z+LAYER_HEIGHT/2, 
-		 bd->width, bd->height, 1, 3, l1buf);
-      }
-    }
-  }
-}
+/*
+ * $Id: background.c,v 1.2 2002/12/31 09:34:34 kenta Exp $
+ *
+ * Copyright 2002 Kenta Cho. All rights reserved.
+ */
+
+/**
+ * Handle background graphics.
+ *
+ * @version $Revision: 1.2 $
+ */
+#include "SDL.h"
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "noiz2sa.h"
+#include "screen.h"
+#include "vector.h"
+#include "background.h"
+
+static Board board[BOARD_MAX];
+
+void initBackground() {
+  int i;
+  for ( i=0 ; i<BOARD_MAX ; i++ ) {
+    board[i].width = NOT_EXIST;
+  }
+}
+
+static int bdIdx;
+static int boardMx, boardMy;
+static int boardRepx, boardRepy;
+static int boardRepXn, boardRepYn;
+
+static void addBoard(int x, int y, int z, int width, int height) {
+  if ( bdIdx >= BOARD_MAX ) return;
+  board[bdIdx].x = x;
+  board[bdIdx].y = y;
+  z*=SCREEN_DIVISOR;
+  board[bdIdx].z = z;
+  board[bdIdx].width = width/z;
+  board[bdIdx].height = height/z;
+  bdIdx++;
+}
+
+void setStageBackground(int bn) {
+  int i, j, k;
+  bdIdx = 0;
+
+  switch ( bn ) {
+  case 0:
+  case 6:
+    addBoard(9000, 9000, 500, 25000, 25000);
+    for ( i=0 ; i<4 ; i++ ) {
+      for ( j=0 ; j<4 ; j++ ) {
+	if ( i > 1 || j > 1 ) {
+	  addBoard(i*16384, j*16384, 500, 10000+(i*12345)%3000, 10000+(j*54321)%3000);
+	}
+      }
+    }
+    for ( j=0 ; j<8 ; j++ ) {
+      for ( i=0 ; i<4 ; i++ ) {
+	addBoard(0, i*16384, 500-j*50, 20000-j*1000, 12000-j*500);
+      }
+    }
+    for ( i=0 ; i<8 ; i++ ) {
+      addBoard(0, i*8192, 100, 20000, 6400);
+    }
+    if ( bn == 0 ) {
+      boardMx = 40; boardMy = 300;
+    } else {
+      boardMx = -40; boardMy = 480;
+    }
+    boardRepx = boardRepy = 65536;
+    boardRepXn = boardRepYn = 4;
+    break;
+  case 1:
+    addBoard(12000, 12000, 400, 48000, 48000);
+    addBoard(12000, 44000, 400, 48000, 8000);
+    addBoard(44000, 12000, 400, 8000, 48000);
+    for ( i=0 ; i<16 ; i++ ) {
+      addBoard(0, 0, 400-i*10, 16000, 16000);
+      if ( i < 6 ) {
+	addBoard(9600, 16000, 400-i*10, 40000, 16000);
+      }
+    }
+    boardMx = 128; boardMy = 512;
+    boardRepx = boardRepy = 65536;
+    boardRepXn = boardRepYn = 4;
+    break;
+  case 2:
+    for ( i=0 ; i<16 ; i++ ) {
+      addBoard(7000+i*3000, 0, 1600-i*100, 24000, 5000);
+      addBoard(7000+i*3000, 50000, 1600-i*100, 4000, 10000);
+      addBoard(-7000-i*3000, 0, 1600-i*100, 24000, 5000);
+      addBoard(-7000-i*3000, 50000, 1600-i*100, 4000, 10000);
+    }
+    boardMx = 0; boardMy = 1200;
+    boardRepx = 0;
+    boardRepy = 65536;
+    boardRepXn = 1;
+    boardRepYn = 10;
+    break;
+  case 3:
+    addBoard(9000, 9000, 500, 30000, 30000);
+    for ( i=0 ; i<4 ; i++ ) {
+      for ( j=0 ; j<4 ; j++ ) {
+	if ( i > 1 || j > 1 ) {
+	  addBoard(i*16384, j*16384, 500, 12000+(i*12345)%3000, 12000+(j*54321)%3000);
+	}
+      }
+    }
+    for ( i=0 ; i<4 ; i++ ) {
+      for ( j=0 ; j<4 ; j++ ) {
+	if ( (i > 1 || j > 1) && (i+j)%3 == 0 ) {
+	  addBoard(i*16384, j*16384, 480, 9000+(i*12345)%3000, 9000+(j*54321)%3000);
+	}
+      }
+    }
+    addBoard(9000, 9000, 480, 20000, 20000);
+    addBoard(9000, 9000, 450, 20000, 20000);
+    addBoard(32768, 40000, 420, 65536, 5000);
+    addBoard(30000, 32768, 370, 4800, 65536);
+    addBoard(32768, 0, 8, 65536, 10000);
+    boardMx = 10; boardMy = 100;
+    boardRepx = boardRepy = 65536;
+    boardRepXn = boardRepYn = 4;
+    break;
+  case 4:
+    addBoard(32000, 12000, 160, 48000, 48000);
+    addBoard(32000, 44000, 160, 48000, 8000);
+    addBoard(64000, 12000, 160, 8000, 48000);
+    for ( i=0 ; i<16 ; i++ ) {
+      addBoard(20000, 0, 160-i*10, 16000, 16000);
+      if ( i < 6 ) {
+	addBoard(29600, 16000, 160-i*10, 40000, 16000);
+      }
+    }
+    boardMx = 0; boardMy = 128;
+    boardRepx = boardRepy = 65536;
+    boardRepXn = 2; boardRepYn = 2;
+    break;
+  case 5:
+    for ( k=0 ; k<5 ; k++ ) {
+      j = 0;
+      for ( i=0 ; i<16 ; i++ ) {
+	addBoard(j, i*4096, 200-k*10, 16000, 4096);
+	addBoard(j+16000-j*2, i*4096, 200-k*10, 16000, 4096);
+	if ( i < 4 ) j += 2000;
+	else if ( i < 6 ) j -= 3500;
+	else if ( i < 12 ) j += 1500;
+	else j -= 2000;
+      }
+    }
+    boardMx = -10; boardMy = 25;
+    boardRepx = boardRepy = 65536;
+    boardRepXn = boardRepYn = 2;
+    break;
+  }
+}
+
+void moveBackground() {
+  int i;
+  Board *bd;
+  for ( i=0 ; i<BOARD_MAX ; i++ ) {
+    if ( board[i].width == NOT_EXIST ) continue;
+    bd = &(board[i]);
+    bd->x += boardMx; bd->y += boardMy;
+    bd->x &= (boardRepx-1); bd->y &= (boardRepy-1);
+  }
+}
+
+void drawBackground() {
+  int i;
+  Board *bd;
+  int ox, oy, osx, osy, rx, ry;
+  osx = -boardRepx * (boardRepXn/2);
+  osy = -boardRepy * (boardRepYn/2);
+  for ( i=0 ; i<BOARD_MAX ; i++ ) {
+    if ( board[i].width == NOT_EXIST ) continue;
+    bd = &(board[i]);
+    ox = osx; 
+    for ( rx = 0 ; rx < boardRepXn ; rx++, ox += boardRepx ) {
+      oy = osy;
+      for ( ry = 0 ; ry < boardRepYn ; ry++, oy += boardRepy ) {
+	drawBox((bd->x+ox)/bd->z+LAYER_WIDTH/2, (bd->y+oy)/bd->z+LAYER_HEIGHT/2, 
+		 bd->width, bd->height, 1, 3, l1buf);
+      }
+    }
+  }
+}

Deleted: trunk/user/games/noiz2sa/src/barragemanager.cc

Added: trunk/user/games/noiz2sa/src/barragemanager.cpp

Modified: trunk/user/games/noiz2sa/src/bonus.c
===================================================================
--- tags/noiz2sa/noiz2sa-0.51a/src/bonus.c	2008-04-05 00:17:39 UTC (rev 2211)
+++ trunk/user/games/noiz2sa/src/bonus.c	2008-04-07 17:17:30 UTC (rev 2230)
@@ -1,143 +1,143 @@
-/*
- * $Id: bonus.c,v 1.1.1.1 2002/11/03 11:08:24 kenta Exp $
- *
- * Copyright 2002 Kenta Cho. All rights reserved.
- */
-
-/**
- * Bonus item.
- *
- * @version $Revision: 1.1.1.1 $
- */
-#include "SDL.h"
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "noiz2sa.h"
-#include "screen.h"
-#include "vector.h"
-#include "degutil.h"
-#include "ship.h"
-#include "bonus.h"
-#include "soundmanager.h"
-#include "attractmanager.h"
-
-Bonus bonus[BONUS_MAX];
-int bonusScore;
-
-void resetBonusScore() {
-  bonusScore = 10;
-  showScore();
-}
-
-static void getBonus() {
-  addScore(bonusScore);
-  if ( bonusScore < 1000 ) bonusScore += 10;
-}
-
-static void missBonus() {
-  bonusScore /= 20;
-  bonusScore *= 10;
-  if ( bonusScore < 10 ) bonusScore = 10;
-  showScore();
-}
-
-void initBonuses() {
-  int i;
-  for ( i=0 ; i<BONUS_MAX ; i++ ) {
-    bonus[i].cnt = NOT_EXIST;
-  }
-  resetBonusScore();
-}
-
-static int bonusIdx = BONUS_MAX;
-
-void addBonus(Vector *pos, Vector *vel) {
-  int i;
-  for ( i=0 ; i<BONUS_MAX ; i++ ) {
-    bonusIdx--; if ( bonusIdx < 0 ) bonusIdx = BONUS_MAX-1;
-    if ( bonus[i].cnt == NOT_EXIST ) break;
-  }
-  if ( i >= BONUS_MAX ) return;
-  bonus[i].pos = *pos;
-  bonus[i].vel = *vel;
-  bonus[i].cnt = 0;
-  bonus[i].down = 1;
-}
-
-#define BONUS_SPEED 400
-#define BONUS_INHALE_WIDTH 24000
-#define BONUS_ACQUIRE_WIDTH 8000
-
-void moveBonuses() {
-  int i, d;
-  Bonus *bn;
-  for ( i=0 ; i<BONUS_MAX ; i++ ) {
-    if ( bonus[i].cnt == NOT_EXIST ) continue;
-    bn = &(bonus[i]);
-    bn->pos.x += bn->vel.x;
-    bn->pos.y += bn->vel.y;
-    bn->vel.x -= bn->vel.x>>6;
-    if ( bn->pos.x < SCAN_WIDTH_8/8 ) {
-      bn->pos.x = SCAN_WIDTH_8/8;
-      if ( bn->vel.x < 0 ) bn->vel.x = -bn->vel.x;
-    } else if ( bn->pos.x > SCAN_WIDTH_8/8*7 ) {
-      bn->pos.x = SCAN_WIDTH_8/8*7;
-      if ( bn->vel.x > 0 ) bn->vel.x = -bn->vel.x;
-    }
-    if ( bn->down ) {
-      bn->vel.y += (BONUS_SPEED-bn->vel.y)>>6;
-      if ( bn->pos.y > SCAN_HEIGHT_8 ) {
-	bn->down = 0;
-	bn->pos.y = SCAN_HEIGHT_8;
-	bn->vel.y = -bn->vel.y;
-      }
-    } else {
-      bn->vel.y += (-BONUS_SPEED-bn->vel.y)>>6;
-      if ( bn->pos.y < 0 ) {
-	missBonus();
-	bn->cnt = NOT_EXIST;
-	continue;
-      }
-    }
-    
-    d = vctDist(&(ship.pos), &(bn->pos));
-    if ( d < BONUS_ACQUIRE_WIDTH ) {
-      getBonus();
-      playChunk(5);
-      bn->cnt = NOT_EXIST;
-      continue;
-    } else if ( d < BONUS_INHALE_WIDTH ) {
-      bn->vel.x += (long)(ship.pos.x - bn->pos.x)*(BONUS_INHALE_WIDTH-d)>>20;
-      bn->vel.y += (long)(ship.pos.y - bn->pos.y)*(BONUS_INHALE_WIDTH-d)>>20;
-    }
-    bn->cnt++;
-  }
-}
-
-#define BONUS_COLOR_1 16*3-3
-#define BONUS_COLOR_2 16*4-7
-#define BONUS_DRAW_WIDTH 8
-
-void drawBonuses() {
-  int x, y, ox, oy, d;
-  int i;
-  Bonus *bn;
-  for ( i=0 ; i<BONUS_MAX ; i++ ) {
-    if ( bonus[i].cnt == NOT_EXIST ) continue;
-    bn = &(bonus[i]);
-    d = (bn->cnt*8)&(DIV-1);
-    x = (bn->pos.x/SCAN_WIDTH*LAYER_WIDTH)>>8;
-    y = (bn->pos.y/SCAN_HEIGHT*LAYER_HEIGHT)>>8;
-    ox = sctbl[d]>>5;
-    oy = sctbl[d+DIV/4]>>5;
-    drawBox(x+ox, y+oy, BONUS_DRAW_WIDTH, BONUS_DRAW_WIDTH,
-	    BONUS_COLOR_1, BONUS_COLOR_2, l1buf);
-    drawBox(x-ox, y-oy, BONUS_DRAW_WIDTH, BONUS_DRAW_WIDTH,
-	    BONUS_COLOR_1, BONUS_COLOR_2, l1buf);
-    drawBox(x+oy, y-ox, BONUS_DRAW_WIDTH, BONUS_DRAW_WIDTH,
-	    BONUS_COLOR_1, BONUS_COLOR_2, l1buf);
-    drawBox(x-oy, y+ox, BONUS_DRAW_WIDTH, BONUS_DRAW_WIDTH,
-	    BONUS_COLOR_1, BONUS_COLOR_2, l1buf);
-  }
-}
+/*
+ * $Id: bonus.c,v 1.1.1.1 2002/11/03 11:08:24 kenta Exp $
+ *
+ * Copyright 2002 Kenta Cho. All rights reserved.
+ */
+
+/**
+ * Bonus item.
+ *
+ * @version $Revision: 1.1.1.1 $
+ */
+#include "SDL.h"
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "noiz2sa.h"
+#include "screen.h"
+#include "vector.h"
+#include "degutil.h"
+#include "ship.h"
+#include "bonus.h"
+#include "soundmanager.h"
+#include "attractmanager.h"
+
+Bonus bonus[BONUS_MAX];
+int bonusScore;
+
+void resetBonusScore() {
+  bonusScore = 10;
+  showScore();
+}
+
+static void getBonus() {
+  addScore(bonusScore);
+  if ( bonusScore < 1000 ) bonusScore += 10;
+}
+
+static void missBonus() {
+  bonusScore /= 20;
+  bonusScore *= 10;
+  if ( bonusScore < 10 ) bonusScore = 10;
+  showScore();
+}
+
+void initBonuses() {
+  int i;
+  for ( i=0 ; i<BONUS_MAX ; i++ ) {
+    bonus[i].cnt = NOT_EXIST;
+  }
+  resetBonusScore();
+}
+
+static int bonusIdx = BONUS_MAX;
+
+void addBonus(Vector *pos, Vector *vel) {
+  int i;
+  for ( i=0 ; i<BONUS_MAX ; i++ ) {
+    bonusIdx--; if ( bonusIdx < 0 ) bonusIdx = BONUS_MAX-1;
+    if ( bonus[i].cnt == NOT_EXIST ) break;
+  }
+  if ( i >= BONUS_MAX ) return;
+  bonus[i].pos = *pos;
+  bonus[i].vel = *vel;
+  bonus[i].cnt = 0;
+  bonus[i].down = 1;
+}
+
+#define BONUS_SPEED 400
+#define BONUS_INHALE_WIDTH 24000
+#define BONUS_ACQUIRE_WIDTH 8000
+
+void moveBonuses() {
+  int i, d;
+  Bonus *bn;
+  for ( i=0 ; i<BONUS_MAX ; i++ ) {
+    if ( bonus[i].cnt == NOT_EXIST ) continue;
+    bn = &(bonus[i]);
+    bn->pos.x += bn->vel.x;
+    bn->pos.y += bn->vel.y;
+    bn->vel.x -= bn->vel.x>>6;
+    if ( bn->pos.x < SCAN_WIDTH_8/8 ) {
+      bn->pos.x = SCAN_WIDTH_8/8;
+      if ( bn->vel.x < 0 ) bn->vel.x = -bn->vel.x;
+    } else if ( bn->pos.x > SCAN_WIDTH_8/8*7 ) {
+      bn->pos.x = SCAN_WIDTH_8/8*7;
+      if ( bn->vel.x > 0 ) bn->vel.x = -bn->vel.x;
+    }
+    if ( bn->down ) {
+      bn->vel.y += (BONUS_SPEED-bn->vel.y)>>6;
+      if ( bn->pos.y > SCAN_HEIGHT_8 ) {
+	bn->down = 0;
+	bn->pos.y = SCAN_HEIGHT_8;
+	bn->vel.y = -bn->vel.y;
+      }
+    } else {
+      bn->vel.y += (-BONUS_SPEED-bn->vel.y)>>6;
+      if ( bn->pos.y < 0 ) {
+	missBonus();
+	bn->cnt = NOT_EXIST;
+	continue;
+      }
+    }
+    
+    d = vctDist(&(ship.pos), &(bn->pos));
+    if ( d < BONUS_ACQUIRE_WIDTH ) {
+      getBonus();
+      playChunk(5);
+      bn->cnt = NOT_EXIST;
+      continue;
+    } else if ( d < BONUS_INHALE_WIDTH ) {
+      bn->vel.x += (long)(ship.pos.x - bn->pos.x)*(BONUS_INHALE_WIDTH-d)>>20;
+      bn->vel.y += (long)(ship.pos.y - bn->pos.y)*(BONUS_INHALE_WIDTH-d)>>20;
+    }
+    bn->cnt++;
+  }
+}
+
+#define BONUS_COLOR_1 16*3-3
+#define BONUS_COLOR_2 16*4-7
+#define BONUS_DRAW_WIDTH (8 / SCREEN_DIVISOR)
+
+void drawBonuses() {
+  int x, y, ox, oy, d;
+  int i;
+  Bonus *bn;
+  for ( i=0 ; i<BONUS_MAX ; i++ ) {
+    if ( bonus[i].cnt == NOT_EXIST ) continue;
+    bn = &(bonus[i]);
+    d = (bn->cnt*8)&(DIV-1);
+    x = (bn->pos.x/SCAN_WIDTH*LAYER_WIDTH)>>8;
+    y = (bn->pos.y/SCAN_HEIGHT*LAYER_HEIGHT)>>8;
+    ox = sctbl[d]>>5;
+    oy = sctbl[d+DIV/4]>>5;
+    drawBox(x+ox, y+oy, BONUS_DRAW_WIDTH, BONUS_DRAW_WIDTH,
+	    BONUS_COLOR_1, BONUS_COLOR_2, l1buf);
+    drawBox(x-ox, y-oy, BONUS_DRAW_WIDTH, BONUS_DRAW_WIDTH,
+	    BONUS_COLOR_1, BONUS_COLOR_2, l1buf);
+    drawBox(x+oy, y-ox, BONUS_DRAW_WIDTH, BONUS_DRAW_WIDTH,
+	    BONUS_COLOR_1, BONUS_COLOR_2, l1buf);
+    drawBox(x-oy, y+ox, BONUS_DRAW_WIDTH, BONUS_DRAW_WIDTH,
+	    BONUS_COLOR_1, BONUS_COLOR_2, l1buf);
+  }
+}

Modified: trunk/user/games/noiz2sa/src/bulletml/Makefile
===================================================================
--- tags/noiz2sa/noiz2sa-0.51a/src/bulletml/Makefile	2008-04-05 00:17:39 UTC (rev 2211)
+++ trunk/user/games/noiz2sa/src/bulletml/Makefile	2008-04-07 17:17:30 UTC (rev 2230)
@@ -1,27 +1,31 @@
-CC = g++
+#CC = g++
 INCLUDES = -I.
 LIBS = tinyxml/tinyxml.o tinyxml/tinyxmlparser.o tinyxml/tinyxmlerror.o
 #CXXFLAGS = -g -W -Wall -ansi -pedantic
 #CXXFLAGS = -pg -g -W -Wall -ansi -pedantic
-CXXFLAGS = -O2 -W -Wall -ansi -pedantic
-CFLAGS = -O2
+#CXXFLAGS = -I$(ROOTDIR)/lib/uClibc++/include -O2 -g -fomit-frame-pointer -fno-common -fno-builtin -Wall -mswp-byte-writes -DCONFIG_NDS_ROM8BIT -mcpu=arm946e-s -mfpu=fpe3 -DEMBED -D__PIC__ -fpic -msingle-pic-base -Dlinux -D__linux__ -Dunix -D__uClinux__ -I /home/gpf/dslinux/lib/uClibc++/include -fno-builtin -nostdinc++ -DGCC_HASCLASSVISIBILITY -fexceptions -Wno-deprecated
+
+CFLAGS += 
 OBJS = bulletmlparser-tinyxml.o bulletmlparser.o bulletmltree.o calc.o formula-variables.o bulletmlrunner.o bulletmlrunnerimpl.o
 
-all: libbulletml.a
+all: tinyxml libbulletml.a
 
+tinyxml:
+	$(MAKE) -C tinyxml
+
 libbulletml.a: $(OBJS)
-	$(MAKE) -C tinyxml
+		#$(CXX) $(CXXFLAGS) -o $@ $(CRTBEGIN) $(LDFLAGS) $(OBJS) $(CXXLIBS) $(LDLIBS) $(CRTEND)
 	$(AR) -r libbulletml.a *.o tinyxml/tiny*.o
 
 clean:
-	rm -f *.o *.a
+	rm -f *.o *.a *.elf2flt
 	$(MAKE) -C tinyxml clean
 
-calc.cpp: calc.yy
-	bison -y   calc.yy && mv y.tab.c calc.cpp
+#calc.cpp: calc.yy
+#	bison -y   calc.yy && mv y.tab.c calc.cpp
 
 $(OBJS): %.o: %.cpp
-	$(CC) -c $(CXXFLAGS) $(INCLUDES) $<
+	$(CXX) -c $(CXXFLAGS) $(INCLUDES) -o $@ $<
 
 doxy:
 	doxygen

Modified: trunk/user/games/noiz2sa/src/bulletml/calc.cpp
===================================================================
--- tags/noiz2sa/noiz2sa-0.51a/src/bulletml/calc.cpp	2008-04-05 00:17:39 UTC (rev 2211)
+++ trunk/user/games/noiz2sa/src/bulletml/calc.cpp	2008-04-07 17:17:30 UTC (rev 2230)
@@ -1,15 +1,89 @@
+/* A Bison parser, made by GNU Bison 2.3.  */
 
-/*  A Bison parser, made from calc.yy
-    by GNU Bison version 1.28  */
+/* Skeleton implementation for Bison's Yacc-like parsers in C
 
-#define YYBISON 1  /* Identify Bison output.  */
+   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   Free Software Foundation, Inc.
 
-#define	NUM	257
-#define	RAND	258
-#define	RANK	259
-#define	PARAM	260
-#define	NEG	261
+   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, 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., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+/* As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
+
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.  */
+
+/* C LALR(1) parser skeleton written by Richard Stallman, by
+   simplifying the original so-called "semantic" parser.  */
+
+/* All symbols defined below should begin with yy or YY, to avoid
+   infringing on user name space.  This should be done even for local
+   variables, as they might otherwise be expanded by user macros.
+   There are some unavoidable exceptions within include files to
+   define necessary library symbols; they are noted "INFRINGES ON
+   USER NAME SPACE" below.  */
+
+/* Identify Bison output.  */
+#define YYBISON 1
+
+/* Bison version.  */
+#define YYBISON_VERSION "2.3"
+
+/* Skeleton name.  */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers.  */
+#define YYPURE 0
+
+/* Using locations.  */
+#define YYLSP_NEEDED 0
+
+
+
+/* Tokens.  */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+   /* Put the tokens into the symbol table, so that GDB and other debuggers
+      know about them.  */
+   enum yytokentype {
+     NUM = 258,
+     RAND = 259,
+     RANK = 260,
+     PARAM = 261,
+     NEG = 262
+   };
+#endif
+/* Tokens.  */
+#define NUM 258
+#define RAND 259
+#define RANK 260
+#define PARAM 261
+#define NEG 262
+
+
+
+
+/* Copy the first part of user declarations.  */
 #line 3 "calc.yy"
 
 typedef double NumType;
@@ -48,428 +122,1045 @@
 	int paramId;
 }
 
-#ifndef YYSTYPE
-#define YYSTYPE int
+
+
+/* Enabling traces.  */
+#ifndef YYDEBUG
+# define YYDEBUG 0
 #endif
-#include <stdio.h>
 
-#ifndef __cplusplus
-#ifndef __STDC__
-#define const
+/* Enabling verbose error messages.  */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 0
 #endif
+
+/* Enabling the token table.  */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
 #endif
 
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef int YYSTYPE;
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
 
 
-#define	YYFINAL		24
-#define	YYFLAG		-32768
-#define	YYNTBASE	16
 
-#define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 19)
+/* Copy the second part of user declarations.  */
 
-static const char yytranslate[] = {     0,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,    13,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,    14,
-    15,     9,     8,     2,     7,     2,    10,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,    12,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
-    11
-};
 
-#if YYDEBUG != 0
-static const short yyprhs[] = {     0,
-     0,     1,     4,     6,     9,    11,    13,    15,    17,    21,
-    25,    29,    33,    36
-};
+/* Line 216 of yacc.c.  */
+#line 159 "y.tab.c"
 
-static const short yyrhs[] = {    -1,
-    16,    17,     0,    13,     0,    18,    13,     0,     3,     0,
-     4,     0,     5,     0,     6,     0,    18,     8,    18,     0,
-    18,     7,    18,     0,    18,     9,    18,     0,    18,    10,
-    18,     0,     7,    18,     0,    14,    18,    15,     0
-};
+#ifdef short
+# undef short
+#endif
 
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
 #endif
 
-#if YYDEBUG != 0
-static const short yyrline[] = { 0,
-    51,    52,    55,    56,    59,    63,    67,    71,    75,    79,
-    83,    87,    91,    95
-};
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#elif (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+typedef signed char yytype_int8;
+#else
+typedef short int yytype_int8;
 #endif
 
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
 
-#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
 
-static const char * const yytname[] = {   "$","error","$undefined.","NUM","RAND",
-"RANK","PARAM","'-'","'+'","'*'","'/'","NEG","'^'","'\\n'","'('","')'","input",
-"line","exp", NULL
-};
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+#  define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+#  define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+#  define YYSIZE_T size_t
+# else
+#  define YYSIZE_T unsigned int
+# endif
 #endif
 
-static const short yyr1[] = {     0,
-    16,    16,    17,    17,    18,    18,    18,    18,    18,    18,
-    18,    18,    18,    18
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if YYENABLE_NLS
+#  if ENABLE_NLS
+#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+#   define YY_(msgid) dgettext ("bison-runtime", msgid)
+#  endif
+# endif
+# ifndef YY_
+#  define YY_(msgid) msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E.  */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions.  */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int i)
+#else
+static int
+YYID (i)
+    int i;
+#endif
+{
+  return i;
+}
+#endif
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols.  */
+
+# ifdef YYSTACK_USE_ALLOCA
+#  if YYSTACK_USE_ALLOCA
+#   ifdef __GNUC__
+#    define YYSTACK_ALLOC __builtin_alloca
+#   elif defined __BUILTIN_VA_ARG_INCR
+#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
+#   elif defined _AIX
+#    define YYSTACK_ALLOC __alloca
+#   elif defined _MSC_VER
+#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
+#    define alloca _alloca
+#   else
+#    define YYSTACK_ALLOC alloca
+#    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+#     ifndef _STDLIB_H
+#      define _STDLIB_H 1
+#     endif
+#    endif
+#   endif
+#  endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+   /* Pacify GCC's `empty if-body' warning.  */
+#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+#  ifndef YYSTACK_ALLOC_MAXIMUM
+    /* The OS might guarantee only one guard page at the bottom of the stack,
+       and a page size can be as small as 4096 bytes.  So we cannot safely
+       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
+       to allow for a few compiler-allocated temporary stack slots.  */
+#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+#  endif
+# else
+#  define YYSTACK_ALLOC YYMALLOC
+#  define YYSTACK_FREE YYFREE
+#  ifndef YYSTACK_ALLOC_MAXIMUM
+#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+#  endif
+#  if (defined __cplusplus && ! defined _STDLIB_H \
+       && ! ((defined YYMALLOC || defined malloc) \
+	     && (defined YYFREE || defined free)))
+#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+#   ifndef _STDLIB_H
+#    define _STDLIB_H 1
+#   endif
+#  endif
+#  ifndef YYMALLOC
+#   define YYMALLOC malloc
+#   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+#   endif
+#  endif
+#  ifndef YYFREE
+#   define YYFREE free
+#   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+#   endif
+#  endif
+# endif
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
+
+
+#if (! defined yyoverflow \
+     && (! defined __cplusplus \
+	 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member.  */
+union yyalloc
+{
+  yytype_int16 yyss;
+  YYSTYPE yyvs;
+  };
+
+/* The size of the maximum gap between one aligned stack and the next.  */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+   N elements.  */
+# define YYSTACK_BYTES(N) \
+     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+      + YYSTACK_GAP_MAXIMUM)
+
+/* Copy COUNT objects from FROM to TO.  The source and destination do
+   not overlap.  */
+# ifndef YYCOPY
+#  if defined __GNUC__ && 1 < __GNUC__
+#   define YYCOPY(To, From, Count) \
+      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+#  else
+#   define YYCOPY(To, From, Count)		\
+      do					\
+	{					\
+	  YYSIZE_T yyi;				\
+	  for (yyi = 0; yyi < (Count); yyi++)	\
+	    (To)[yyi] = (From)[yyi];		\
+	}					\
+      while (YYID (0))
+#  endif
+# endif
+
+/* Relocate STACK from its old location to the new one.  The
+   local variables YYSIZE and YYSTACKSIZE give the old and new number of
+   elements in the stack, and YYPTR gives the new location of the
+   stack.  Advance YYPTR to a properly aligned location for the next
+   stack.  */
+# define YYSTACK_RELOCATE(Stack)					\
+    do									\
+      {									\
+	YYSIZE_T yynewbytes;						\
+	YYCOPY (&yyptr->Stack, Stack, yysize);				\
+	Stack = &yyptr->Stack;						\
+	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+	yyptr += yynewbytes / sizeof (*yyptr);				\
+      }									\
+    while (YYID (0))
+
+#endif
+
+/* YYFINAL -- State number of the termination state.  */
+#define YYFINAL  2
+/* YYLAST -- Last index in YYTABLE.  */
+#define YYLAST   36
+
+/* YYNTOKENS -- Number of terminals.  */
+#define YYNTOKENS  16
+/* YYNNTS -- Number of nonterminals.  */
+#define YYNNTS  4
+/* YYNRULES -- Number of rules.  */
+#define YYNRULES  15
+/* YYNRULES -- Number of states.  */
+#define YYNSTATES  24
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
+#define YYUNDEFTOK  2
+#define YYMAXUTOK   262
+
+#define YYTRANSLATE(YYX)						\
+  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
+static const yytype_uint8 yytranslate[] =
+{
+       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+      13,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+      14,    15,     9,     8,     2,     7,     2,    10,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,    12,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
+       5,     6,    11
 };
 
-static const short yyr2[] = {     0,
-     0,     2,     1,     2,     1,     1,     1,     1,     3,     3,
-     3,     3,     2,     3
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+   YYRHS.  */
+static const yytype_uint8 yyprhs[] =
+{
+       0,     0,     3,     4,     7,     9,    12,    14,    16,    18,
+      20,    24,    28,    32,    36,    39
 };
 
-static const short yydefact[] = {     1,
-     0,     5,     6,     7,     8,     0,     3,     0,     2,     0,
-    13,     0,     0,     0,     0,     0,     4,    14,    10,     9,
-    11,    12,     0,     0
+/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
+static const yytype_int8 yyrhs[] =
+{
+      17,     0,    -1,    -1,    17,    18,    -1,    13,    -1,    19,
+      13,    -1,     3,    -1,     4,    -1,     5,    -1,     6,    -1,
+      19,     8,    19,    -1,    19,     7,    19,    -1,    19,     9,
+      19,    -1,    19,    10,    19,    -1,     7,    19,    -1,    14,
+      19,    15,    -1
 };
 
-static const short yydefgoto[] = {     1,
-     9,    10
+/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
+static const yytype_uint8 yyrline[] =
+{
+       0,    51,    51,    52,    55,    56,    59,    63,    67,    71,
+      75,    79,    83,    87,    91,    95
 };
+#endif
 
-static const short yypact[] = {-32768,
-     0,-32768,-32768,-32768,-32768,     5,-32768,     5,-32768,    23,
--32768,    19,     5,     5,     5,     5,-32768,-32768,    -8,    -8,
--32768,-32768,    16,-32768
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
+static const char *const yytname[] =
+{
+  "$end", "error", "$undefined", "NUM", "RAND", "RANK", "PARAM", "'-'",
+  "'+'", "'*'", "'/'", "NEG", "'^'", "'\\n'", "'('", "')'", "$accept",
+  "input", "line", "exp", 0
 };
+#endif
 
-static const short yypgoto[] = {-32768,
--32768,     9
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+   token YYLEX-NUM.  */
+static const yytype_uint16 yytoknum[] =
+{
+       0,   256,   257,   258,   259,   260,   261,    45,    43,    42,
+      47,   262,    94,    10,    40,    41
 };
+# endif
 
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
+static const yytype_uint8 yyr1[] =
+{
+       0,    16,    17,    17,    18,    18,    19,    19,    19,    19,
+      19,    19,    19,    19,    19,    19
+};
 
-#define	YYLAST		36
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
+static const yytype_uint8 yyr2[] =
+{
+       0,     2,     0,     2,     1,     2,     1,     1,     1,     1,
+       3,     3,     3,     3,     2,     3
+};
 
+/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
+   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
+   means the default is an error.  */
+static const yytype_uint8 yydefact[] =
+{
+       2,     0,     1,     6,     7,     8,     9,     0,     4,     0,
+       3,     0,    14,     0,     0,     0,     0,     0,     5,    15,
+      11,    10,    12,    13
+};
 
-static const short yytable[] = {    23,
-    15,    16,     2,     3,     4,     5,     6,     2,     3,     4,
-     5,     6,     7,     8,    11,    24,    12,     0,     8,     0,
-     0,    19,    20,    21,    22,    13,    14,    15,    16,    13,
-    14,    15,    16,    18,     0,    17
+/* YYDEFGOTO[NTERM-NUM].  */
+static const yytype_int8 yydefgoto[] =
+{
+      -1,     1,    10,    11
 };
 
-static const short yycheck[] = {     0,
-     9,    10,     3,     4,     5,     6,     7,     3,     4,     5,
-     6,     7,    13,    14,     6,     0,     8,    -1,    14,    -1,
-    -1,    13,    14,    15,    16,     7,     8,     9,    10,     7,
-     8,     9,    10,    15,    -1,    13
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+   STATE-NUM.  */
+#define YYPACT_NINF -9
+static const yytype_int8 yypact[] =
+{
+      -9,     0,    -9,    -9,    -9,    -9,    -9,     5,    -9,     5,
+      -9,    23,    -9,    19,     5,     5,     5,     5,    -9,    -9,
+      -8,    -8,    -9,    -9
 };
-/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
-#line 3 "/usr/lib/bison.simple"
-/* This file comes from bison-1.28.  */
 
-/* Skeleton output parser for bison,
-   Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
+/* YYPGOTO[NTERM-NUM].  */
+static const yytype_int8 yypgoto[] =
+{
+      -9,    -9,    -9,     8
+};
 
-   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, or (at your option)
-   any later version.
+/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
+   positive, shift that token.  If negative, reduce the rule which
+   number is the opposite.  If zero, do what YYDEFACT says.
+   If YYTABLE_NINF, syntax error.  */
+#define YYTABLE_NINF -1
+static const yytype_uint8 yytable[] =
+{
+       2,    16,    17,     3,     4,     5,     6,     7,     3,     4,
+       5,     6,     7,     8,     9,    12,     0,    13,     0,     9,
+       0,     0,    20,    21,    22,    23,    14,    15,    16,    17,
+      14,    15,    16,    17,    19,     0,    18
+};
 
-   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.
+static const yytype_int8 yycheck[] =
+{
+       0,     9,    10,     3,     4,     5,     6,     7,     3,     4,
+       5,     6,     7,    13,    14,     7,    -1,     9,    -1,    14,
+      -1,    -1,    14,    15,    16,    17,     7,     8,     9,    10,
+       7,     8,     9,    10,    15,    -1,    13
+};
 
-   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.  */
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+   symbol of state STATE-NUM.  */
+static const yytype_uint8 yystos[] =
+{
+       0,    17,     0,     3,     4,     5,     6,     7,    13,    14,
+      18,    19,    19,    19,     7,     8,     9,    10,    13,    15,
+      19,    19,    19,    19
+};
 
-/* As a special exception, when this file is copied by Bison into a
-   Bison output file, you may use that output file without restriction.
-   This special exception was added by the Free Software Foundation
-   in version 1.24 of Bison.  */
-
-/* This is the parser code that is written into each bison parser
-  when the %semantic_parser declaration is not specified in the grammar.
-  It was written by Richard Stallman by simplifying the hairy parser
-  used when %semantic_parser is specified.  */
-
-#ifndef YYSTACK_USE_ALLOCA
-#ifdef alloca
-#define YYSTACK_USE_ALLOCA
-#else /* alloca not defined */
-#ifdef __GNUC__
-#define YYSTACK_USE_ALLOCA
-#define alloca __builtin_alloca
-#else /* not GNU C.  */
-#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
-#define YYSTACK_USE_ALLOCA
-#include <alloca.h>
-#else /* not sparc */
-/* We think this test detects Watcom and Microsoft C.  */
-/* This used to test MSDOS, but that is a bad idea
-   since that symbol is in the user namespace.  */
-#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
-#if 0 /* No need for malloc.h, which pollutes the namespace;
-	 instead, just don't use alloca.  */
-#include <malloc.h>
-#endif
-#else /* not MSDOS, or __TURBOC__ */
-#if defined(_AIX)
-/* I don't know what this was needed for, but it pollutes the namespace.
-   So I turned it off.   rms, 2 May 1997.  */
-/* #include <malloc.h>  */
- #pragma alloca
-#define YYSTACK_USE_ALLOCA
-#else /* not MSDOS, or __TURBOC__, or _AIX */
-#if 0
-#ifdef __hpux /* haible at ilog.fr says this works for HPUX 9.05 and up,
-		 and on HPUX 10.  Eventually we can turn this on.  */
-#define YYSTACK_USE_ALLOCA
-#define alloca __builtin_alloca
-#endif /* __hpux */
-#endif
-#endif /* not _AIX */
-#endif /* not MSDOS, or __TURBOC__ */
-#endif /* not sparc */
-#endif /* not GNU C */
-#endif /* alloca not defined */
-#endif /* YYSTACK_USE_ALLOCA not defined */
-
-#ifdef YYSTACK_USE_ALLOCA
-#define YYSTACK_ALLOC alloca
-#else
-#define YYSTACK_ALLOC malloc
-#endif
-
-/* Note: there must be only one dollar sign in this file.
-   It is replaced by the list of actions, each action
-   as one case of the switch.  */
-
 #define yyerrok		(yyerrstatus = 0)
 #define yyclearin	(yychar = YYEMPTY)
-#define YYEMPTY		-2
+#define YYEMPTY		(-2)
 #define YYEOF		0
+
 #define YYACCEPT	goto yyacceptlab
-#define YYABORT 	goto yyabortlab
-#define YYERROR		goto yyerrlab1
-/* Like YYERROR except do call yyerror.
-   This remains here temporarily to ease the
-   transition to the new meaning of YYERROR, for GCC.
+#define YYABORT		goto yyabortlab
+#define YYERROR		goto yyerrorlab
+
+
+/* Like YYERROR except do call yyerror.  This remains here temporarily
+   to ease the transition to the new meaning of YYERROR, for GCC.
    Once GCC version 2 has supplanted version 1, this can go.  */
+
 #define YYFAIL		goto yyerrlab
+
 #define YYRECOVERING()  (!!yyerrstatus)
-#define YYBACKUP(token, value) \
+
+#define YYBACKUP(Token, Value)					\
 do								\
   if (yychar == YYEMPTY && yylen == 1)				\
-    { yychar = (token), yylval = (value);			\
-      yychar1 = YYTRANSLATE (yychar);				\
-      YYPOPSTACK;						\
+    {								\
+      yychar = (Token);						\
+      yylval = (Value);						\
+      yytoken = YYTRANSLATE (yychar);				\
+      YYPOPSTACK (1);						\
       goto yybackup;						\
     }								\
   else								\
-    { yyerror ("syntax error: cannot back up"); YYERROR; }	\
-while (0)
+    {								\
+      yyerror (YY_("syntax error: cannot back up")); \
+      YYERROR;							\
+    }								\
+while (YYID (0))
 
+
 #define YYTERROR	1
 #define YYERRCODE	256
 
-#ifndef YYPURE
-#define YYLEX		yylex()
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+   If N is 0, then set CURRENT to the empty location which ends
+   the previous symbol: RHS[0] (always defined).  */
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N)				\
+    do									\
+      if (YYID (N))                                                    \
+	{								\
+	  (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;	\
+	  (Current).first_column = YYRHSLOC (Rhs, 1).first_column;	\
+	  (Current).last_line    = YYRHSLOC (Rhs, N).last_line;		\
+	  (Current).last_column  = YYRHSLOC (Rhs, N).last_column;	\
+	}								\
+      else								\
+	{								\
+	  (Current).first_line   = (Current).last_line   =		\
+	    YYRHSLOC (Rhs, 0).last_line;				\
+	  (Current).first_column = (Current).last_column =		\
+	    YYRHSLOC (Rhs, 0).last_column;				\
+	}								\
+    while (YYID (0))
 #endif
 
-#ifdef YYPURE
-#ifdef YYLSP_NEEDED
+
+/* YY_LOCATION_PRINT -- Print the location on the stream.
+   This macro was not mandated originally: define only if we know
+   we won't break user code: when these are the locations we know.  */
+
+#ifndef YY_LOCATION_PRINT
+# if YYLTYPE_IS_TRIVIAL
+#  define YY_LOCATION_PRINT(File, Loc)			\
+     fprintf (File, "%d.%d-%d.%d",			\
+	      (Loc).first_line, (Loc).first_column,	\
+	      (Loc).last_line,  (Loc).last_column)
+# else
+#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+# endif
+#endif
+
+
+/* YYLEX -- calling `yylex' with the right arguments.  */
+
 #ifdef YYLEX_PARAM
-#define YYLEX		yylex(&yylval, &yylloc, YYLEX_PARAM)
+# define YYLEX yylex (YYLEX_PARAM)
 #else
-#define YYLEX		yylex(&yylval, &yylloc)
+# define YYLEX yylex ()
 #endif
-#else /* not YYLSP_NEEDED */
-#ifdef YYLEX_PARAM
-#define YYLEX		yylex(&yylval, YYLEX_PARAM)
+
+/* Enable debugging if requested.  */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
+#  define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args)			\
+do {						\
+  if (yydebug)					\
+    YYFPRINTF Args;				\
+} while (YYID (0))
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)			  \
+do {									  \
+  if (yydebug)								  \
+    {									  \
+      YYFPRINTF (stderr, "%s ", Title);					  \
+      yy_symbol_print (stderr,						  \
+		  Type, Value); \
+      YYFPRINTF (stderr, "\n");						  \
+    }									  \
+} while (YYID (0))
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT.  |
+`--------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
 #else
-#define YYLEX		yylex(&yylval)
+static void
+yy_symbol_value_print (yyoutput, yytype, yyvaluep)
+    FILE *yyoutput;
+    int yytype;
+    YYSTYPE const * const yyvaluep;
 #endif
-#endif /* not YYLSP_NEEDED */
+{
+  if (!yyvaluep)
+    return;
+# ifdef YYPRINT
+  if (yytype < YYNTOKENS)
+    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# else
+  YYUSE (yyoutput);
+# endif
+  switch (yytype)
+    {
+      default:
+	break;
+    }
+}
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT.  |
+`--------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_print (yyoutput, yytype, yyvaluep)
+    FILE *yyoutput;
+    int yytype;
+    YYSTYPE const * const yyvaluep;
 #endif
+{
+  if (yytype < YYNTOKENS)
+    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+  else
+    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
 
-/* If nonreentrant, generate the variables here */
+  yy_symbol_value_print (yyoutput, yytype, yyvaluep);
+  YYFPRINTF (yyoutput, ")");
+}
 
-#ifndef YYPURE
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included).                                                   |
+`------------------------------------------------------------------*/
 
-int	yychar;			/*  the lookahead symbol		*/
-YYSTYPE	yylval;			/*  the semantic value of the		*/
-				/*  lookahead symbol			*/
-
-#ifdef YYLSP_NEEDED
-YYLTYPE yylloc;			/*  location data for the lookahead	*/
-				/*  symbol				*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
+#else
+static void
+yy_stack_print (bottom, top)
+    yytype_int16 *bottom;
+    yytype_int16 *top;
 #endif
+{
+  YYFPRINTF (stderr, "Stack now");
+  for (; bottom <= top; ++bottom)
+    YYFPRINTF (stderr, " %d", *bottom);
+  YYFPRINTF (stderr, "\n");
+}
 
-int yynerrs;			/*  number of parse errors so far       */
-#endif  /* not YYPURE */
+# define YY_STACK_PRINT(Bottom, Top)				\
+do {								\
+  if (yydebug)							\
+    yy_stack_print ((Bottom), (Top));				\
+} while (YYID (0))
 
-#if YYDEBUG != 0
-int yydebug;			/*  nonzero means print parse trace	*/
-/* Since this is uninitialized, it does not stop multiple parsers
-   from coexisting.  */
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced.  |
+`------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
+#else
+static void
+yy_reduce_print (yyvsp, yyrule)
+    YYSTYPE *yyvsp;
+    int yyrule;
 #endif
+{
+  int yynrhs = yyr2[yyrule];
+  int yyi;
+  unsigned long int yylno = yyrline[yyrule];
+  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+	     yyrule - 1, yylno);
+  /* The symbols being reduced.  */
+  for (yyi = 0; yyi < yynrhs; yyi++)
+    {
+      fprintf (stderr, "   $%d = ", yyi + 1);
+      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+		       &(yyvsp[(yyi + 1) - (yynrhs)])
+		       		       );
+      fprintf (stderr, "\n");
+    }
+}
 
-/*  YYINITDEPTH indicates the initial size of the parser's stacks	*/
+# define YY_REDUCE_PRINT(Rule)		\
+do {					\
+  if (yydebug)				\
+    yy_reduce_print (yyvsp, Rule); \
+} while (YYID (0))
 
+/* Nonzero means print parse trace.  It is left uninitialized so that
+   multiple parsers can coexist.  */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks.  */
 #ifndef	YYINITDEPTH
-#define YYINITDEPTH 200
+# define YYINITDEPTH 200
 #endif
 
-/*  YYMAXDEPTH is the maximum size the stacks can grow to
-    (effective only if the built-in stack extension method is used).  */
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+   if the built-in stack extension method is used).
 
-#if YYMAXDEPTH == 0
-#undef YYMAXDEPTH
-#endif
+   Do not make this value too large; the results are undefined if
+   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+   evaluated with infinite-precision integer arithmetic.  */
 
 #ifndef YYMAXDEPTH
-#define YYMAXDEPTH 10000
+# define YYMAXDEPTH 10000
 #endif
+
 
-/* Define __yy_memcpy.  Note that the size argument
-   should be passed with type unsigned int, because that is what the non-GCC
-   definitions require.  With GCC, __builtin_memcpy takes an arg
-   of type size_t, but it can handle unsigned int.  */
 
-#if __GNUC__ > 1		/* GNU C and GNU C++ define this.  */
-#define __yy_memcpy(TO,FROM,COUNT)	__builtin_memcpy(TO,FROM,COUNT)
-#else				/* not GNU C or C++ */
-#ifndef __cplusplus
+#if YYERROR_VERBOSE
 
-/* This is the most reliable way to avoid incompatibilities
-   in available built-in functions on various systems.  */
-static void
-__yy_memcpy (to, from, count)
-     char *to;
-     char *from;
-     unsigned int count;
+# ifndef yystrlen
+#  if defined __GLIBC__ && defined _STRING_H
+#   define yystrlen strlen
+#  else
+/* Return the length of YYSTR.  */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static YYSIZE_T
+yystrlen (const char *yystr)
+#else
+static YYSIZE_T
+yystrlen (yystr)
+    const char *yystr;
+#endif
 {
-  register char *f = from;
-  register char *t = to;
-  register int i = count;
+  YYSIZE_T yylen;
+  for (yylen = 0; yystr[yylen]; yylen++)
+    continue;
+  return yylen;
+}
+#  endif
+# endif
 
-  while (i-- > 0)
-    *t++ = *f++;
+# ifndef yystpcpy
+#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
+#   define yystpcpy stpcpy
+#  else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+   YYDEST.  */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static char *
+yystpcpy (char *yydest, const char *yysrc)
+#else
+static char *
+yystpcpy (yydest, yysrc)
+    char *yydest;
+    const char *yysrc;
+#endif
+{
+  char *yyd = yydest;
+  const char *yys = yysrc;
+
+  while ((*yyd++ = *yys++) != '\0')
+    continue;
+
+  return yyd - 1;
 }
+#  endif
+# endif
 
-#else /* __cplusplus */
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+   quotes and backslashes, so that it's suitable for yyerror.  The
+   heuristic is that double-quoting is unnecessary unless the string
+   contains an apostrophe, a comma, or backslash (other than
+   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
+   null, do not copy; instead, return the length of what the result
+   would have been.  */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+  if (*yystr == '"')
+    {
+      YYSIZE_T yyn = 0;
+      char const *yyp = yystr;
 
-/* This is the most reliable way to avoid incompatibilities
-   in available built-in functions on various systems.  */
-static void
-__yy_memcpy (char *to, char *from, unsigned int count)
+      for (;;)
+	switch (*++yyp)
+	  {
+	  case '\'':
+	  case ',':
+	    goto do_not_strip_quotes;
+
+	  case '\\':
+	    if (*++yyp != '\\')
+	      goto do_not_strip_quotes;
+	    /* Fall through.  */
+	  default:
+	    if (yyres)
+	      yyres[yyn] = *yyp;
+	    yyn++;
+	    break;
+
+	  case '"':
+	    if (yyres)
+	      yyres[yyn] = '\0';
+	    return yyn;
+	  }
+    do_not_strip_quotes: ;
+    }
+
+  if (! yyres)
+    return yystrlen (yystr);
+
+  return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+/* Copy into YYRESULT an error message about the unexpected token
+   YYCHAR while in state YYSTATE.  Return the number of bytes copied,
+   including the terminating null byte.  If YYRESULT is null, do not
+   copy anything; just return the number of bytes that would be
+   copied.  As a special case, return 0 if an ordinary "syntax error"
+   message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
+   size calculation.  */
+static YYSIZE_T
+yysyntax_error (char *yyresult, int yystate, int yychar)
 {
-  register char *t = to;
-  register char *f = from;
-  register int i = count;
+  int yyn = yypact[yystate];
 
-  while (i-- > 0)
-    *t++ = *f++;
+  if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
+    return 0;
+  else
+    {
+      int yytype = YYTRANSLATE (yychar);
+      YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
+      YYSIZE_T yysize = yysize0;
+      YYSIZE_T yysize1;
+      int yysize_overflow = 0;
+      enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+      char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+      int yyx;
+
+# if 0
+      /* This is so xgettext sees the translatable formats that are
+	 constructed on the fly.  */
+      YY_("syntax error, unexpected %s");
+      YY_("syntax error, unexpected %s, expecting %s");
+      YY_("syntax error, unexpected %s, expecting %s or %s");
+      YY_("syntax error, unexpected %s, expecting %s or %s or %s");
+      YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
+# endif
+      char *yyfmt;
+      char const *yyf;
+      static char const yyunexpected[] = "syntax error, unexpected %s";
+      static char const yyexpecting[] = ", expecting %s";
+      static char const yyor[] = " or %s";
+      char yyformat[sizeof yyunexpected
+		    + sizeof yyexpecting - 1
+		    + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
+		       * (sizeof yyor - 1))];
+      char const *yyprefix = yyexpecting;
+
+      /* Start YYX at -YYN if negative to avoid negative indexes in
+	 YYCHECK.  */
+      int yyxbegin = yyn < 0 ? -yyn : 0;
+
+      /* Stay within bounds of both yycheck and yytname.  */
+      int yychecklim = YYLAST - yyn + 1;
+      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+      int yycount = 1;
+
+      yyarg[0] = yytname[yytype];
+      yyfmt = yystpcpy (yyformat, yyunexpected);
+
+      for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+	if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+	  {
+	    if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+	      {
+		yycount = 1;
+		yysize = yysize0;
+		yyformat[sizeof yyunexpected - 1] = '\0';
+		break;
+	      }
+	    yyarg[yycount++] = yytname[yyx];
+	    yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+	    yysize_overflow |= (yysize1 < yysize);
+	    yysize = yysize1;
+	    yyfmt = yystpcpy (yyfmt, yyprefix);
+	    yyprefix = yyor;
+	  }
+
+      yyf = YY_(yyformat);
+      yysize1 = yysize + yystrlen (yyf);
+      yysize_overflow |= (yysize1 < yysize);
+      yysize = yysize1;
+
+      if (yysize_overflow)
+	return YYSIZE_MAXIMUM;
+
+      if (yyresult)
+	{
+	  /* Avoid sprintf, as that infringes on the user's name space.
+	     Don't have undefined behavior even if the translation
+	     produced a string with the wrong number of "%s"s.  */
+	  char *yyp = yyresult;
+	  int yyi = 0;
+	  while ((*yyp = *yyf) != '\0')
+	    {
+	      if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
+		{
+		  yyp += yytnamerr (yyp, yyarg[yyi++]);
+		  yyf += 2;
+		}
+	      else
+		{
+		  yyp++;
+		  yyf++;
+		}
+	    }
+	}
+      return yysize;
+    }
 }
+#endif /* YYERROR_VERBOSE */
+
 
+/*-----------------------------------------------.
+| Release the memory associated to this symbol.  |
+`-----------------------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
+#else
+static void
+yydestruct (yymsg, yytype, yyvaluep)
+    const char *yymsg;
+    int yytype;
+    YYSTYPE *yyvaluep;
 #endif
-#endif
+{
+  YYUSE (yyvaluep);
+
+  if (!yymsg)
+    yymsg = "Deleting";
+  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+  switch (yytype)
+    {
+
+      default:
+	break;
+    }
+}
 
-#line 217 "/usr/lib/bison.simple"
 
-/* The user can define YYPARSE_PARAM as the name of an argument to be passed
-   into yyparse.  The argument should have type void *.
-   It should actually point to an object.
-   Grammar actions can access the variable by casting it
-   to the proper pointer type.  */
+/* Prevent warnings from -Wmissing-prototypes.  */
 
 #ifdef YYPARSE_PARAM
-#ifdef __cplusplus
-#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
-#define YYPARSE_PARAM_DECL
-#else /* not __cplusplus */
-#define YYPARSE_PARAM_ARG YYPARSE_PARAM
-#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
-#endif /* not __cplusplus */
-#else /* not YYPARSE_PARAM */
-#define YYPARSE_PARAM_ARG
-#define YYPARSE_PARAM_DECL
-#endif /* not YYPARSE_PARAM */
-
-/* Prevent warning if -Wstrict-prototypes.  */
-#ifdef __GNUC__
-#ifdef YYPARSE_PARAM
-int yyparse (void *);
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void *YYPARSE_PARAM);
 #else
+int yyparse ();
+#endif
+#else /* ! YYPARSE_PARAM */
+#if defined __STDC__ || defined __cplusplus
 int yyparse (void);
+#else
+int yyparse ();
 #endif
-#endif
+#endif /* ! YYPARSE_PARAM */
 
-int
-yyparse(YYPARSE_PARAM_ARG)
-     YYPARSE_PARAM_DECL
-{
-  register int yystate;
-  register int yyn;
-  register short *yyssp;
-  register YYSTYPE *yyvsp;
-  int yyerrstatus;	/*  number of tokens to shift before error messages enabled */
-  int yychar1 = 0;		/*  lookahead token as an internal (translated) token number */
 
-  short	yyssa[YYINITDEPTH];	/*  the state stack			*/
-  YYSTYPE yyvsa[YYINITDEPTH];	/*  the semantic value stack		*/
 
-  short *yyss = yyssa;		/*  refer to the stacks thru separate pointers */
-  YYSTYPE *yyvs = yyvsa;	/*  to allow yyoverflow to reallocate them elsewhere */
+/* The look-ahead symbol.  */
+int yychar;
 
-#ifdef YYLSP_NEEDED
-  YYLTYPE yylsa[YYINITDEPTH];	/*  the location stack			*/
-  YYLTYPE *yyls = yylsa;
-  YYLTYPE *yylsp;
+/* The semantic value of the look-ahead symbol.  */
+YYSTYPE yylval;
 
-#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
+/* Number of syntax errors so far.  */
+int yynerrs;
+
+
+
+/*----------.
+| yyparse.  |
+`----------*/
+
+#ifdef YYPARSE_PARAM
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void *YYPARSE_PARAM)
 #else
-#define YYPOPSTACK   (yyvsp--, yyssp--)
+int
+yyparse (YYPARSE_PARAM)
+    void *YYPARSE_PARAM;
 #endif
+#else /* ! YYPARSE_PARAM */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void)
+#else
+int
+yyparse ()
 
-  int yystacksize = YYINITDEPTH;
-  int yyfree_stacks = 0;
-
-#ifdef YYPURE
-  int yychar;
-  YYSTYPE yylval;
-  int yynerrs;
-#ifdef YYLSP_NEEDED
-  YYLTYPE yylloc;
 #endif
 #endif
+{
+  
+  int yystate;
+  int yyn;
+  int yyresult;
+  /* Number of tokens to shift before error messages enabled.  */
+  int yyerrstatus;
+  /* Look-ahead token as an internal (translated) token number.  */
+  int yytoken = 0;
+#if YYERROR_VERBOSE
+  /* Buffer for error messages, and its allocated size.  */
+  char yymsgbuf[128];
+  char *yymsg = yymsgbuf;
+  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
 
-  YYSTYPE yyval;		/*  the variable used to return		*/
-				/*  semantic values from the action	*/
-				/*  routines				*/
+  /* Three stacks and their tools:
+     `yyss': related to states,
+     `yyvs': related to semantic values,
+     `yyls': related to locations.
 
-  int yylen;
+     Refer to the stacks thru separate pointers, to allow yyoverflow
+     to reallocate them elsewhere.  */
 
-#if YYDEBUG != 0
-  if (yydebug)
-    fprintf(stderr, "Starting parse\n");
-#endif
+  /* The state stack.  */
+  yytype_int16 yyssa[YYINITDEPTH];
+  yytype_int16 *yyss = yyssa;
+  yytype_int16 *yyssp;
 
+  /* The semantic value stack.  */
+  YYSTYPE yyvsa[YYINITDEPTH];
+  YYSTYPE *yyvs = yyvsa;
+  YYSTYPE *yyvsp;
+
+
+
+#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
+
+  YYSIZE_T yystacksize = YYINITDEPTH;
+
+  /* The variables used to return semantic value and location from the
+     action routines.  */
+  YYSTYPE yyval;
+
+
+  /* The number of symbols on the RHS of the reduced rule.
+     Keep to zero when no symbol should be popped.  */
+  int yylen = 0;
+
+  YYDPRINTF ((stderr, "Starting parse\n"));
+
   yystate = 0;
   yyerrstatus = 0;
   yynerrs = 0;
@@ -480,546 +1171,497 @@
      so that they stay on the same level as the state stack.
      The wasted elements are never initialized.  */
 
-  yyssp = yyss - 1;
+  yyssp = yyss;
   yyvsp = yyvs;
-#ifdef YYLSP_NEEDED
-  yylsp = yyls;
-#endif
 
-/* Push a new state, which is found in  yystate  .  */
-/* In all cases, when you get here, the value and location stacks
-   have just been pushed. so pushing a state here evens the stacks.  */
-yynewstate:
+  goto yysetstate;
 
-  *++yyssp = yystate;
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate.  |
+`------------------------------------------------------------*/
+ yynewstate:
+  /* In all cases, when you get here, the value and location stacks
+     have just been pushed.  So pushing a state here evens the stacks.  */
+  yyssp++;
 
-  if (yyssp >= yyss + yystacksize - 1)
+ yysetstate:
+  *yyssp = yystate;
+
+  if (yyss + yystacksize - 1 <= yyssp)
     {
-      /* Give user a chance to reallocate the stack */
-      /* Use copies of these so that the &'s don't force the real ones into memory. */
-      YYSTYPE *yyvs1 = yyvs;
-      short *yyss1 = yyss;
-#ifdef YYLSP_NEEDED
-      YYLTYPE *yyls1 = yyls;
-#endif
-
       /* Get the current used size of the three stacks, in elements.  */
-      int size = yyssp - yyss + 1;
+      YYSIZE_T yysize = yyssp - yyss + 1;
 
 #ifdef yyoverflow
-      /* Each stack pointer address is followed by the size of
-	 the data in use in that stack, in bytes.  */
-#ifdef YYLSP_NEEDED
-      /* This used to be a conditional around just the two extra args,
-	 but that might be undefined if yyoverflow is a macro.  */
-      yyoverflow("parser stack overflow",
-		 &yyss1, size * sizeof (*yyssp),
-		 &yyvs1, size * sizeof (*yyvsp),
-		 &yyls1, size * sizeof (*yylsp),
-		 &yystacksize);
-#else
-      yyoverflow("parser stack overflow",
-		 &yyss1, size * sizeof (*yyssp),
-		 &yyvs1, size * sizeof (*yyvsp),
-		 &yystacksize);
-#endif
+      {
+	/* Give user a chance to reallocate the stack.  Use copies of
+	   these so that the &'s don't force the real ones into
+	   memory.  */
+	YYSTYPE *yyvs1 = yyvs;
+	yytype_int16 *yyss1 = yyss;
 
-      yyss = yyss1; yyvs = yyvs1;
-#ifdef YYLSP_NEEDED
-      yyls = yyls1;
-#endif
+
+	/* Each stack pointer address is followed by the size of the
+	   data in use in that stack, in bytes.  This used to be a
+	   conditional around just the two extra args, but that might
+	   be undefined if yyoverflow is a macro.  */
+	yyoverflow (YY_("memory exhausted"),
+		    &yyss1, yysize * sizeof (*yyssp),
+		    &yyvs1, yysize * sizeof (*yyvsp),
+
+		    &yystacksize);
+
+	yyss = yyss1;
+	yyvs = yyvs1;
+      }
 #else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+      goto yyexhaustedlab;
+# else
       /* Extend the stack our own way.  */
-      if (yystacksize >= YYMAXDEPTH)
-	{
-	  yyerror("parser stack overflow");
-	  if (yyfree_stacks)
-	    {
-	      free (yyss);
-	      free (yyvs);
-#ifdef YYLSP_NEEDED
-	      free (yyls);
-#endif
-	    }
-	  return 2;
-	}
+      if (YYMAXDEPTH <= yystacksize)
+	goto yyexhaustedlab;
       yystacksize *= 2;
-      if (yystacksize > YYMAXDEPTH)
+      if (YYMAXDEPTH < yystacksize)
 	yystacksize = YYMAXDEPTH;
-#ifndef YYSTACK_USE_ALLOCA
-      yyfree_stacks = 1;
-#endif
-      yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
-      __yy_memcpy ((char *)yyss, (char *)yyss1,
-		   size * (unsigned int) sizeof (*yyssp));
-      yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
-      __yy_memcpy ((char *)yyvs, (char *)yyvs1,
-		   size * (unsigned int) sizeof (*yyvsp));
-#ifdef YYLSP_NEEDED
-      yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
-      __yy_memcpy ((char *)yyls, (char *)yyls1,
-		   size * (unsigned int) sizeof (*yylsp));
-#endif
+
+      {
+	yytype_int16 *yyss1 = yyss;
+	union yyalloc *yyptr =
+	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+	if (! yyptr)
+	  goto yyexhaustedlab;
+	YYSTACK_RELOCATE (yyss);
+	YYSTACK_RELOCATE (yyvs);
+
+#  undef YYSTACK_RELOCATE
+	if (yyss1 != yyssa)
+	  YYSTACK_FREE (yyss1);
+      }
+# endif
 #endif /* no yyoverflow */
 
-      yyssp = yyss + size - 1;
-      yyvsp = yyvs + size - 1;
-#ifdef YYLSP_NEEDED
-      yylsp = yyls + size - 1;
-#endif
+      yyssp = yyss + yysize - 1;
+      yyvsp = yyvs + yysize - 1;
 
-#if YYDEBUG != 0
-      if (yydebug)
-	fprintf(stderr, "Stack size increased to %d\n", yystacksize);
-#endif
 
-      if (yyssp >= yyss + yystacksize - 1)
+      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+		  (unsigned long int) yystacksize));
+
+      if (yyss + yystacksize - 1 <= yyssp)
 	YYABORT;
     }
 
-#if YYDEBUG != 0
-  if (yydebug)
-    fprintf(stderr, "Entering state %d\n", yystate);
-#endif
+  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
 
   goto yybackup;
- yybackup:
 
-/* Do appropriate processing given the current state.  */
-/* Read a lookahead token if we need one and don't already have one.  */
-/* yyresume: */
+/*-----------.
+| yybackup.  |
+`-----------*/
+yybackup:
 
-  /* First try to decide what to do without reference to lookahead token.  */
+  /* Do appropriate processing given the current state.  Read a
+     look-ahead token if we need one and don't already have one.  */
 
+  /* First try to decide what to do without reference to look-ahead token.  */
   yyn = yypact[yystate];
-  if (yyn == YYFLAG)
+  if (yyn == YYPACT_NINF)
     goto yydefault;
 
-  /* Not known => get a lookahead token if don't already have one.  */
+  /* Not known => get a look-ahead token if don't already have one.  */
 
-  /* yychar is either YYEMPTY or YYEOF
-     or a valid token in external form.  */
-
+  /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
   if (yychar == YYEMPTY)
     {
-#if YYDEBUG != 0
-      if (yydebug)
-	fprintf(stderr, "Reading a token: ");
-#endif
+      YYDPRINTF ((stderr, "Reading a token: "));
       yychar = YYLEX;
     }
 
-  /* Convert token to internal form (in yychar1) for indexing tables with */
-
-  if (yychar <= 0)		/* This means end of input. */
+  if (yychar <= YYEOF)
     {
-      yychar1 = 0;
-      yychar = YYEOF;		/* Don't call YYLEX any more */
-
-#if YYDEBUG != 0
-      if (yydebug)
-	fprintf(stderr, "Now at end of input.\n");
-#endif
+      yychar = yytoken = YYEOF;
+      YYDPRINTF ((stderr, "Now at end of input.\n"));
     }
   else
     {
-      yychar1 = YYTRANSLATE(yychar);
-
-#if YYDEBUG != 0
-      if (yydebug)
-	{
-	  fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
-	  /* Give the individual parser a way to print the precise meaning
-	     of a token, for further debugging info.  */
-#ifdef YYPRINT
-	  YYPRINT (stderr, yychar, yylval);
-#endif
-	  fprintf (stderr, ")\n");
-	}
-#endif
+      yytoken = YYTRANSLATE (yychar);
+      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
     }
 
-  yyn += yychar1;
-  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
+  /* If the proper action on seeing token YYTOKEN is to reduce or to
+     detect an error, take that action.  */
+  yyn += yytoken;
+  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
     goto yydefault;
-
   yyn = yytable[yyn];
-
-  /* yyn is what to do for this token type in this state.
-     Negative => reduce, -yyn is rule number.
-     Positive => shift, yyn is new state.
-       New state is final state => don't bother to shift,
-       just return success.
-     0, or most negative number => error.  */
-
-  if (yyn < 0)
+  if (yyn <= 0)
     {
-      if (yyn == YYFLAG)
+      if (yyn == 0 || yyn == YYTABLE_NINF)
 	goto yyerrlab;
       yyn = -yyn;
       goto yyreduce;
     }
-  else if (yyn == 0)
-    goto yyerrlab;
 
   if (yyn == YYFINAL)
     YYACCEPT;
 
-  /* Shift the lookahead token.  */
+  /* Count tokens shifted since error; after three, turn off error
+     status.  */
+  if (yyerrstatus)
+    yyerrstatus--;
 
-#if YYDEBUG != 0
-  if (yydebug)
-    fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
-#endif
+  /* Shift the look-ahead token.  */
+  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
 
-  /* Discard the token being shifted unless it is eof.  */
+  /* Discard the shifted token unless it is eof.  */
   if (yychar != YYEOF)
     yychar = YYEMPTY;
 
+  yystate = yyn;
   *++yyvsp = yylval;
-#ifdef YYLSP_NEEDED
-  *++yylsp = yylloc;
-#endif
 
-  /* count tokens shifted since error; after three, turn off error status.  */
-  if (yyerrstatus) yyerrstatus--;
-
-  yystate = yyn;
   goto yynewstate;
 
-/* Do the default action for the current state.  */
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state.  |
+`-----------------------------------------------------------*/
 yydefault:
-
   yyn = yydefact[yystate];
   if (yyn == 0)
     goto yyerrlab;
+  goto yyreduce;
 
-/* Do a reduction.  yyn is the number of a rule to reduce with.  */
+
+/*-----------------------------.
+| yyreduce -- Do a reduction.  |
+`-----------------------------*/
 yyreduce:
+  /* yyn is the number of a rule to reduce with.  */
   yylen = yyr2[yyn];
-  if (yylen > 0)
-    yyval = yyvsp[1-yylen]; /* implement default value of the action */
 
-#if YYDEBUG != 0
-  if (yydebug)
-    {
-      int i;
+  /* If YYLEN is nonzero, implement the default value of the action:
+     `$$ = $1'.
 
-      fprintf (stderr, "Reducing via rule %d (line %d), ",
-	       yyn, yyrline[yyn]);
+     Otherwise, the following line sets YYVAL to garbage.
+     This behavior is undocumented and Bison
+     users should not rely upon it.  Assigning to YYVAL
+     unconditionally makes the parser a bit smaller, and it avoids a
+     GCC warning that YYVAL may be used uninitialized.  */
+  yyval = yyvsp[1-yylen];
 
-      /* Print the symbols being reduced, and their result.  */
-      for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
-	fprintf (stderr, "%s ", yytname[yyrhs[i]]);
-      fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
-    }
-#endif
 
+  YY_REDUCE_PRINT (yyn);
+  switch (yyn)
+    {
+        case 5:
+#line 56 "calc.yy"
+    { formula = f((yyvsp[(1) - (2)])); return 0; }
+    break;
 
-  switch (yyn) {
+  case 6:
+#line 59 "calc.yy"
+    {
+	        (yyval) = formulas.size();
+	        formulas.push_back(new CalcFormula(new CalcNumber((yyvsp[(1) - (1)]))));
+        }
+    break;
 
-case 4:
-#line 56 "calc.yy"
-{ formula = f(yyvsp[-1]); return 0; ;
-    break;}
-case 5:
-#line 59 "calc.yy"
-{
-	        yyval = formulas.size();
-	        formulas.push_back(new CalcFormula(new CalcNumber(yyvsp[0])));
-        ;
-    break;}
-case 6:
+  case 7:
 #line 63 "calc.yy"
-{
-	        yyval = formulas.size();
+    {
+	        (yyval) = formulas.size();
             formulas.push_back(new CalcFormula(new CalcRandom()));
-        ;
-    break;}
-case 7:
+        }
+    break;
+
+  case 8:
 #line 67 "calc.yy"
-{
-			yyval = formulas.size();
+    {
+			(yyval) = formulas.size();
 			formulas.push_back(new CalcFormula(new CalcRank()));
-		;
-    break;}
-case 8:
+		}
+    break;
+
+  case 9:
 #line 71 "calc.yy"
-{
-			yyval = formulas.size();
+    {
+			(yyval) = formulas.size();
 			formulas.push_back(new CalcFormula(new CalcParam(paramId)));
-		;
-    break;}
-case 9:
+		}
+    break;
+
+  case 10:
 #line 75 "calc.yy"
-{
-		    yyval = formulas.size();
-			formulas.push_back(new CalcFormula(f(yyvsp[-2]), op_add, f(yyvsp[0])));
-		;
-    break;}
-case 10:
+    {
+		    (yyval) = formulas.size();
+			formulas.push_back(new CalcFormula(f((yyvsp[(1) - (3)])), op_add, f((yyvsp[(3) - (3)]))));
+		}
+    break;
+
+  case 11:
 #line 79 "calc.yy"
-{
-		    yyval = formulas.size();
-			formulas.push_back(new CalcFormula(f(yyvsp[-2]), op_sub, f(yyvsp[0])));
-		;
-    break;}
-case 11:
+    {
+		    (yyval) = formulas.size();
+			formulas.push_back(new CalcFormula(f((yyvsp[(1) - (3)])), op_sub, f((yyvsp[(3) - (3)]))));
+		}
+    break;
+
+  case 12:
 #line 83 "calc.yy"
-{
-		    yyval = formulas.size();
-			formulas.push_back(new CalcFormula(f(yyvsp[-2]), op_mul, f(yyvsp[0])));
-		;
-    break;}
-case 12:
+    {
+		    (yyval) = formulas.size();
+			formulas.push_back(new CalcFormula(f((yyvsp[(1) - (3)])), op_mul, f((yyvsp[(3) - (3)]))));
+		}
+    break;
+
+  case 13:
 #line 87 "calc.yy"
-{
-		    yyval = formulas.size();
-			formulas.push_back(new CalcFormula(f(yyvsp[-2]), op_div, f(yyvsp[0])));
-		;
-    break;}
-case 13:
+    {
+		    (yyval) = formulas.size();
+			formulas.push_back(new CalcFormula(f((yyvsp[(1) - (3)])), op_div, f((yyvsp[(3) - (3)]))));
+		}
+    break;
+
+  case 14:
 #line 91 "calc.yy"
-{
-		    yyval = yyvsp[0];
-			f(yyvsp[0])->setHeadSub();
-		;
-    break;}
-case 14:
+    {
+		    (yyval) = (yyvsp[(2) - (2)]);
+			f((yyvsp[(2) - (2)]))->setHeadSub();
+		}
+    break;
+
+  case 15:
 #line 95 "calc.yy"
-{
-		    yyval = yyvsp[-1];
-		;
-    break;}
-}
-   /* the action file gets copied in in place of this dollarsign */
-#line 543 "/usr/lib/bison.simple"
-
-  yyvsp -= yylen;
-  yyssp -= yylen;
-#ifdef YYLSP_NEEDED
-  yylsp -= yylen;
-#endif
+    {
+		    (yyval) = (yyvsp[(2) - (3)]);
+		}
+    break;
 
-#if YYDEBUG != 0
-  if (yydebug)
-    {
-      short *ssp1 = yyss - 1;
-      fprintf (stderr, "state stack now");
-      while (ssp1 != yyssp)
-	fprintf (stderr, " %d", *++ssp1);
-      fprintf (stderr, "\n");
+
+/* Line 1267 of yacc.c.  */
+#line 1445 "y.tab.c"
+      default: break;
     }
-#endif
+  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
 
+  YYPOPSTACK (yylen);
+  yylen = 0;
+  YY_STACK_PRINT (yyss, yyssp);
+
   *++yyvsp = yyval;
 
-#ifdef YYLSP_NEEDED
-  yylsp++;
-  if (yylen == 0)
-    {
-      yylsp->first_line = yylloc.first_line;
-      yylsp->first_column = yylloc.first_column;
-      yylsp->last_line = (yylsp-1)->last_line;
-      yylsp->last_column = (yylsp-1)->last_column;
-      yylsp->text = 0;
-    }
-  else
-    {
-      yylsp->last_line = (yylsp+yylen-1)->last_line;
-      yylsp->last_column = (yylsp+yylen-1)->last_column;
-    }
-#endif
 
-  /* Now "shift" the result of the reduction.
-     Determine what state that goes to,
-     based on the state we popped back to
-     and the rule number reduced by.  */
+  /* Now `shift' the result of the reduction.  Determine what state
+     that goes to, based on the state we popped back to and the rule
+     number reduced by.  */
 
   yyn = yyr1[yyn];
 
-  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
-  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
     yystate = yytable[yystate];
   else
-    yystate = yydefgoto[yyn - YYNTBASE];
+    yystate = yydefgoto[yyn - YYNTOKENS];
 
   goto yynewstate;
 
-yyerrlab:   /* here on detecting error */
 
-  if (! yyerrstatus)
-    /* If not already recovering from an error, report this error.  */
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
+yyerrlab:
+  /* If not already recovering from an error, report this error.  */
+  if (!yyerrstatus)
     {
       ++yynerrs;
+#if ! YYERROR_VERBOSE
+      yyerror (YY_("syntax error"));
+#else
+      {
+	YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
+	if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
+	  {
+	    YYSIZE_T yyalloc = 2 * yysize;
+	    if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
+	      yyalloc = YYSTACK_ALLOC_MAXIMUM;
+	    if (yymsg != yymsgbuf)
+	      YYSTACK_FREE (yymsg);
+	    yymsg = (char *) YYSTACK_ALLOC (yyalloc);
+	    if (yymsg)
+	      yymsg_alloc = yyalloc;
+	    else
+	      {
+		yymsg = yymsgbuf;
+		yymsg_alloc = sizeof yymsgbuf;
+	      }
+	  }
 
-#ifdef YYERROR_VERBOSE
-      yyn = yypact[yystate];
+	if (0 < yysize && yysize <= yymsg_alloc)
+	  {
+	    (void) yysyntax_error (yymsg, yystate, yychar);
+	    yyerror (yymsg);
+	  }
+	else
+	  {
+	    yyerror (YY_("syntax error"));
+	    if (yysize != 0)
+	      goto yyexhaustedlab;
+	  }
+      }
+#endif
+    }
 
-      if (yyn > YYFLAG && yyn < YYLAST)
-	{
-	  int size = 0;
-	  char *msg;
-	  int x, count;
 
-	  count = 0;
-	  /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
-	  for (x = (yyn < 0 ? -yyn : 0);
-	       x < (sizeof(yytname) / sizeof(char *)); x++)
-	    if (yycheck[x + yyn] == x)
-	      size += strlen(yytname[x]) + 15, count++;
-	  msg = (char *) malloc(size + 15);
-	  if (msg != 0)
-	    {
-	      strcpy(msg, "parse error");
 
-	      if (count < 5)
-		{
-		  count = 0;
-		  for (x = (yyn < 0 ? -yyn : 0);
-		       x < (sizeof(yytname) / sizeof(char *)); x++)
-		    if (yycheck[x + yyn] == x)
-		      {
-			strcat(msg, count == 0 ? ", expecting `" : " or `");
-			strcat(msg, yytname[x]);
-			strcat(msg, "'");
-			count++;
-		      }
-		}
-	      yyerror(msg);
-	      free(msg);
-	    }
-	  else
-	    yyerror ("parse error; also virtual memory exceeded");
+  if (yyerrstatus == 3)
+    {
+      /* If just tried and failed to reuse look-ahead token after an
+	 error, discard it.  */
+
+      if (yychar <= YYEOF)
+	{
+	  /* Return failure if at end of input.  */
+	  if (yychar == YYEOF)
+	    YYABORT;
 	}
       else
-#endif /* YYERROR_VERBOSE */
-	yyerror("parse error");
+	{
+	  yydestruct ("Error: discarding",
+		      yytoken, &yylval);
+	  yychar = YYEMPTY;
+	}
     }
 
+  /* Else will try to reuse look-ahead token after shifting the error
+     token.  */
   goto yyerrlab1;
-yyerrlab1:   /* here on error raised explicitly by an action */
 
-  if (yyerrstatus == 3)
-    {
-      /* if just tried and failed to reuse lookahead token after an error, discard it.  */
 
-      /* return failure if at end of input */
-      if (yychar == YYEOF)
-	YYABORT;
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR.  |
+`---------------------------------------------------*/
+yyerrorlab:
 
-#if YYDEBUG != 0
-      if (yydebug)
-	fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
-#endif
+  /* Pacify compilers like GCC when the user code never invokes
+     YYERROR and the label yyerrorlab therefore never appears in user
+     code.  */
+  if (/*CONSTCOND*/ 0)
+     goto yyerrorlab;
 
-      yychar = YYEMPTY;
-    }
+  /* Do not reclaim the symbols of the rule which action triggered
+     this YYERROR.  */
+  YYPOPSTACK (yylen);
+  yylen = 0;
+  YY_STACK_PRINT (yyss, yyssp);
+  yystate = *yyssp;
+  goto yyerrlab1;
 
-  /* Else will try to reuse lookahead token
-     after shifting the error token.  */
 
-  yyerrstatus = 3;		/* Each real token shifted decrements this */
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR.  |
+`-------------------------------------------------------------*/
+yyerrlab1:
+  yyerrstatus = 3;	/* Each real token shifted decrements this.  */
 
-  goto yyerrhandle;
-
-yyerrdefault:  /* current state does not do anything special for the error token. */
-
-#if 0
-  /* This is wrong; only states that explicitly want error tokens
-     should shift them.  */
-  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
-  if (yyn) goto yydefault;
-#endif
-
-yyerrpop:   /* pop the current state because it cannot handle the error token */
-
-  if (yyssp == yyss) YYABORT;
-  yyvsp--;
-  yystate = *--yyssp;
-#ifdef YYLSP_NEEDED
-  yylsp--;
-#endif
-
-#if YYDEBUG != 0
-  if (yydebug)
+  for (;;)
     {
-      short *ssp1 = yyss - 1;
-      fprintf (stderr, "Error: state stack now");
-      while (ssp1 != yyssp)
-	fprintf (stderr, " %d", *++ssp1);
-      fprintf (stderr, "\n");
-    }
-#endif
+      yyn = yypact[yystate];
+      if (yyn != YYPACT_NINF)
+	{
+	  yyn += YYTERROR;
+	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+	    {
+	      yyn = yytable[yyn];
+	      if (0 < yyn)
+		break;
+	    }
+	}
 
-yyerrhandle:
+      /* Pop the current state because it cannot handle the error token.  */
+      if (yyssp == yyss)
+	YYABORT;
 
-  yyn = yypact[yystate];
-  if (yyn == YYFLAG)
-    goto yyerrdefault;
 
-  yyn += YYTERROR;
-  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
-    goto yyerrdefault;
-
-  yyn = yytable[yyn];
-  if (yyn < 0)
-    {
-      if (yyn == YYFLAG)
-	goto yyerrpop;
-      yyn = -yyn;
-      goto yyreduce;
+      yydestruct ("Error: popping",
+		  yystos[yystate], yyvsp);
+      YYPOPSTACK (1);
+      yystate = *yyssp;
+      YY_STACK_PRINT (yyss, yyssp);
     }
-  else if (yyn == 0)
-    goto yyerrpop;
 
   if (yyn == YYFINAL)
     YYACCEPT;
 
-#if YYDEBUG != 0
-  if (yydebug)
-    fprintf(stderr, "Shifting error token, ");
-#endif
-
   *++yyvsp = yylval;
-#ifdef YYLSP_NEEDED
-  *++yylsp = yylloc;
-#endif
 
+
+  /* Shift the error token.  */
+  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
+
   yystate = yyn;
   goto yynewstate;
 
- yyacceptlab:
-  /* YYACCEPT comes here.  */
-  if (yyfree_stacks)
-    {
-      free (yyss);
-      free (yyvs);
-#ifdef YYLSP_NEEDED
-      free (yyls);
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here.  |
+`-------------------------------------*/
+yyacceptlab:
+  yyresult = 0;
+  goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here.  |
+`-----------------------------------*/
+yyabortlab:
+  yyresult = 1;
+  goto yyreturn;
+
+#ifndef yyoverflow
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here.  |
+`-------------------------------------------------*/
+yyexhaustedlab:
+  yyerror (YY_("memory exhausted"));
+  yyresult = 2;
+  /* Fall through.  */
 #endif
-    }
-  return 0;
 
- yyabortlab:
-  /* YYABORT comes here.  */
-  if (yyfree_stacks)
+yyreturn:
+  if (yychar != YYEOF && yychar != YYEMPTY)
+     yydestruct ("Cleanup: discarding lookahead",
+		 yytoken, &yylval);
+  /* Do not reclaim the symbols of the rule which action triggered
+     this YYABORT or YYACCEPT.  */
+  YYPOPSTACK (yylen);
+  YY_STACK_PRINT (yyss, yyssp);
+  while (yyssp != yyss)
     {
-      free (yyss);
-      free (yyvs);
-#ifdef YYLSP_NEEDED
-      free (yyls);
+      yydestruct ("Cleanup: popping",
+		  yystos[*yyssp], yyvsp);
+      YYPOPSTACK (1);
+    }
+#ifndef yyoverflow
+  if (yyss != yyssa)
+    YYSTACK_FREE (yyss);
 #endif
-    }
-  return 1;
+#if YYERROR_VERBOSE
+  if (yymsg != yymsgbuf)
+    YYSTACK_FREE (yymsg);
+#endif
+  /* Make sure YYID is used.  */
+  return YYID (yyresult);
 }
+
+
 #line 99 "calc.yy"
 
 
 /**
- * Žš‹å‰ðÍŠí‚́A”’l‚ð“ǂ߂΁AdoubleŒ^‚Ì’l‚ðƒXƒ^ƒbƒN‚ɐςñ‚Å
- * ƒg[ƒNƒ“uNUMv‚ð•Ô‚µA”’lˆÈŠO‚ð“ǂ߂΁A‚»‚Ì•¶Žš‚̃AƒXƒL[•„†‚ð•Ô‚·B
- * ‹ó”’‚ƃ^ƒu‚Í“Ç‚Ý”ò‚΂³‚ê‚éBƒtƒ@ƒCƒ‹‚ªI‚í‚é‚Æ0‚ð•Ô‚·B
+ * »ú¶ç²òÀÏ´ï¤Ï¡¢¿ôÃͤòÆɤá¤Ð¡¢double·¿¤ÎÃͤò¥¹¥¿¥Ã¥¯¤ËÀѤó¤Ç
+ * ¥È¡¼¥¯¥ó¡ÖNUM¡×¤òÊÖ¤·¡¢¿ôÃͰʳ°¤òÆɤá¤Ð¡¢¤½¤Îʸ»ú¤Î¥¢¥¹¥­¡¼Éä¹æ¤òÊÖ¤¹¡£
+ * ¶õÇò¤È¥¿¥Ö¤ÏÆɤßÈô¤Ð¤µ¤ì¤ë¡£¥Õ¥¡¥¤¥ë¤¬½ª¤ï¤ë¤È0¤òÊÖ¤¹¡£
  */
 
 #include <ctype.h>
@@ -1029,10 +1671,10 @@
 {
 	int c;
 
-	/* ‹ó”’—Þ‚ð“Ç‚Ý”ò‚΂·  */
+	/* ¶õÇòÎà¤òÆɤßÈô¤Ð¤¹  */
 	while ((c = *(yyinStr++)) == ' ' || c == '\t')
 		;
-	/* ”’l‚ðˆ—‚·‚é   */
+	/* ¿ôÃͤò½èÍý¤¹¤ë   */
 	if (c == '.' || isdigit (c))
     {
 		yyinStr--;
@@ -1041,7 +1683,7 @@
 		return NUM;
     }
 
-	// •Ï”‚ðˆ—‚·‚é */
+	// ÊÑ¿ô¤ò½èÍý¤¹¤ë */
 	if (c == '$') {
 		if (strncmp(yyinStr, "rand", 4) == 0) {
 			yyinStr += 4;
@@ -1059,10 +1701,10 @@
 		}
 	}
 
-	/* ƒtƒ@ƒCƒ‹‚̏I‚í‚è‚ðˆ—‚·‚é  */
+	/* ¥Õ¥¡¥¤¥ë¤Î½ª¤ï¤ê¤ò½èÍý¤¹¤ë  */
 	if (c == '\0')
 		return 0;
-	/* 1•¶Žš‚ð•Ô‚· */
+	/* 1ʸ»ú¤òÊÖ¤¹ */
 	return c;
 }
 
@@ -1078,3 +1720,4 @@
 	return std::auto_ptr<CalcFormula>(formula);
 }
 
+

Modified: trunk/user/games/noiz2sa/src/bulletml/tinyxml/Makefile
===================================================================
--- tags/noiz2sa/noiz2sa-0.51a/src/bulletml/tinyxml/Makefile	2008-04-05 00:17:39 UTC (rev 2211)
+++ trunk/user/games/noiz2sa/src/bulletml/tinyxml/Makefile	2008-04-07 17:17:30 UTC (rev 2230)
@@ -15,11 +15,11 @@
 
 #****************************************************************************
 
-CC     := gcc
-CXX    := g++
-LD     := g++
-AR     := ar rc
-RANLIB := ranlib
+#CC     := gcc
+#CXX    := g++
+#LD     := g++
+#AR     := ar rc
+#RANLIB := ranlib
 
 DEBUG_CFLAGS     := -Wall -Wno-unknown-pragmas -Wno-format -g -DDEBUG
 RELEASE_CFLAGS   := -Wall -Wno-unknown-pragmas -Wno-format -O2
@@ -98,21 +98,22 @@
 #****************************************************************************
 
 ${OUTPUT}: ${OBJS}
-	${LD} -o $@ ${LDFLAGS} ${OBJS} ${LIBS} ${EXTRA_LIBS}
+	#${LD} -o $@ ${LDFLAGS} ${OBJS} ${LIBS} ${EXTRA_LIBS}
+	 $(CXX) -o $@ $(CXXFLAGS) $(INCS) $(CRTBEGIN) $(LDFLAGS) $(OBJS) $(CXXLIBS) $(LDLIBS) $(CRTEND)
 
+
 #****************************************************************************
 # common rules
 #****************************************************************************
 
 # Rules for compiling source files to object files
 %.o : %.cpp
-	${CXX} -c ${CXXFLAGS} ${INCS} $< -o $@
-
+	$(CXX) -c $(CXXFLAGS) -o $@ $<
 %.o : %.c
 	${CC} -c ${CFLAGS} ${INCS} $< -o $@
 
 clean:
-	-rm -f core ${OBJS} ${OUTPUT}
+	-rm -f core ${OBJS} ${OUTPUT} $(OUTPUT).gdb
 
 depend:
 	makedepend ${INCS} ${SRCS}

Deleted: trunk/user/games/noiz2sa/src/foe.cc

Added: trunk/user/games/noiz2sa/src/foe.cpp

Deleted: trunk/user/games/noiz2sa/src/foecommand.cc

Added: trunk/user/games/noiz2sa/src/foecommand.cpp

Modified: trunk/user/games/noiz2sa/src/frag.c
===================================================================
--- tags/noiz2sa/noiz2sa-0.51a/src/frag.c	2008-04-05 00:17:39 UTC (rev 2211)
+++ trunk/user/games/noiz2sa/src/frag.c	2008-04-07 17:17:30 UTC (rev 2230)
@@ -1,150 +1,150 @@
-/*
- * $Id: frag.c,v 1.1.1.1 2002/11/03 11:08:24 kenta Exp $
- *
- * Copyright 2002 Kenta Cho. All rights reserved.
- */
-
-/**
- * Fragments.
- *
- * @version $Revision: 1.1.1.1 $
- */
-#include "SDL.h"
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "noiz2sa.h"
-#include "screen.h"
-#include "vector.h"
-#include "degutil.h"
-#include "shot.h"
-#include "frag.h"
-
-Frag frag[FRAG_MAX];
-
-void initFrags() {
-  int i;
-  for ( i=0 ; i<FRAG_MAX ; i++ ) {
-    frag[i].cnt = 0;
-  }
-}
-
-static int fragIdx = FRAG_MAX;
-
-static void addFrag(Vector *pos, Vector *vel, int spc, int size) {
-  int i;
-  for ( i=0 ; i<FRAG_MAX ; i++ ) {
-    fragIdx--; if ( fragIdx < 0 ) fragIdx = FRAG_MAX-1;
-    if ( frag[i].cnt <= 0 ) break;
-  }
-  if ( i >= FRAG_MAX ) return;
-  frag[i].pos = *pos;
-  frag[i].vel = *vel;
-  switch ( spc ) {
-  case 0:
-    frag[i].width = 5+randN(10);
-    frag[i].height = 5+randN(10);
-    frag[i].cnt = 4+randN(8);
-    break;
-  case 1:
-    frag[i].width = size*5+randN(size*3);
-    frag[i].height = size*5+randN(size*3);
-    frag[i].cnt = 12+randN(12);
-    break;
-  case 2:
-    frag[i].width = 4;
-    frag[i].height = 4;
-    frag[i].cnt = 10+randN(4);
-    break;
-  }
-  frag[i].spc = spc;
-}
-
-void addShotFrag(Vector *p) {
-  Vector pos, vel;
-  pos.x = (p->x/SCAN_WIDTH*LAYER_WIDTH)>>8;
-  pos.y = (p->y/SCAN_HEIGHT*LAYER_HEIGHT)>>8;
-  vel.x = randNS(SHOT_SPEED>>11)*LAYER_WIDTH/SCAN_WIDTH;
-  vel.y = (-(SHOT_SPEED>>8) + randNS(SHOT_SPEED>>11))*LAYER_HEIGHT/SCAN_HEIGHT;
-  addFrag(&pos, &vel, 0, 0);
-}
-
-void addEnemyFrag(Vector *p, int mx, int my, int type) {
-  Vector pos, vel;
-  int cmx, cmy;
-  int i;
-  pos.x = (p->x/SCAN_WIDTH*LAYER_WIDTH)>>8;
-  pos.y = (p->y/SCAN_HEIGHT*LAYER_HEIGHT)>>8;
-  cmx = (mx/SCAN_WIDTH*LAYER_WIDTH)>>8;
-  cmy = (my/SCAN_HEIGHT*LAYER_HEIGHT)>>8;
-  type = type*2+1;
-  for ( i=0 ; i<type+randN(type*2) ; i++ ) {
-    vel.x = randNS(16);
-    vel.y = randNS(16);
-    addFrag(&pos, &vel, 0, 0);
-  }
-  for ( i=0 ; i<type*2+randN(type) ; i++ ) {
-    vel.x = cmx+randNS(3);
-    vel.y = cmy+randNS(3);
-    addFrag(&pos, &vel, 1, 2+type);
-  }
-}
-
-void addShipFrag(Vector *p) {
-  Vector pos, vel;
-  int cmx, cmy;
-  int i;
-  pos.x = (p->x/SCAN_WIDTH*LAYER_WIDTH)>>8;
-  pos.y = (p->y/SCAN_HEIGHT*LAYER_HEIGHT)>>8;
-  for ( i=0 ; i<48 ; i++ ) {
-    vel.x = randNS(24);
-    vel.y = randNS(24);
-    addFrag(&pos, &vel, 0, 0);
-  }
-  for ( i=0 ; i<32 ; i++ ) {
-    vel.x = randNS(4);
-    vel.y = randNS(4);
-    addFrag(&pos, &vel, 1, 1+randN(6));
-  }
-}
-
-void addClearFrag(Vector *p, Vector *v) {
-  Vector pos, vel;
-  pos.x = (p->x/SCAN_WIDTH*LAYER_WIDTH)>>8;
-  pos.y = (p->y/SCAN_HEIGHT*LAYER_HEIGHT)>>8;
-  vel.x = (v->x/SCAN_WIDTH*LAYER_WIDTH)>>8;
-  vel.y = (v->y/SCAN_HEIGHT*LAYER_HEIGHT)>>8;
-  addFrag(&pos, &vel, 2, 0);
-}
-
-
-void moveFrags() {
-  int i;
-  Frag *fr;
-  for ( i=0 ; i<FRAG_MAX ; i++ ) {
-    if ( frag[i].cnt <= 0 ) continue;
-    fr = &(frag[i]);
-    fr->pos.x += fr->vel.x;
-    fr->pos.y += fr->vel.y;
-    fr->cnt--;
-  }
-}
-
-static int fragColor[3][2][2] = {
-  {{16*8-7, 16*2-2}, {16*2-7, 16*8-2}},
-  {{16*5-7, 16*2-2}, {16*2-7, 16*5-2}},
-  {{16*1-10, 16*1-5}, {16*1-5, 16*1-10}},
-};
-
-void drawFrags() {
-  int x, y, c;
-  int i;
-  Frag *fr;
-  for ( i=0 ; i<FRAG_MAX ; i++ ) {
-    if ( frag[i].cnt <= 0 ) continue;
-    fr = &(frag[i]);
-    c = fr->cnt&1;
-    drawBox(fr->pos.x, fr->pos.y, fr->width, fr->height, 
-	    fragColor[fr->spc][c][0],fragColor[fr->spc][c][1], l2buf);
-  }
-}
+/*
+ * $Id: frag.c,v 1.1.1.1 2002/11/03 11:08:24 kenta Exp $
+ *
+ * Copyright 2002 Kenta Cho. All rights reserved.
+ */
+
+/**
+ * Fragments.
+ *
+ * @version $Revision: 1.1.1.1 $
+ */
+#include "SDL.h"
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "noiz2sa.h"
+#include "screen.h"
+#include "vector.h"
+#include "degutil.h"
+#include "shot.h"
+#include "frag.h"
+
+Frag frag[FRAG_MAX];
+
+void initFrags() {
+  int i;
+  for ( i=0 ; i<FRAG_MAX ; i++ ) {
+    frag[i].cnt = 0;
+  }
+}
+
+static int fragIdx = FRAG_MAX;
+
+static void addFrag(Vector *pos, Vector *vel, int spc, int size) {
+  int i;
+  for ( i=0 ; i<FRAG_MAX ; i++ ) {
+    fragIdx--; if ( fragIdx < 0 ) fragIdx = FRAG_MAX-1;
+    if ( frag[i].cnt <= 0 ) break;
+  }
+  if ( i >= FRAG_MAX ) return;
+  frag[i].pos = *pos;
+  frag[i].vel = *vel;
+  switch ( spc ) {
+  case 0:
+    frag[i].width = (5+randN(10))/SCREEN_DIVISOR;
+    frag[i].height = (5+randN(10))/SCREEN_DIVISOR;
+    frag[i].cnt = 4+randN(8);
+    break;
+  case 1:
+    frag[i].width = (size*5+randN(size*3))/SCREEN_DIVISOR;
+    frag[i].height = (size*5+randN(size*3))/SCREEN_DIVISOR;
+    frag[i].cnt = 12+randN(12);
+    break;
+  case 2:
+    frag[i].width = 4/SCREEN_DIVISOR;
+    frag[i].height = 4/SCREEN_DIVISOR;
+    frag[i].cnt = 10+randN(4);
+    break;
+  }
+  frag[i].spc = spc;
+}
+
+void addShotFrag(Vector *p) {
+  Vector pos, vel;
+  pos.x = (p->x/SCAN_WIDTH*LAYER_WIDTH)>>8;
+  pos.y = (p->y/SCAN_HEIGHT*LAYER_HEIGHT)>>8;
+  vel.x = randNS(SHOT_SPEED>>11)*LAYER_WIDTH/SCAN_WIDTH;
+  vel.y = (-(SHOT_SPEED>>8) + randNS(SHOT_SPEED>>11))*LAYER_HEIGHT/SCAN_HEIGHT;
+  addFrag(&pos, &vel, 0, 0);
+}
+
+void addEnemyFrag(Vector *p, int mx, int my, int type) {
+  Vector pos, vel;
+  int cmx, cmy;
+  int i;
+  pos.x = (p->x/SCAN_WIDTH*LAYER_WIDTH)>>8;
+  pos.y = (p->y/SCAN_HEIGHT*LAYER_HEIGHT)>>8;
+  cmx = (mx/SCAN_WIDTH*LAYER_WIDTH)>>8;
+  cmy = (my/SCAN_HEIGHT*LAYER_HEIGHT)>>8;
+  type = type*2+1;
+  for ( i=0 ; i<type+randN(type*2) ; i++ ) {
+    vel.x = randNS(16);
+    vel.y = randNS(16);
+    addFrag(&pos, &vel, 0, 0);
+  }
+  for ( i=0 ; i<type*2+randN(type) ; i++ ) {
+    vel.x = cmx+randNS(3);
+    vel.y = cmy+randNS(3);
+    addFrag(&pos, &vel, 1, 2+type);
+  }
+}
+
+void addShipFrag(Vector *p) {
+  Vector pos, vel;
+  int cmx, cmy;
+  int i;
+  pos.x = (p->x/SCAN_WIDTH*LAYER_WIDTH)>>8;
+  pos.y = (p->y/SCAN_HEIGHT*LAYER_HEIGHT)>>8;
+  for ( i=0 ; i<48 ; i++ ) {
+    vel.x = randNS(24);
+    vel.y = randNS(24);
+    addFrag(&pos, &vel, 0, 0);
+  }
+  for ( i=0 ; i<32 ; i++ ) {
+    vel.x = randNS(4);
+    vel.y = randNS(4);
+    addFrag(&pos, &vel, 1, 1+randN(6));
+  }
+}
+
+void addClearFrag(Vector *p, Vector *v) {
+  Vector pos, vel;
+  pos.x = (p->x/SCAN_WIDTH*LAYER_WIDTH)>>8;
+  pos.y = (p->y/SCAN_HEIGHT*LAYER_HEIGHT)>>8;
+  vel.x = (v->x/SCAN_WIDTH*LAYER_WIDTH)>>8;
+  vel.y = (v->y/SCAN_HEIGHT*LAYER_HEIGHT)>>8;
+  addFrag(&pos, &vel, 2, 0);
+}
+
+
+void moveFrags() {
+  int i;
+  Frag *fr;
+  for ( i=0 ; i<FRAG_MAX ; i++ ) {
+    if ( frag[i].cnt <= 0 ) continue;
+    fr = &(frag[i]);
+    fr->pos.x += fr->vel.x;
+    fr->pos.y += fr->vel.y;
+    fr->cnt--;
+  }
+}
+
+static int fragColor[3][2][2] = {
+  {{16*8-7, 16*2-2}, {16*2-7, 16*8-2}},
+  {{16*5-7, 16*2-2}, {16*2-7, 16*5-2}},
+  {{16*1-10, 16*1-5}, {16*1-5, 16*1-10}},
+};
+
+void drawFrags() {
+  int x, y, c;
+  int i;
+  Frag *fr;
+  for ( i=0 ; i<FRAG_MAX ; i++ ) {
+    if ( frag[i].cnt <= 0 ) continue;
+    fr = &(frag[i]);
+    c = fr->cnt&1;
+    drawBox(fr->pos.x, fr->pos.y, fr->width, fr->height, 
+	    fragColor[fr->spc][c][0],fragColor[fr->spc][c][1], l2buf);
+  }
+}

Modified: trunk/user/games/noiz2sa/src/letterrender.c
===================================================================
--- tags/noiz2sa/noiz2sa-0.51a/src/letterrender.c	2008-04-05 00:17:39 UTC (rev 2211)
+++ trunk/user/games/noiz2sa/src/letterrender.c	2008-04-07 17:17:30 UTC (rev 2230)
@@ -1,116 +1,117 @@
-/*
- * $Id: letterrender.c,v 1.1.1.1 2002/11/03 11:08:24 kenta Exp $
- *
- * Copyright 2002 Kenta Cho. All rights reserved.
- */
-
-/**
- * Letter render.
- *
- * @version $Revision: 1.1.1.1 $
- */
-#include "screen.h"
-#include "letterrender.h"
-#include "letterdata.h"
-
-void drawLetterBuf(int idx, int lx, int ly, int ltSize, int d,
-		LayerBit color1, LayerBit color2, LayerBit *buf, int panel) {
-  int i;
-  float x, y, length, size, t;
-  int deg;
-  for ( i=0 ; ; i++ ) {
-    deg = (int)spData[idx][i][4];
-    if ( deg > 99990 ) break;
-    x = spData[idx][i][0]; y = spData[idx][i][1];
-    size = spData[idx][i][2]; length = spData[idx][i][3];
-    size *= 1.3f; length *= 1.1f;
-    switch ( d ) {
-    case 0:
-      x = -x; y = y;
-      break;
-    case 1:
-      t = x; x = -y; y = -t;
-      deg += 90;
-      break;
-    case 2:
-      x = x; y = -y;
-      deg += 180;
-      break;
-    case 3:
-      t = x; x = y; y = t;
-      deg += 270;
-      break;
-    }
-    deg %= 180;
-    if ( panel ) {
-      if ( deg < 45 || deg > 135 ) {
-	drawBoxPanel((int)(x*ltSize)+lx, (int)(y*ltSize)+ly, 
-		     (int)(size*ltSize), (int)(length*ltSize), color1, color2, buf);
-      } else {
-	drawBoxPanel((int)(x*ltSize)+lx, (int)(y*ltSize)+ly, 
-		     (int)(length*ltSize), (int)(size*ltSize), color1, color2, buf);
-      }
-    } else {
-      if ( deg <= 45 || deg > 135 ) {
-	drawBox((int)(x*ltSize)+lx, (int)(y*ltSize)+ly, 
-		     (int)(size*ltSize), (int)(length*ltSize), color1, color2, buf);
-      } else {
-	drawBox((int)(x*ltSize)+lx, (int)(y*ltSize)+ly, 
-		     (int)(length*ltSize), (int)(size*ltSize), color1, color2, buf);
-      }
-    }
-  }
-}
-		       
-void drawLetter(int idx, int lx, int ly, int ltSize, int d,
-		LayerBit color1, LayerBit color2, LayerBit *buf) {
-  drawLetterBuf(idx, lx, ly, ltSize, d, color1, color2, buf, 1);
-}
-
-void drawStringBuf(char *str, int lx, int ly, int ltSize, int d, 
-		LayerBit color1, LayerBit color2, LayerBit *buf, int panel) {
-  int x = lx, y = ly;
-  int i, c, idx;
-  for ( i=0 ; ; i++ ) {
-    if ( str[i] == '\0' ) break;
-    c = str[i];
-    if ( c != ' ' ) {
-      if ( c >= '0' && c <='9' ) {
-	idx = c-'0';
-      } else if ( c >= 'A' && c <= 'Z' ) {
-	idx = c-'A'+10;
-      } else if ( c >= 'a' && c <= 'z' ) {
-	idx = c-'a'+10;
-      } else if ( c == '.' ) {
-	idx = 36;
-      } else if ( c == '-' ) {
-	idx = 38;
-      } else if ( c == '+' ) {
-	idx = 39;
-      } else {
-	idx = 37;
-      }
-      drawLetterBuf(idx, x, y, ltSize, d, color1, color2, buf, panel);
-    }
-    switch ( d ) {
-    case 0:
-      x -= ltSize*1.7f;
-      break;
-    case 1:
-      y -= ltSize*1.7f;
-      break;
-    case 2:
-      x += ltSize*1.7f;
-      break;
-    case 3:
-      y += ltSize*1.7f;
-      break;
-    }
-  }
-}
-
-void drawString(char *str, int lx, int ly, int ltSize, int d, 
-		LayerBit color1, LayerBit color2, LayerBit *buf) {
-  drawStringBuf(str, lx, ly, ltSize, d, color1, color2, buf, 1);
-}
-
+/*
+ * $Id: letterrender.c,v 1.1.1.1 2002/11/03 11:08:24 kenta Exp $
+ *
+ * Copyright 2002 Kenta Cho. All rights reserved.
+ */
+
+/**
+ * Letter render.
+ *
+ * @version $Revision: 1.1.1.1 $
+ */
+#include "screen.h"
+#include "letterrender.h"
+#include "letterdata.h"
+
+void drawLetterBuf(int idx, int lx, int ly, int ltSize, int d,
+		LayerBit color1, LayerBit color2, LayerBit *buf, int panel) {
+  int i;
+  float x, y, length, size, t;
+  int deg;
+  ltSize+=(SCREEN_DIVISOR*SCREEN_DIVISOR)-1;
+  for ( i=0 ; ; i++ ) {
+    deg = (int)spData[idx][i][4];
+    if ( deg > 99990 ) break;
+    x = spData[idx][i][0] / (float)SCREEN_DIVISOR; y = spData[idx][i][1] / (float)SCREEN_DIVISOR;
+    size = spData[idx][i][2] / (float)SCREEN_DIVISOR; length = spData[idx][i][3] / (float)SCREEN_DIVISOR;
+    size *= 1.3f; length *= 1.1f;
+    switch ( d ) {
+    case 0:
+      x = -x; y = y;
+      break;
+    case 1:
+      t = x; x = -y; y = -t;
+      deg += 90;
+      break;
+    case 2:
+      x = x; y = -y;
+      deg += 180;
+      break;
+    case 3:
+      t = x; x = y; y = t;
+      deg += 270;
+      break;
+    }
+    deg %= 180;
+    if ( panel ) {
+      if ( deg < 45 || deg > 135 ) {
+	drawBoxPanel((int)(x*ltSize)+lx, (int)(y*ltSize)+ly, 
+		     (int)(size*ltSize), (int)(length*ltSize), color1, color2, buf);
+      } else {
+	drawBoxPanel((int)(x*ltSize)+lx, (int)(y*ltSize)+ly, 
+		     (int)(length*ltSize), (int)(size*ltSize), color1, color2, buf);
+      }
+    } else {
+      if ( deg <= 45 || deg > 135 ) {
+	drawBox((int)(x*ltSize)+lx, (int)(y*ltSize)+ly, 
+		     (int)(size*ltSize), (int)(length*ltSize), color1, color2, buf);
+      } else {
+	drawBox((int)(x*ltSize)+lx, (int)(y*ltSize)+ly, 
+		     (int)(length*ltSize), (int)(size*ltSize), color1, color2, buf);
+      }
+    }
+  }
+}
+		       
+void drawLetter(int idx, int lx, int ly, int ltSize, int d,
+		LayerBit color1, LayerBit color2, LayerBit *buf) {
+  drawLetterBuf(idx, lx, ly, ltSize, d, color1, color2, buf, 1);
+}
+
+void drawStringBuf(char *str, int lx, int ly, int ltSize, int d, 
+		LayerBit color1, LayerBit color2, LayerBit *buf, int panel) {
+  int x = lx, y = ly;
+  int i, c, idx;
+  for ( i=0 ; ; i++ ) {
+    if ( str[i] == '\0' ) break;
+    c = str[i];
+    if ( c != ' ' ) {
+      if ( c >= '0' && c <='9' ) {
+	idx = c-'0';
+      } else if ( c >= 'A' && c <= 'Z' ) {
+	idx = c-'A'+10;
+      } else if ( c >= 'a' && c <= 'z' ) {
+	idx = c-'a'+10;
+      } else if ( c == '.' ) {
+	idx = 36;
+      } else if ( c == '-' ) {
+	idx = 38;
+      } else if ( c == '+' ) {
+	idx = 39;
+      } else {
+	idx = 37;
+      }
+      drawLetterBuf(idx, x, y, ltSize, d, color1, color2, buf, panel);
+    }
+    switch ( d ) {
+    case 0:
+      x -= ltSize*1.7f / (float)SCREEN_DIVISOR;
+      break;
+    case 1:
+      y -= ltSize*1.7f / (float)SCREEN_DIVISOR;
+      break;
+    case 2:
+      x += ltSize*1.7f / (float)SCREEN_DIVISOR;
+      break;
+    case 3:
+      y += ltSize*1.7f / (float)SCREEN_DIVISOR;
+      break;
+    }
+  }
+}
+
+void drawString(char *str, int lx, int ly, int ltSize, int d, 
+		LayerBit color1, LayerBit color2, LayerBit *buf) {
+  drawStringBuf(str, lx, ly, ltSize, d, color1, color2, buf, 1);
+}
+

Modified: trunk/user/games/noiz2sa/src/screen.c
===================================================================
--- tags/noiz2sa/noiz2sa-0.51a/src/screen.c	2008-04-05 00:17:39 UTC (rev 2211)
+++ trunk/user/games/noiz2sa/src/screen.c	2008-04-07 17:17:30 UTC (rev 2230)
@@ -1,580 +1,580 @@
-/*
- * $Id: screen.c,v 1.3 2003/02/09 07:34:16 kenta Exp $
- *
- * Copyright 2002 Kenta Cho. All rights reserved.
- */
-
-/**
- * SDL screen handler.
- *
- * @version $Revision: 1.3 $
- */
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "SDL.h"
-
-#include "noiz2sa.h"
-#include "screen.h"
-#include "clrtbl.h"
-#include "vector.h"
-#include "degutil.h"
-#include "letterrender.h"
-#include "attractmanager.h"
-
-int windowMode = 0;
-int brightness = DEFAULT_BRIGHTNESS;
-int joystickMode = 1;
-
-static SDL_Surface *video, *layer, *lpanel, *rpanel;
-static LayerBit **smokeBuf;
-static LayerBit *pbuf;
-LayerBit *l1buf, *l2buf;
-LayerBit *buf;
-LayerBit *lpbuf, *rpbuf;
-static SDL_Rect screenRect, layerRect, layerClearRect;
-static SDL_Rect lpanelRect, rpanelRect, panelClearRect;
-static int pitch, ppitch;
-
-// Handle BMP images.
-#define SPRITE_NUM 7
-#define SHARE_LOC "/usr/share/games/noiz2sa/"
-
-static SDL_Surface *sprite[SPRITE_NUM];
-static char *spriteFile[SPRITE_NUM] = {
-  "title_n.bmp", "title_o.bmp", "title_i.bmp", "title_z.bmp", "title_2.bmp",
-  "title_s.bmp", "title_a.bmp",
-};
-
-Uint8 *keys;
-SDL_Joystick *stick = NULL;
-
-static void loadSprites() {
-  SDL_Surface *img;
-  int i;
-  char name[56];
-  color[0].r = 100; color[0].g = 0; color[0].b = 0;
-  SDL_SetColors(video, color, 0, 1);
-  for ( i=0 ; i<SPRITE_NUM ; i++ ) {
-    strcpy(name, SHARE_LOC);
-    strcat(name, "images/");
-    strcat(name, spriteFile[i]);
-    img = SDL_LoadBMP(name);
-    if ( img == NULL ) {
-      fprintf(stderr, "Unable to load: %s\n", name);
-      SDL_Quit();
-      exit(1);
-    }
-    sprite[i] = SDL_ConvertSurface(img,
-				   video->format,
-				   SDL_HWSURFACE | SDL_SRCCOLORKEY);
-    SDL_SetColorKey(sprite[i], SDL_SRCCOLORKEY | SDL_RLEACCEL, 0);
-  }
-  color[0].r = color[0].g = color[0].b = 255;
-  SDL_SetColors(video, color, 0, 1);
-}
-
-void drawSprite(int n, int x, int y) {
-  SDL_Rect pos;
-  pos.x = x; pos.y = y;
-  SDL_BlitSurface(sprite[n], NULL, video, &pos);
-}
-
-// Initialize palletes.
-static void initPalette() {
-  int i;
-  for ( i=0 ; i<256 ; i++ ) {
-    color[i].r = color[i].r*brightness/256;
-    color[i].g = color[i].g*brightness/256;
-    color[i].b = color[i].b*brightness/256;
-  }
-  SDL_SetColors(video, color, 0, 256);
-  SDL_SetColors(layer, color, 0, 256);
-  SDL_SetColors(lpanel, color, 0, 256);
-  SDL_SetColors(rpanel, color, 0, 256);
-}
-
-static int lyrSize;
-
-static void makeSmokeBuf() {
-  int x, y, mx, my;
-  lyrSize = sizeof(LayerBit)*pitch*LAYER_HEIGHT;
-  if ( NULL == (smokeBuf = (LayerBit**)malloc(sizeof(LayerBit*)*pitch*LAYER_HEIGHT)) ) {
-    fprintf(stderr, "Couldn't malloc smokeBuf.");
-    exit(1);
-  }
-  if ( NULL == (pbuf  = (LayerBit*)malloc(lyrSize+sizeof(LayerBit))) ||
-       NULL == (l1buf = (LayerBit*)malloc(lyrSize+sizeof(LayerBit))) ||
-       NULL == (l2buf = (LayerBit*)malloc(lyrSize+sizeof(LayerBit))) ) {
-    fprintf(stderr, "Couldn't malloc buffer.");
-    exit(1);
-  }
-  pbuf[pitch*LAYER_HEIGHT] = 0;
-  for ( y=0 ; y<LAYER_HEIGHT ; y++ ) {
-    for ( x=0 ; x<LAYER_WIDTH ; x++ ) {
-      mx = x + sctbl[(x*8)&(DIV-1)]/128;
-      my = y + sctbl[(y*8)&(DIV-1)]/128;
-      if ( mx < 0 || mx >= LAYER_WIDTH || my < 0 || my >= LAYER_HEIGHT ) {
-	smokeBuf[x+y*pitch] = &(pbuf[pitch*LAYER_HEIGHT]);
-      } else {
-	smokeBuf[x+y*pitch] = &(pbuf[mx+my*pitch]);
-      }
-    }
-  }
-}
-
-void initSDL(int window) {
-  Uint8 videoBpp;
-  Uint32 videoFlags;
-  SDL_PixelFormat *pfrm;
-
-  if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
-    fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
-    exit(1);
-  }
-  atexit(SDL_Quit);
-  if ( SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0 ) {
-    printf( "Unable to initialize SDL_JOYSTICK: %s\n", SDL_GetError());
-    joystickMode = 0;
-  }
-
-  videoBpp = BPP;
-  videoFlags = SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE;
-  if ( !window ) videoFlags |= SDL_FULLSCREEN;
-
-  if ( (video = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, videoBpp, videoFlags)) == NULL ) {
-    fprintf(stderr, "Unable to create SDL screen: %s\n", SDL_GetError());
-    SDL_Quit();
-    exit(1);
-  }
-  screenRect.x = screenRect.y = 0;
-  screenRect.w = SCREEN_WIDTH; screenRect.h = SCREEN_HEIGHT;
-  pfrm = video->format;
-  if ( NULL == ( layer = SDL_CreateRGBSurface
-		(SDL_SWSURFACE, LAYER_WIDTH, LAYER_HEIGHT, videoBpp,
-		 pfrm->Rmask, pfrm->Gmask, pfrm->Bmask, pfrm->Amask)) ||
-       NULL == ( lpanel = SDL_CreateRGBSurface
-		(SDL_SWSURFACE, PANEL_WIDTH, PANEL_HEIGHT, videoBpp,
-		 pfrm->Rmask, pfrm->Gmask, pfrm->Bmask, pfrm->Amask)) ||
-       NULL == ( rpanel = SDL_CreateRGBSurface
-		(SDL_SWSURFACE, PANEL_WIDTH, PANEL_HEIGHT, videoBpp,
-		 pfrm->Rmask, pfrm->Gmask, pfrm->Bmask, pfrm->Amask)) ) {
-      fprintf(stderr, "Couldn't create surface: %s\n", SDL_GetError());
-      exit(1);
-  }
-  layerRect.x = (SCREEN_WIDTH-LAYER_WIDTH)/2;
-  layerRect.y = (SCREEN_HEIGHT-LAYER_HEIGHT)/2;
-  layerRect.w = LAYER_WIDTH;
-  layerRect.h = LAYER_HEIGHT;
-  layerClearRect.x = layerClearRect.y = 0;
-  layerClearRect.w = LAYER_WIDTH;
-  layerClearRect.h = LAYER_HEIGHT;
-  lpanelRect.x = 0;
-  lpanelRect.y = (SCREEN_HEIGHT-PANEL_HEIGHT)/2;
-  rpanelRect.x = SCREEN_WIDTH-PANEL_WIDTH;
-  rpanelRect.y = (SCREEN_HEIGHT-PANEL_HEIGHT)/2;
-  lpanelRect.w = rpanelRect.w = PANEL_WIDTH;
-  lpanelRect.h = rpanelRect.h = PANEL_HEIGHT;
-  panelClearRect.x = panelClearRect.y = 0;
-  panelClearRect.w = PANEL_WIDTH;
-  panelClearRect.h = PANEL_HEIGHT;
-
-  pitch = layer->pitch/(videoBpp/8);
-  buf = (LayerBit*)layer->pixels;
-  ppitch = lpanel->pitch/(videoBpp/8);
-  lpbuf = (LayerBit*)lpanel->pixels;
-  rpbuf = (LayerBit*)rpanel->pixels;
-
-  initPalette();
-  makeSmokeBuf();
-  clearLPanel();
-  clearRPanel();
-
-  loadSprites();
-  if (joystickMode == 1) {
-    stick = SDL_JoystickOpen(0);
-  }
-
-  SDL_WM_SetCaption(CAPTION, NULL);
-  SDL_ShowCursor(SDL_DISABLE);
-  //SDL_WM_GrabInput(SDL_GRAB_ON);
-}
-
-void closeSDL() {
-  SDL_ShowCursor(SDL_ENABLE);
-}
-
-void blendScreen() {
-  int i;
-  for ( i = lyrSize-1 ; i >= 0 ; i-- ) {
-    buf[i] = colorAlp[l1buf[i]][l2buf[i]];
-  }
-}
-
-void flipScreen() {
-  SDL_BlitSurface(layer, NULL, video, &layerRect);
-  SDL_BlitSurface(lpanel, NULL, video, &lpanelRect);
-  SDL_BlitSurface(rpanel, NULL, video, &rpanelRect);
-  if ( status == TITLE ) {
-    drawTitle();
-  }
-  SDL_Flip(video);
-}
-
-void clearScreen() {
-  SDL_FillRect(layer, &layerClearRect, 0);
-}
-
-void clearLPanel() {
-  SDL_FillRect(lpanel, &panelClearRect, 0);
-}
-
-void clearRPanel() {
-  SDL_FillRect(rpanel, &panelClearRect, 0);
-}
-
-void smokeScreen() {
-  int i;
-  memcpy(pbuf, l2buf, lyrSize);
-  for ( i = lyrSize-1 ; i >= 0 ; i-- ) {
-    l1buf[i] = colorDfs[l1buf[i]];
-    l2buf[i] = colorDfs[*(smokeBuf[i])];
-  }
-}
-
-
-void drawLine(int x1, int y1, int x2, int y2, LayerBit color, int width, LayerBit *buf) {
-  int lx, ly, ax, ay, x, y, ptr, i, j;
-  int xMax, yMax;
-
-  lx = absN(x2 - x1);
-  ly = absN(y2 - y1);
-  if ( lx < ly ) {
-    x1 -= width>>1; x2 -= width>>1;
-  } else {
-    y1 -= width>>1; y2 -= width>>1;
-  }
-  xMax = LAYER_WIDTH-width-1; yMax = LAYER_HEIGHT-width-1;
-
-  if ( x1 < 0 ) {
-    if ( x2 < 0 ) return;
-    y1 = (y1-y2)*x2/(x2-x1)+y2;
-    x1 = 0;
-  } else if ( x2 < 0 ) {
-    y2 = (y2-y1)*x1/(x1-x2)+y1;
-    x2 = 0;
-  }
-  if ( x1 > xMax ) {
-    if ( x2 > xMax ) return;
-    y1 = (y1-y2)*(x2-xMax)/(x2-x1)+y2;
-    x1 = xMax;
-  } else if ( x2 > xMax ) {
-    y2 = (y2-y1)*(x1-xMax)/(x1-x2)+y1;
-    x2 = xMax;
-  }
-  if ( y1 < 0 ) {
-    if ( y2 < 0 ) return;
-    x1 = (x1-x2)*y2/(y2-y1)+x2;
-    y1 = 0;
-  } else if ( y2 < 0 ) {
-    x2 = (x2-x1)*y1/(y1-y2)+x1;
-    y2 = 0;
-  }
-  if ( y1 > yMax ) {
-    if ( y2 > yMax ) return;
-    x1 = (x1-x2)*(y2-yMax)/(y2-y1)+x2;
-    y1 = yMax;
-  } else if ( y2 > yMax ) {
-    x2 = (x2-x1)*(y1-yMax)/(y1-y2)+x1;
-    y2 = yMax;
-  }
-
-  lx = abs(x2 - x1);
-  ly = abs(y2 - y1);
-
-  if ( lx < ly ) {
-    if ( ly == 0 ) ly++;
-    ax = ((x2 - x1)<<8) / ly;
-    ay = ((y2 - y1)>>8) | 1;
-    x  = x1<<8;
-    y  = y1;
-    for ( i=ly ; i>0 ; i--, x+=ax, y+=ay ){
-      ptr = y*pitch + (x>>8);
-      for ( j=width ; j>0 ; j--, ptr++ ) {
-	buf[ptr] = color;
-      }
-    }
-  } else {
-    if ( lx == 0 ) lx++;
-    ay = ((y2 - y1)<<8) / lx;
-    ax = ((x2 - x1)>>8) | 1;
-    x  = x1;
-    y  = y1<<8;
-    for ( i=lx ; i>0 ; i--, x+=ax, y+=ay ) {
-      ptr = (y>>8)*pitch + x;
-      for ( j=width ; j>0 ; j--, ptr+=pitch ) {
-	buf[ptr] = color;
-      }
-    }
-  }
-}
-
-void drawThickLine(int x1, int y1, int x2, int y2,
-		   LayerBit color1, LayerBit color2, int width) {
-  int lx, ly, ax, ay, x, y, ptr, i, j;
-  int xMax, yMax;
-  int width1, width2;
-
-  lx = abs(x2 - x1);
-  ly = abs(y2 - y1);
-  if ( lx < ly ) {
-    x1 -= width>>1; x2 -= width>>1;
-  } else {
-    y1 -= width>>1; y2 -= width>>1;
-  }
-  xMax = LAYER_WIDTH-width; yMax = LAYER_HEIGHT-width;
-
-  if ( x1 < 0 ) {
-    if ( x2 < 0 ) return;
-    y1 = (y1-y2)*x2/(x2-x1)+y2;
-    x1 = 0;
-  } else if ( x2 < 0 ) {
-    y2 = (y2-y1)*x1/(x1-x2)+y1;
-    x2 = 0;
-  }
-  if ( x1 > xMax ) {
-    if ( x2 > xMax ) return;
-    y1 = (y1-y2)*(x2-xMax)/(x2-x1)+y2;
-    x1 = xMax;
-  } else if ( x2 > xMax ) {
-    y2 = (y2-y1)*(x1-xMax)/(x1-x2)+y1;
-    x2 = xMax;
-  }
-  if ( y1 < 0 ) {
-    if ( y2 < 0 ) return;
-    x1 = (x1-x2)*y2/(y2-y1)+x2;
-    y1 = 0;
-  } else if ( y2 < 0 ) {
-    x2 = (x2-x1)*y1/(y1-y2)+x1;
-    y2 = 0;
-  }
-  if ( y1 > yMax ) {
-    if ( y2 > yMax ) return;
-    x1 = (x1-x2)*(y2-yMax)/(y2-y1)+x2;
-    y1 = yMax;
-  } else if ( y2 > yMax ) {
-    x2 = (x2-x1)*(y1-yMax)/(y1-y2)+x1;
-    y2 = yMax;
-  }
-
-  lx = abs(x2 - x1);
-  ly = abs(y2 - y1);
-  width1 = width - 2;
-
-  if ( lx < ly ) {
-    if ( ly == 0 ) ly++;
-    ax = ((x2 - x1)<<8) / ly;
-    ay = ((y2 - y1)>>8) | 1;
-    x  = x1<<8;
-    y  = y1;
-    ptr = y*pitch + (x>>8) + 1;
-    memset(&(buf[ptr]), color2, width1);
-    x += ax; y += ay;
-    for ( i = ly-1 ; i > 1 ; i--, x+=ax, y+=ay ){
-      ptr = y*pitch + (x>>8);
-      buf[ptr] = color2; ptr++;
-      memset(&(buf[ptr]), color1, width1); ptr += width1;
-      buf[ptr] = color2;
-    }
-    ptr = y*pitch + (x>>8) + 1;
-    memset(&(buf[ptr]), color2, width1);
-  } else {
-    if ( lx == 0 ) lx++;
-    ay = ((y2 - y1)<<8) / lx;
-    ax = ((x2 - x1)>>8) | 1;
-    x  = x1;
-    y  = y1<<8;
-    ptr = ((y>>8)+1)*pitch + x;
-    for ( j=width1 ; j>0 ; j--, ptr+=pitch ) {
-      buf[ptr] = color2;
-    }
-    x += ax; y += ay;
-    for ( i=lx-1 ; i>1 ; i--, x+=ax, y+=ay ) {
-      ptr = (y>>8)*pitch + x;
-      buf[ptr] = color2; ptr += pitch;
-      for ( j=width1 ; j>0 ; j--, ptr+=pitch ) {
-	buf[ptr] = color1;
-      }
-      buf[ptr] = color2;
-    }
-    ptr = ((y>>8)+1)*pitch + x;
-    for ( j=width1 ; j>0 ; j--, ptr+=pitch ) {
-      buf[ptr] = color2;
-    }
-  }
-}
-
-void drawBox(int x, int y, int width, int height,
-	     LayerBit color1, LayerBit color2, LayerBit *buf) {
-  int i, j;
-  LayerBit cl;
-  int ptr;
-
-  x -= width>>1; y -= height>>1;
-  if ( x < 0 ) {
-    width += x; x = 0;
-  }
-  if ( x+width >= LAYER_WIDTH ) {
-    width = LAYER_WIDTH-x;
-  }
-  if ( width <= 1 ) return;
-  if ( y < 0 ) {
-    height += y; y = 0;
-  }
-  if ( y+height > LAYER_HEIGHT ) {
-    height = LAYER_HEIGHT-y;
-  }
-  if ( height <= 1 ) return;
-
-  ptr = x + y*LAYER_WIDTH;
-  memset(&(buf[ptr]), color2, width);
-  y++;
-  for ( i=0 ; i<height-2 ; i++, y++ ) {
-    ptr = x + y*LAYER_WIDTH;
-    buf[ptr] = color2; ptr++;
-    memset(&(buf[ptr]), color1, width-2);
-    ptr += width-2;
-    buf[ptr] = color2;
-  }
-  ptr = x + y*LAYER_WIDTH;
-  memset(&(buf[ptr]), color2, width);
-}
-
-void drawBoxPanel(int x, int y, int width, int height,
-		  LayerBit color1, LayerBit color2, LayerBit *buf) {
-  int i, j;
-  LayerBit cl;
-  int ptr;
-
-  x -= width>>1; y -= height>>1;
-  if ( x < 0 ) {
-    width += x; x = 0;
-  }
-  if ( x+width >= PANEL_WIDTH ) {
-    width = PANEL_WIDTH-x;
-  }
-  if ( width <= 1 ) return;
-  if ( y < 0 ) {
-    height += y; y = 0;
-  }
-  if ( y+height > PANEL_HEIGHT ) {
-    height = PANEL_HEIGHT-y;
-  }
-  if ( height <= 1 ) return;
-
-  ptr = x + y*PANEL_WIDTH;
-  memset(&(buf[ptr]), color2, width);
-  y++;
-  for ( i=0 ; i<height-2 ; i++, y++ ) {
-    ptr = x + y*PANEL_WIDTH;
-    buf[ptr] = color2; ptr++;
-    memset(&(buf[ptr]), color1, width-2);
-    ptr += width-2;
-    buf[ptr] = color2;
-  }
-  ptr = x + y*PANEL_WIDTH;
-  memset(&(buf[ptr]), color2, width);
-}
-
-// Draw the numbers.
-int drawNum(int n, int x ,int y, int s, int c1, int c2) {
-  for ( ; ; ) {
-    drawLetter(n%10, x, y, s, 1, c1, c2, lpbuf);
-    y += s*1.7f;
-    n /= 10;
-    if ( n <= 0 ) break;
-  }
-  return y;
-}
-
-int drawNumRight(int n, int x ,int y, int s, int c1, int c2) {
-  int d, nd, drawn = 0;
-  for ( d = 100000000 ; d > 0 ; d /= 10 ) {
-    nd = (int)(n/d);
-    if ( nd > 0 || drawn ) {
-      n -= d*nd;
-      drawLetter(nd%10, x, y, s, 3, c1, c2, rpbuf);
-      y += s*1.7f;
-      drawn = 1;
-    }
-  }
-  if ( !drawn ) {
-    drawLetter(0, x, y, s, 3, c1, c2, rpbuf);
-    y += s*1.7f;
-  }
-  return y;
-}
-
-int drawNumCenter(int n, int x ,int y, int s, int c1, int c2) {
-  for ( ; ; ) {
-    drawLetterBuf(n%10, x, y, s, 2, c1, c2, buf, 0);
-    x -= s*1.7f;
-    n /= 10;
-    if ( n <= 0 ) break;
-  }
-  return y;
-}
-
-
-#define JOYSTICK_AXIS 16384
-
-int getPadState() {
-  int x = 0, y = 0;
-  int pad = 0;
-  if ( stick != NULL ) {
-    x = SDL_JoystickGetAxis(stick, 0);
-    y = SDL_JoystickGetAxis(stick, 1);
-  }
-  if ( keys[SDLK_RIGHT] == SDL_PRESSED || keys[SDLK_KP6] == SDL_PRESSED || x > JOYSTICK_AXIS ) {
-    pad |= PAD_RIGHT;
-  }
-  if ( keys[SDLK_LEFT] == SDL_PRESSED || keys[SDLK_KP4] == SDL_PRESSED || x < -JOYSTICK_AXIS ) {
-    pad |= PAD_LEFT;
-  }
-  if ( keys[SDLK_DOWN] == SDL_PRESSED || keys[SDLK_KP2] == SDL_PRESSED || y > JOYSTICK_AXIS ) {
-    pad |= PAD_DOWN;
-  }
-  if ( keys[SDLK_UP] == SDL_PRESSED ||  keys[SDLK_KP8] == SDL_PRESSED || y < -JOYSTICK_AXIS ) {
-    pad |= PAD_UP;
-  }
-  return pad;
-}
-
-int buttonReversed = 0;
-
-int getButtonState() {
-  int btn = 0;
-  int btn1 = 0, btn2 = 0, btn3 = 0, btn4 = 0;
-  if ( stick != NULL ) {
-    btn1 = SDL_JoystickGetButton(stick, 0);
-    btn2 = SDL_JoystickGetButton(stick, 1);
-    btn3 = SDL_JoystickGetButton(stick, 2);
-    btn4 = SDL_JoystickGetButton(stick, 3);
-  }
-  if ( keys[SDLK_z] == SDL_PRESSED || btn1 || btn4 ) {
-    if ( !buttonReversed ) {
-      btn |= PAD_BUTTON1;
-    } else {
-      btn |= PAD_BUTTON2;
-    }
-  }
-  if ( keys[SDLK_x] == SDL_PRESSED || btn2 || btn3 ) {
-    if ( !buttonReversed ) {
-      btn |= PAD_BUTTON2;
-    } else {
-      btn |= PAD_BUTTON1;
-    }
-  }
-  return btn;
-}
+/*
+ * $Id: screen.c,v 1.3 2003/02/09 07:34:16 kenta Exp $
+ *
+ * Copyright 2002 Kenta Cho. All rights reserved.
+ */
+
+/**
+ * SDL screen handler.
+ *
+ * @version $Revision: 1.3 $
+ */
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "SDL.h"
+
+#include "noiz2sa.h"
+#include "screen.h"
+#include "clrtbl.h"
+#include "vector.h"
+#include "degutil.h"
+#include "letterrender.h"
+#include "attractmanager.h"
+
+int windowMode = 0;
+int brightness = DEFAULT_BRIGHTNESS;
+int joystickMode = 1;
+
+static SDL_Surface *video, *layer, *lpanel, *rpanel;
+static LayerBit **smokeBuf;
+static LayerBit *pbuf;
+LayerBit *l1buf, *l2buf;
+LayerBit *buf;
+LayerBit *lpbuf, *rpbuf;
+static SDL_Rect screenRect, layerRect, layerClearRect;
+static SDL_Rect lpanelRect, rpanelRect, panelClearRect;
+static int pitch, ppitch;
+
+// Handle BMP images.
+#define SPRITE_NUM 7
+#define SHARE_LOC "/usr/share/games/noiz2sa/"
+
+static SDL_Surface *sprite[SPRITE_NUM];
+static char *spriteFile[SPRITE_NUM] = {
+  "title_n.bmp", "title_o.bmp", "title_i.bmp", "title_z.bmp", "title_2.bmp",
+  "title_s.bmp", "title_a.bmp",
+};
+
+Uint8 *keys;
+SDL_Joystick *stick = NULL;
+
+static void loadSprites() {
+  SDL_Surface *img;
+  int i;
+  char name[56];
+  color[0].r = 100; color[0].g = 0; color[0].b = 0;
+  SDL_SetColors(video, color, 0, 1);
+  for ( i=0 ; i<SPRITE_NUM ; i++ ) {
+    strcpy(name, SHARE_LOC);
+    strcat(name, "images/");
+    strcat(name, spriteFile[i]);
+    img = SDL_LoadBMP(name);
+    if ( img == NULL ) {
+      fprintf(stderr, "Unable to load: %s\n", name);
+      SDL_Quit();
+      exit(1);
+    }
+    sprite[i] = SDL_ConvertSurface(img,
+				   video->format,
+				   SDL_SWSURFACE | SDL_SRCCOLORKEY);
+    SDL_SetColorKey(sprite[i], SDL_SRCCOLORKEY | SDL_RLEACCEL, 0);
+  }
+  color[0].r = color[0].g = color[0].b = 255;
+  SDL_SetColors(video, color, 0, 1);
+}
+
+void drawSprite(int n, int x, int y) {
+  SDL_Rect pos;
+  pos.x = x; pos.y = y;
+  SDL_BlitSurface(sprite[n], NULL, video, &pos);
+}
+
+// Initialize palletes.
+static void initPalette() {
+  int i;
+  for ( i=0 ; i<256 ; i++ ) {
+    color[i].r = color[i].r*brightness/256;
+    color[i].g = color[i].g*brightness/256;
+    color[i].b = color[i].b*brightness/256;
+  }
+  SDL_SetColors(video, color, 0, 256);
+  SDL_SetColors(layer, color, 0, 256);
+  SDL_SetColors(lpanel, color, 0, 256);
+  SDL_SetColors(rpanel, color, 0, 256);
+}
+
+static int lyrSize;
+
+static void makeSmokeBuf() {
+  int x, y, mx, my;
+  lyrSize = sizeof(LayerBit)*pitch*LAYER_HEIGHT;
+  if ( NULL == (smokeBuf = (LayerBit**)malloc(sizeof(LayerBit*)*pitch*LAYER_HEIGHT)) ) {
+    fprintf(stderr, "Couldn't malloc smokeBuf.");
+    exit(1);
+  }
+  if ( NULL == (pbuf  = (LayerBit*)malloc(lyrSize+sizeof(LayerBit))) ||
+       NULL == (l1buf = (LayerBit*)malloc(lyrSize+sizeof(LayerBit))) ||
+       NULL == (l2buf = (LayerBit*)malloc(lyrSize+sizeof(LayerBit))) ) {
+    fprintf(stderr, "Couldn't malloc buffer.");
+    exit(1);
+  }
+  pbuf[pitch*LAYER_HEIGHT] = 0;
+  for ( y=0 ; y<LAYER_HEIGHT ; y++ ) {
+    for ( x=0 ; x<LAYER_WIDTH ; x++ ) {
+      mx = x + sctbl[(x*8)&(DIV-1)]/128;
+      my = y + sctbl[(y*8)&(DIV-1)]/128;
+      if ( mx < 0 || mx >= LAYER_WIDTH || my < 0 || my >= LAYER_HEIGHT ) {
+	smokeBuf[x+y*pitch] = &(pbuf[pitch*LAYER_HEIGHT]);
+      } else {
+	smokeBuf[x+y*pitch] = &(pbuf[mx+my*pitch]);
+      }
+    }
+  }
+}
+
+void initSDL(int window) {
+  Uint8 videoBpp;
+  Uint32 videoFlags;
+  SDL_PixelFormat *pfrm;
+
+  if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+    fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
+    exit(1);
+  }
+  atexit(SDL_Quit);
+  if ( SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0 ) {
+    printf( "Unable to initialize SDL_JOYSTICK: %s\n", SDL_GetError());
+    joystickMode = 0;
+  }
+
+  videoBpp = BPP;
+  videoFlags = SDL_DOUBLEBUF | SDL_SWSURFACE | SDL_HWPALETTE;
+  if ( !window ) videoFlags |= SDL_FULLSCREEN;
+
+  if ( (video = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, videoBpp, videoFlags)) == NULL ) {
+    fprintf(stderr, "Unable to create SDL screen: %s\n", SDL_GetError());
+    SDL_Quit();
+    exit(1);
+  }
+  screenRect.x = screenRect.y = 0;
+  screenRect.w = SCREEN_WIDTH; screenRect.h = SCREEN_HEIGHT;
+  pfrm = video->format;
+  if ( NULL == ( layer = SDL_CreateRGBSurface
+		(SDL_SWSURFACE, LAYER_WIDTH, LAYER_HEIGHT, videoBpp,
+		 pfrm->Rmask, pfrm->Gmask, pfrm->Bmask, pfrm->Amask)) ||
+       NULL == ( lpanel = SDL_CreateRGBSurface
+		(SDL_SWSURFACE, PANEL_WIDTH, PANEL_HEIGHT, videoBpp,
+		 pfrm->Rmask, pfrm->Gmask, pfrm->Bmask, pfrm->Amask)) ||
+       NULL == ( rpanel = SDL_CreateRGBSurface
+		(SDL_SWSURFACE, PANEL_WIDTH, PANEL_HEIGHT, videoBpp,
+		 pfrm->Rmask, pfrm->Gmask, pfrm->Bmask, pfrm->Amask)) ) {
+      fprintf(stderr, "Couldn't create surface: %s\n", SDL_GetError());
+      exit(1);
+  }
+  layerRect.x = (SCREEN_WIDTH-LAYER_WIDTH)/2;
+  layerRect.y = (SCREEN_HEIGHT-LAYER_HEIGHT)/2;
+  layerRect.w = LAYER_WIDTH;
+  layerRect.h = LAYER_HEIGHT;
+  layerClearRect.x = layerClearRect.y = 0;
+  layerClearRect.w = LAYER_WIDTH;
+  layerClearRect.h = LAYER_HEIGHT;
+  lpanelRect.x = 0;
+  lpanelRect.y = (SCREEN_HEIGHT-PANEL_HEIGHT)/2;
+  rpanelRect.x = SCREEN_WIDTH-PANEL_WIDTH;
+  rpanelRect.y = (SCREEN_HEIGHT-PANEL_HEIGHT)/2;
+  lpanelRect.w = rpanelRect.w = PANEL_WIDTH;
+  lpanelRect.h = rpanelRect.h = PANEL_HEIGHT;
+  panelClearRect.x = panelClearRect.y = 0;
+  panelClearRect.w = PANEL_WIDTH;
+  panelClearRect.h = PANEL_HEIGHT;
+
+  pitch = layer->pitch/(videoBpp/8);
+  buf = (LayerBit*)layer->pixels;
+  ppitch = lpanel->pitch/(videoBpp/8);
+  lpbuf = (LayerBit*)lpanel->pixels;
+  rpbuf = (LayerBit*)rpanel->pixels;
+
+  initPalette();
+  makeSmokeBuf();
+  clearLPanel();
+  clearRPanel();
+
+  loadSprites();
+  if (joystickMode == 1) {
+    stick = SDL_JoystickOpen(0);
+  }
+
+  SDL_WM_SetCaption(CAPTION, NULL);
+  SDL_ShowCursor(SDL_DISABLE);
+  //SDL_WM_GrabInput(SDL_GRAB_ON);
+}
+
+void closeSDL() {
+  SDL_ShowCursor(SDL_ENABLE);
+}
+
+void blendScreen() {
+  int i;
+  for ( i = lyrSize-1 ; i >= 0 ; i-- ) {
+    buf[i] = colorAlp[l1buf[i]][l2buf[i]];
+  }
+}
+
+void flipScreen() {
+  SDL_BlitSurface(layer, NULL, video, &layerRect);
+  SDL_BlitSurface(lpanel, NULL, video, &lpanelRect);
+  SDL_BlitSurface(rpanel, NULL, video, &rpanelRect);
+  if ( status == TITLE ) {
+    drawTitle();
+  }
+  SDL_Flip(video);
+}
+
+void clearScreen() {
+  SDL_FillRect(layer, &layerClearRect, 0);
+}
+
+void clearLPanel() {
+  SDL_FillRect(lpanel, &panelClearRect, 0);
+}
+
+void clearRPanel() {
+  SDL_FillRect(rpanel, &panelClearRect, 0);
+}
+
+void smokeScreen() {
+  int i;
+  memcpy(pbuf, l2buf, lyrSize);
+  for ( i = lyrSize-1 ; i >= 0 ; i-- ) {
+    l1buf[i] = colorDfs[l1buf[i]];
+    l2buf[i] = colorDfs[*(smokeBuf[i])];
+  }
+}
+
+
+void drawLine(int x1, int y1, int x2, int y2, LayerBit color, int width, LayerBit *buf) {
+  int lx, ly, ax, ay, x, y, ptr, i, j;
+  int xMax, yMax;
+
+  lx = absN(x2 - x1);
+  ly = absN(y2 - y1);
+  if ( lx < ly ) {
+    x1 -= width>>1; x2 -= width>>1;
+  } else {
+    y1 -= width>>1; y2 -= width>>1;
+  }
+  xMax = LAYER_WIDTH-width-1; yMax = LAYER_HEIGHT-width-1;
+
+  if ( x1 < 0 ) {
+    if ( x2 < 0 ) return;
+    y1 = (y1-y2)*x2/(x2-x1)+y2;
+    x1 = 0;
+  } else if ( x2 < 0 ) {
+    y2 = (y2-y1)*x1/(x1-x2)+y1;
+    x2 = 0;
+  }
+  if ( x1 > xMax ) {
+    if ( x2 > xMax ) return;
+    y1 = (y1-y2)*(x2-xMax)/(x2-x1)+y2;
+    x1 = xMax;
+  } else if ( x2 > xMax ) {
+    y2 = (y2-y1)*(x1-xMax)/(x1-x2)+y1;
+    x2 = xMax;
+  }
+  if ( y1 < 0 ) {
+    if ( y2 < 0 ) return;
+    x1 = (x1-x2)*y2/(y2-y1)+x2;
+    y1 = 0;
+  } else if ( y2 < 0 ) {
+    x2 = (x2-x1)*y1/(y1-y2)+x1;
+    y2 = 0;
+  }
+  if ( y1 > yMax ) {
+    if ( y2 > yMax ) return;
+    x1 = (x1-x2)*(y2-yMax)/(y2-y1)+x2;
+    y1 = yMax;
+  } else if ( y2 > yMax ) {
+    x2 = (x2-x1)*(y1-yMax)/(y1-y2)+x1;
+    y2 = yMax;
+  }
+
+  lx = abs(x2 - x1);
+  ly = abs(y2 - y1);
+
+  if ( lx < ly ) {
+    if ( ly == 0 ) ly++;
+    ax = ((x2 - x1)<<8) / ly;
+    ay = ((y2 - y1)>>8) | 1;
+    x  = x1<<8;
+    y  = y1;
+    for ( i=ly ; i>0 ; i--, x+=ax, y+=ay ){
+      ptr = y*pitch + (x>>8);
+      for ( j=width ; j>0 ; j--, ptr++ ) {
+	buf[ptr] = color;
+      }
+    }
+  } else {
+    if ( lx == 0 ) lx++;
+    ay = ((y2 - y1)<<8) / lx;
+    ax = ((x2 - x1)>>8) | 1;
+    x  = x1;
+    y  = y1<<8;
+    for ( i=lx ; i>0 ; i--, x+=ax, y+=ay ) {
+      ptr = (y>>8)*pitch + x;
+      for ( j=width ; j>0 ; j--, ptr+=pitch ) {
+	buf[ptr] = color;
+      }
+    }
+  }
+}
+
+void drawThickLine(int x1, int y1, int x2, int y2,
+		   LayerBit color1, LayerBit color2, int width) {
+  int lx, ly, ax, ay, x, y, ptr, i, j;
+  int xMax, yMax;
+  int width1, width2;
+
+  lx = abs(x2 - x1);
+  ly = abs(y2 - y1);
+  if ( lx < ly ) {
+    x1 -= width>>1; x2 -= width>>1;
+  } else {
+    y1 -= width>>1; y2 -= width>>1;
+  }
+  xMax = LAYER_WIDTH-width; yMax = LAYER_HEIGHT-width;
+
+  if ( x1 < 0 ) {
+    if ( x2 < 0 ) return;
+    y1 = (y1-y2)*x2/(x2-x1)+y2;
+    x1 = 0;
+  } else if ( x2 < 0 ) {
+    y2 = (y2-y1)*x1/(x1-x2)+y1;
+    x2 = 0;
+  }
+  if ( x1 > xMax ) {
+    if ( x2 > xMax ) return;
+    y1 = (y1-y2)*(x2-xMax)/(x2-x1)+y2;
+    x1 = xMax;
+  } else if ( x2 > xMax ) {
+    y2 = (y2-y1)*(x1-xMax)/(x1-x2)+y1;
+    x2 = xMax;
+  }
+  if ( y1 < 0 ) {
+    if ( y2 < 0 ) return;
+    x1 = (x1-x2)*y2/(y2-y1)+x2;
+    y1 = 0;
+  } else if ( y2 < 0 ) {
+    x2 = (x2-x1)*y1/(y1-y2)+x1;
+    y2 = 0;
+  }
+  if ( y1 > yMax ) {
+    if ( y2 > yMax ) return;
+    x1 = (x1-x2)*(y2-yMax)/(y2-y1)+x2;
+    y1 = yMax;
+  } else if ( y2 > yMax ) {
+    x2 = (x2-x1)*(y1-yMax)/(y1-y2)+x1;
+    y2 = yMax;
+  }
+
+  lx = abs(x2 - x1);
+  ly = abs(y2 - y1);
+  width1 = width - 2;
+
+  if ( lx < ly ) {
+    if ( ly == 0 ) ly++;
+    ax = ((x2 - x1)<<8) / ly;
+    ay = ((y2 - y1)>>8) | 1;
+    x  = x1<<8;
+    y  = y1;
+    ptr = y*pitch + (x>>8) + 1;
+    memset(&(buf[ptr]), color2, width1);
+    x += ax; y += ay;
+    for ( i = ly-1 ; i > 1 ; i--, x+=ax, y+=ay ){
+      ptr = y*pitch + (x>>8);
+      buf[ptr] = color2; ptr++;
+      memset(&(buf[ptr]), color1, width1); ptr += width1;
+      buf[ptr] = color2;
+    }
+    ptr = y*pitch + (x>>8) + 1;
+    memset(&(buf[ptr]), color2, width1);
+  } else {
+    if ( lx == 0 ) lx++;
+    ay = ((y2 - y1)<<8) / lx;
+    ax = ((x2 - x1)>>8) | 1;
+    x  = x1;
+    y  = y1<<8;
+    ptr = ((y>>8)+1)*pitch + x;
+    for ( j=width1 ; j>0 ; j--, ptr+=pitch ) {
+      buf[ptr] = color2;
+    }
+    x += ax; y += ay;
+    for ( i=lx-1 ; i>1 ; i--, x+=ax, y+=ay ) {
+      ptr = (y>>8)*pitch + x;
+      buf[ptr] = color2; ptr += pitch;
+      for ( j=width1 ; j>0 ; j--, ptr+=pitch ) {
+	buf[ptr] = color1;
+      }
+      buf[ptr] = color2;
+    }
+    ptr = ((y>>8)+1)*pitch + x;
+    for ( j=width1 ; j>0 ; j--, ptr+=pitch ) {
+      buf[ptr] = color2;
+    }
+  }
+}
+
+void drawBox(int x, int y, int width, int height,
+	     LayerBit color1, LayerBit color2, LayerBit *buf) {
+  int i, j;
+  LayerBit cl;
+  int ptr;
+
+  x -= width>>1; y -= height>>1;
+  if ( x < 0 ) {
+    width += x; x = 0;
+  }
+  if ( x+width >= LAYER_WIDTH ) {
+    width = LAYER_WIDTH-x;
+  }
+  if ( width <= 1 ) return;
+  if ( y < 0 ) {
+    height += y; y = 0;
+  }
+  if ( y+height > LAYER_HEIGHT ) {
+    height = LAYER_HEIGHT-y;
+  }
+  if ( height <= 1 ) return;
+
+  ptr = x + y*LAYER_WIDTH;
+  memset(&(buf[ptr]), color2, width);
+  y++;
+  for ( i=0 ; i<height-2 ; i++, y++ ) {
+    ptr = x + y*LAYER_WIDTH;
+    buf[ptr] = color2; ptr++;
+    memset(&(buf[ptr]), color1, width-2);
+    ptr += width-2;
+    buf[ptr] = color2;
+  }
+  ptr = x + y*LAYER_WIDTH;
+  memset(&(buf[ptr]), color2, width);
+}
+
+void drawBoxPanel(int x, int y, int width, int height,
+		  LayerBit color1, LayerBit color2, LayerBit *buf) {
+  int i, j;
+  LayerBit cl;
+  int ptr;
+
+  x -= width>>1; y -= height>>1;
+  if ( x < 0 ) {
+    width += x; x = 0;
+  }
+  if ( x+width >= PANEL_WIDTH ) {
+    width = PANEL_WIDTH-x;
+  }
+  if ( width <= 1 ) return;
+  if ( y < 0 ) {
+    height += y; y = 0;
+  }
+  if ( y+height > PANEL_HEIGHT ) {
+    height = PANEL_HEIGHT-y;
+  }
+  if ( height <= 1 ) return;
+
+  ptr = x + y*PANEL_WIDTH;
+  memset(&(buf[ptr]), color2, width);
+  y++;
+  for ( i=0 ; i<height-2 ; i++, y++ ) {
+    ptr = x + y*PANEL_WIDTH;
+    buf[ptr] = color2; ptr++;
+    memset(&(buf[ptr]), color1, width-2);
+    ptr += width-2;
+    buf[ptr] = color2;
+  }
+  ptr = x + y*PANEL_WIDTH;
+  memset(&(buf[ptr]), color2, width);
+}
+
+// Draw the numbers.
+int drawNum(int n, int x ,int y, int s, int c1, int c2) {
+  for ( ; ; ) {
+    drawLetter(n%10, x, y, s, 1, c1, c2, lpbuf);
+    y += (s*1.7f) / (float)SCREEN_DIVISOR;
+    n /= 10;
+    if ( n <= 0 ) break;
+  }
+  return y;
+}
+
+int drawNumRight(int n, int x ,int y, int s, int c1, int c2) {
+  int d, nd, drawn = 0;
+  for ( d = 100000000 ; d > 0 ; d /= 10 ) {
+    nd = (int)(n/d);
+    if ( nd > 0 || drawn ) {
+      n -= d*nd;
+      drawLetter(nd%10, x, y, s, 3, c1, c2, rpbuf);
+      y += (s*1.7f) / (float)SCREEN_DIVISOR;
+      drawn = 1;
+    }
+  }
+  if ( !drawn ) {
+    drawLetter(0, x, y, s, 3, c1, c2, rpbuf);
+    y += (s*1.7f) / (float)SCREEN_DIVISOR;
+  }
+  return y;
+}
+
+int drawNumCenter(int n, int x ,int y, int s, int c1, int c2) {
+  for ( ; ; ) {
+    drawLetterBuf(n%10, x, y, s, 2, c1, c2, buf, 0);
+    y += (s*1.7f) / (float)SCREEN_DIVISOR;
+    n /= 10;
+    if ( n <= 0 ) break;
+  }
+  return y;
+}
+
+
+#define JOYSTICK_AXIS 16384
+
+int getPadState() {
+  int x = 0, y = 0;
+  int pad = 0;
+  if ( stick != NULL ) {
+    x = SDL_JoystickGetAxis(stick, 0);
+    y = SDL_JoystickGetAxis(stick, 1);
+  }
+  if ( keys[SDLK_RIGHT] == SDL_PRESSED || keys[SDLK_KP6] == SDL_PRESSED || x > JOYSTICK_AXIS ) {
+    pad |= PAD_RIGHT;
+  }
+  if ( keys[SDLK_LEFT] == SDL_PRESSED || keys[SDLK_KP4] == SDL_PRESSED || x < -JOYSTICK_AXIS ) {
+    pad |= PAD_LEFT;
+  }
+  if ( keys[SDLK_DOWN] == SDL_PRESSED || keys[SDLK_KP2] == SDL_PRESSED || y > JOYSTICK_AXIS ) {
+    pad |= PAD_DOWN;
+  }
+  if ( keys[SDLK_UP] == SDL_PRESSED ||  keys[SDLK_KP8] == SDL_PRESSED || y < -JOYSTICK_AXIS ) {
+    pad |= PAD_UP;
+  }
+  return pad;
+}
+
+int buttonReversed = 0;
+
+int getButtonState() {
+  int btn = 0;
+  int btn1 = 0, btn2 = 0, btn3 = 0, btn4 = 0;
+  if ( stick != NULL ) {
+    btn1 = SDL_JoystickGetButton(stick, 0);
+    btn2 = SDL_JoystickGetButton(stick, 1);
+    btn3 = SDL_JoystickGetButton(stick, 2);
+    btn4 = SDL_JoystickGetButton(stick, 3);
+  }
+  if ( keys[SDLK_SPACE] == SDL_PRESSED || btn1 || btn4 ) {
+    if ( !buttonReversed ) {
+      btn |= PAD_BUTTON1;
+    } else {
+      btn |= PAD_BUTTON2;
+    }
+  }
+  if ( keys[SDLK_RETURN] == SDL_PRESSED || btn2 || btn3 ) {
+    if ( !buttonReversed ) {
+      btn |= PAD_BUTTON2;
+    } else {
+      btn |= PAD_BUTTON1;
+    }
+  }
+  return btn;
+}

Modified: trunk/user/games/noiz2sa/src/screen.h
===================================================================
--- tags/noiz2sa/noiz2sa-0.51a/src/screen.h	2008-04-05 00:17:39 UTC (rev 2211)
+++ trunk/user/games/noiz2sa/src/screen.h	2008-04-07 17:17:30 UTC (rev 2230)
@@ -1,68 +1,69 @@
-/*
- * $Id: screen.h,v 1.3 2002/12/31 09:34:34 kenta Exp $
- *
- * Copyright 2002 Kenta Cho. All rights reserved.
- */
-
-/**
- * SDL screen functions header file.
- *
- * @version $Revision: 1.3 $
- */
-#include "SDL.h"
-#include "vector.h"
-
-#define SCREEN_WIDTH 640
-#define SCREEN_HEIGHT 480
-#define LAYER_WIDTH 320
-#define LAYER_HEIGHT 480
-#define PANEL_WIDTH 160
-#define PANEL_HEIGHT 480
-
-#define SCAN_WIDTH 320
-#define SCAN_HEIGHT 480
-#define SCAN_WIDTH_8 (SCAN_WIDTH<<8)
-#define SCAN_HEIGHT_8 (SCAN_HEIGHT<<8)
-
-#define BPP 8
-#define LayerBit Uint8
-
-#define PAD_UP 1
-#define PAD_DOWN 2
-#define PAD_LEFT 4
-#define PAD_RIGHT 8
-#define PAD_BUTTON1 16
-#define PAD_BUTTON2 32
-
-#define DEFAULT_BRIGHTNESS 224
-
-extern int windowMode;
-extern LayerBit *l1buf, *l2buf;
-extern LayerBit *buf;
-extern LayerBit *lpbuf, *rpbuf;
-extern Uint8 *keys;
-extern SDL_Joystick *stick;
-extern int buttonReversed;
-extern int brightness;
-
-void initSDL(int window);
-void closeSDL();
-void blendScreen();
-void flipScreen();
-void clearScreen();
-void clearLPanel();
-void clearRPanel();
-void smokeScreen();
-void drawThickLine(int x1, int y1, int x2, int y2, LayerBit color1, LayerBit color2, int width);
-void drawLine(int x1, int y1, int x2, int y2, LayerBit color, int width, LayerBit *buf);
-void drawBox(int x, int y, int width, int height, 
-	     LayerBit color1, LayerBit color2, LayerBit *buf);
-void drawBoxPanel(int x, int y, int width, int height, 
-		  LayerBit color1, LayerBit color2, LayerBit *buf);
-int drawNum(int n, int x ,int y, int s, int c1, int c2);
-int drawNumRight(int n, int x ,int y, int s, int c1, int c2);
-int drawNumCenter(int n, int x ,int y, int s, int c1, int c2);
-void drawSprite(int n, int x, int y);
-
-int getPadState();
-int getButtonState();
+/*
+ * $Id: screen.h,v 1.3 2002/12/31 09:34:34 kenta Exp $
+ *
+ * Copyright 2002 Kenta Cho. All rights reserved.
+ */
+
+/**
+ * SDL screen functions header file.
+ *
+ * @version $Revision: 1.3 $
+ */
+#include "SDL.h"
+#include "vector.h"
+
+#define SCREEN_WIDTH (640 / SCREEN_DIVISOR)
+#define SCREEN_HEIGHT (480 / SCREEN_DIVISOR)
+#define LAYER_WIDTH (320 / SCREEN_DIVISOR) 
+#define LAYER_HEIGHT (480 / SCREEN_DIVISOR)
+#define PANEL_WIDTH (160 / SCREEN_DIVISOR)
+#define PANEL_HEIGHT (480 / SCREEN_DIVISOR)
+
+#define SCAN_WIDTH (320 / SCREEN_DIVISOR)
+#define SCAN_HEIGHT (480 / SCREEN_DIVISOR)
+
+#define SCAN_WIDTH_8 (SCAN_WIDTH<<8)
+#define SCAN_HEIGHT_8 (SCAN_HEIGHT<<8)
+
+#define BPP 8
+#define LayerBit Uint8
+
+#define PAD_UP 1
+#define PAD_DOWN 2
+#define PAD_LEFT 4
+#define PAD_RIGHT 8
+#define PAD_BUTTON1 16
+#define PAD_BUTTON2 32
+
+#define DEFAULT_BRIGHTNESS 224
+
+extern int windowMode;
+extern LayerBit *l1buf, *l2buf;
+extern LayerBit *buf;
+extern LayerBit *lpbuf, *rpbuf;
+extern Uint8 *keys;
+extern SDL_Joystick *stick;
+extern int buttonReversed;
+extern int brightness;
+
+void initSDL(int window);
+void closeSDL();
+void blendScreen();
+void flipScreen();
+void clearScreen();
+void clearLPanel();
+void clearRPanel();
+void smokeScreen();
+void drawThickLine(int x1, int y1, int x2, int y2, LayerBit color1, LayerBit color2, int width);
+void drawLine(int x1, int y1, int x2, int y2, LayerBit color, int width, LayerBit *buf);
+void drawBox(int x, int y, int width, int height, 
+	     LayerBit color1, LayerBit color2, LayerBit *buf);
+void drawBoxPanel(int x, int y, int width, int height, 
+		  LayerBit color1, LayerBit color2, LayerBit *buf);
+int drawNum(int n, int x ,int y, int s, int c1, int c2);
+int drawNumRight(int n, int x ,int y, int s, int c1, int c2);
+int drawNumCenter(int n, int x ,int y, int s, int c1, int c2);
+void drawSprite(int n, int x, int y);
+
+int getPadState();
+int getButtonState();

Modified: trunk/user/games/noiz2sa/src/ship.c
===================================================================
--- tags/noiz2sa/noiz2sa-0.51a/src/ship.c	2008-04-05 00:17:39 UTC (rev 2211)
+++ trunk/user/games/noiz2sa/src/ship.c	2008-04-07 17:17:30 UTC (rev 2230)
@@ -1,173 +1,173 @@
-/*
- * $Id: ship.c,v 1.5 2003/02/09 07:34:16 kenta Exp $
- *
- * Copyright 2002 Kenta Cho. All rights reserved.
- */
-
-/**
- * Handle player.
- *
- * @version $Revision: 1.5 $
- */
-#include "SDL.h"
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "noiz2sa.h"
-#include "screen.h"
-#include "vector.h"
-#include "ship.h"
-#include "shot.h"
-#include "bonus.h"
-#include "foe_mtd.h"
-#include "degutil.h"
-#include "brgmng_mtd.h"
-#include "frag.h"
-#include "soundmanager.h"
-#include "attractmanager.h"
-
-Ship ship;
-
-#define SHIP_SPEED 1280
-#define SHIP_SLOW_SPEED 640
-#define SHIP_SLOW_DOWN 64
-
-#define SHIP_INVINCIBLE_CNT_BASE 240
-
-void initShip() {
-  ship.pos.x = (SCAN_WIDTH/2)<<8; ship.pos.y = (SCAN_HEIGHT/5*4)<<8;
-  ship.cnt = 0; ship.shotCnt = -1;
-  ship.speed = SHIP_SPEED;
-  ship.invCnt = SHIP_INVINCIBLE_CNT_BASE*(100-scene)/100;
-  if ( ship.invCnt < 0 ) ship.invCnt = 0;
-}
-
-#define SHOT_INTERVAL 3
-
-#define SHIP_SCAN_WIDTH 1024
-#define SHIP_SCREEN_EDGE_WIDTH 3
-
-static int shipMv[8][2] = {
-  {0, -256}, {181, -181}, {256, 0}, {181, 181}, {0, 256}, {-181, 181}, {-256, 0}, {-181, -181},  
-};
-
-void moveShip() {
-  int pad = getPadState();
-  int btn = getButtonState();
-  int sd = -1;
-  if ( pad & PAD_RIGHT ) {
-    sd = 2;
-  }
-  if ( pad & PAD_LEFT ) {
-    sd = 6;
-  }
-  if ( pad & PAD_DOWN ) {
-    switch ( sd ) {
-    case 2:
-      sd = 3;
-      break;
-    case 6:
-      sd = 5;
-      break;
-    default:
-      sd = 4;
-      break;
-    }
-  }
-  if ( pad & PAD_UP ) {
-    switch ( sd ) {
-    case 2:
-      sd = 1;
-      break;
-    case 6:
-      sd = 7;
-      break;
-    default:
-      sd = 0;
-      break;
-    }
-  }
-  if ( btn & PAD_BUTTON1 ) {
-    if ( ship.shotCnt < 0 && status == IN_GAME ) {
-      addShot(&(ship.pos));
-      ship.shotCnt = SHOT_INTERVAL;
-    }
-  }
-  ship.shotCnt--;
-  if ( btn & PAD_BUTTON2 ) {
-    if ( ship.speed > SHIP_SLOW_SPEED ) {
-      ship.speed -= SHIP_SLOW_DOWN;
-    }
-  } else {
-    if ( ship.speed < SHIP_SPEED ) {
-      ship.speed += SHIP_SLOW_DOWN;
-    }
-  }
-
-  if ( sd >= 0 ) {
-    ship.pos.x += (ship.speed*shipMv[sd][0])>>8;
-    ship.pos.y += (ship.speed*shipMv[sd][1])>>8;
-    if ( ship.pos.x < SHIP_SCAN_WIDTH*SHIP_SCREEN_EDGE_WIDTH ) {
-      ship.pos.x = SHIP_SCAN_WIDTH*SHIP_SCREEN_EDGE_WIDTH;
-    } else if ( ship.pos.x > SCAN_WIDTH_8-SHIP_SCAN_WIDTH*SHIP_SCREEN_EDGE_WIDTH ) {
-      ship.pos.x = SCAN_WIDTH_8-SHIP_SCAN_WIDTH*SHIP_SCREEN_EDGE_WIDTH;
-    }
-    if ( ship.pos.y < SHIP_SCAN_WIDTH*SHIP_SCREEN_EDGE_WIDTH ) {
-      ship.pos.y = SHIP_SCAN_WIDTH*SHIP_SCREEN_EDGE_WIDTH;
-    } else if ( ship.pos.y > SCAN_HEIGHT_8-SHIP_SCAN_WIDTH*SHIP_SCREEN_EDGE_WIDTH ) {
-      ship.pos.y = SCAN_HEIGHT_8-SHIP_SCAN_WIDTH*SHIP_SCREEN_EDGE_WIDTH;
-    }
-  }
-
-  ship.cnt++;
-  if ( ship.invCnt > 0 ) ship.invCnt--;
-}
-
-#define SHIP_DRAW_WIDTH 6
-#define SHIP_DRUM_WIDTH 15
-#define SHIP_DRUM_SIZE 4
-
-void drawShip() {
-  int x, y, d;
-  int i;
-  int ic;
-  x = (ship.pos.x/SCAN_WIDTH*LAYER_WIDTH)>>8;
-  y = (ship.pos.y/SCAN_HEIGHT*LAYER_HEIGHT)>>8;
-  d = (ship.cnt*8)&(DIV/8-1); d -= DIV/4;
-  ic = ship.invCnt&31;
-  if ( ic > 0 && ic < 16 ) {
-    drawBox(x, y, SHIP_DRAW_WIDTH, SHIP_DRAW_WIDTH, 16*2-1, 16*4-5, buf);
-    return;
-  }
-  for ( i=0 ; i<4 ; i++ ) {
-    d &= (DIV-1);
-    drawBox(x+((sctbl[d]*SHIP_DRUM_WIDTH)>>8), y-((sctbl[d+DIV/4]*SHIP_DRUM_WIDTH)>>10), 
-	    SHIP_DRUM_SIZE, SHIP_DRUM_WIDTH*2, 16*3-10, 16*3-12, buf);
-    d += DIV/8;
-  }
-  drawBox(x, y, SHIP_DRAW_WIDTH, SHIP_DRAW_WIDTH, 16*2-1, 16*4-5, buf);
-  for ( i=0 ; i<4 ; i++ ) {
-    d &= (DIV-1);
-    drawBox(x+((sctbl[d]*SHIP_DRUM_WIDTH)>>8), y-((sctbl[d+DIV/4]*SHIP_DRUM_WIDTH)>>10), 
-	    SHIP_DRUM_SIZE, SHIP_DRUM_WIDTH*2, 16*3-7, 16*4-11, buf);
-    d += DIV/8;
-  }
-}
-
-void destroyShip() {
-  if ( status != IN_GAME || ship.invCnt > 0 ) return;
-  addShipFrag(&(ship.pos));
-  playChunk(4);
-  resetBonusScore();
-  if ( decrementShip() ) {
-    initGameover();
-  } else {
-    ship.invCnt = SHIP_INVINCIBLE_CNT_BASE*(100-scene)/100;
-    if ( ship.invCnt < 0 ) ship.invCnt = 0;
-    clearFoesZako();
-  }
-}
-
-int getPlayerDeg(int x, int y) {
-  return getDeg(ship.pos.x - x, ship.pos.y - y);
-}
+/*
+ * $Id: ship.c,v 1.5 2003/02/09 07:34:16 kenta Exp $
+ *
+ * Copyright 2002 Kenta Cho. All rights reserved.
+ */
+
+/**
+ * Handle player.
+ *
+ * @version $Revision: 1.5 $
+ */
+#include "SDL.h"
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "noiz2sa.h"
+#include "screen.h"
+#include "vector.h"
+#include "ship.h"
+#include "shot.h"
+#include "bonus.h"
+#include "foe_mtd.h"
+#include "degutil.h"
+#include "brgmng_mtd.h"
+#include "frag.h"
+#include "soundmanager.h"
+#include "attractmanager.h"
+
+Ship ship;
+
+#define SHIP_SPEED 1280
+#define SHIP_SLOW_SPEED 640
+#define SHIP_SLOW_DOWN 64
+
+#define SHIP_INVINCIBLE_CNT_BASE 240
+
+void initShip() {
+  ship.pos.x = (SCAN_WIDTH/2)<<8; ship.pos.y = (SCAN_HEIGHT/5*4)<<8;
+  ship.cnt = 0; ship.shotCnt = -1;
+  ship.speed = SHIP_SPEED;
+  ship.invCnt = SHIP_INVINCIBLE_CNT_BASE*(100-scene)/100;
+  if ( ship.invCnt < 0 ) ship.invCnt = 0;
+}
+
+#define SHOT_INTERVAL 3
+
+#define SHIP_SCAN_WIDTH 1024
+#define SHIP_SCREEN_EDGE_WIDTH 3
+
+static int shipMv[8][2] = {
+  {0, -256}, {181, -181}, {256, 0}, {181, 181}, {0, 256}, {-181, 181}, {-256, 0}, {-181, -181},  
+};
+
+void moveShip() {
+  int pad = getPadState();
+  int btn = getButtonState();
+  int sd = -1;
+  if ( pad & PAD_RIGHT ) {
+    sd = 2;
+  }
+  if ( pad & PAD_LEFT ) {
+    sd = 6;
+  }
+  if ( pad & PAD_DOWN ) {
+    switch ( sd ) {
+    case 2:
+      sd = 3;
+      break;
+    case 6:
+      sd = 5;
+      break;
+    default:
+      sd = 4;
+      break;
+    }
+  }
+  if ( pad & PAD_UP ) {
+    switch ( sd ) {
+    case 2:
+      sd = 1;
+      break;
+    case 6:
+      sd = 7;
+      break;
+    default:
+      sd = 0;
+      break;
+    }
+  }
+  if ( btn & PAD_BUTTON1 ) {
+    if ( ship.shotCnt < 0 && status == IN_GAME ) {
+      addShot(&(ship.pos));
+      ship.shotCnt = SHOT_INTERVAL;
+    }
+  }
+  ship.shotCnt--;
+  if ( btn & PAD_BUTTON2 ) {
+    if ( ship.speed > SHIP_SLOW_SPEED ) {
+      ship.speed -= SHIP_SLOW_DOWN;
+    }
+  } else {
+    if ( ship.speed < SHIP_SPEED ) {
+      ship.speed += SHIP_SLOW_DOWN;
+    }
+  }
+
+  if ( sd >= 0 ) {
+    ship.pos.x += (ship.speed*shipMv[sd][0])>>8;
+    ship.pos.y += (ship.speed*shipMv[sd][1])>>8;
+    if ( ship.pos.x < SHIP_SCAN_WIDTH*SHIP_SCREEN_EDGE_WIDTH ) {
+      ship.pos.x = SHIP_SCAN_WIDTH*SHIP_SCREEN_EDGE_WIDTH;
+    } else if ( ship.pos.x > SCAN_WIDTH_8-SHIP_SCAN_WIDTH*SHIP_SCREEN_EDGE_WIDTH ) {
+      ship.pos.x = SCAN_WIDTH_8-SHIP_SCAN_WIDTH*SHIP_SCREEN_EDGE_WIDTH;
+    }
+    if ( ship.pos.y < SHIP_SCAN_WIDTH*SHIP_SCREEN_EDGE_WIDTH ) {
+      ship.pos.y = SHIP_SCAN_WIDTH*SHIP_SCREEN_EDGE_WIDTH;
+    } else if ( ship.pos.y > SCAN_HEIGHT_8-SHIP_SCAN_WIDTH*SHIP_SCREEN_EDGE_WIDTH ) {
+      ship.pos.y = SCAN_HEIGHT_8-SHIP_SCAN_WIDTH*SHIP_SCREEN_EDGE_WIDTH;
+    }
+  }
+
+  ship.cnt++;
+  if ( ship.invCnt > 0 ) ship.invCnt--;
+}
+
+#define SHIP_DRAW_WIDTH (6 / SCREEN_DIVISOR)
+#define SHIP_DRUM_WIDTH (15 / SCREEN_DIVISOR)
+#define SHIP_DRUM_SIZE (4 / SCREEN_DIVISOR)
+
+void drawShip() {
+  int x, y, d;
+  int i;
+  int ic;
+  x = (ship.pos.x/SCAN_WIDTH*LAYER_WIDTH)>>8;
+  y = (ship.pos.y/SCAN_HEIGHT*LAYER_HEIGHT)>>8;
+  d = (ship.cnt*8)&(DIV/8-1); d -= DIV/4;
+  ic = ship.invCnt&31;
+  if ( ic > 0 && ic < 16 ) {
+    drawBox(x, y, SHIP_DRAW_WIDTH, SHIP_DRAW_WIDTH, 16*2-1, 16*4-5, buf);
+    return;
+  }
+  for ( i=0 ; i<4 ; i++ ) {
+    d &= (DIV-1);
+    drawBox(x+((sctbl[d]*SHIP_DRUM_WIDTH)>>8), y-((sctbl[d+DIV/4]*SHIP_DRUM_WIDTH)>>10), 
+	    SHIP_DRUM_SIZE, SHIP_DRUM_WIDTH*2, 16*3-10, 16*3-12, buf);
+    d += DIV/8;
+  }
+  drawBox(x, y, SHIP_DRAW_WIDTH, SHIP_DRAW_WIDTH, 16*2-1, 16*4-5, buf);
+  for ( i=0 ; i<4 ; i++ ) {
+    d &= (DIV-1);
+    drawBox(x+((sctbl[d]*SHIP_DRUM_WIDTH)>>8), y-((sctbl[d+DIV/4]*SHIP_DRUM_WIDTH)>>10), 
+	    SHIP_DRUM_SIZE, SHIP_DRUM_WIDTH*2, 16*3-7, 16*4-11, buf);
+    d += DIV/8;
+  }
+}
+
+void destroyShip() {
+  if ( status != IN_GAME || ship.invCnt > 0 ) return;
+  addShipFrag(&(ship.pos));
+  playChunk(4);
+  resetBonusScore();
+  if ( decrementShip() ) {
+    initGameover();
+  } else {
+    ship.invCnt = SHIP_INVINCIBLE_CNT_BASE*(100-scene)/100;
+    if ( ship.invCnt < 0 ) ship.invCnt = 0;
+    clearFoesZako();
+  }
+}
+
+int getPlayerDeg(int x, int y) {
+  return getDeg(ship.pos.x - x, ship.pos.y - y);
+}

Modified: trunk/user/games/noiz2sa/src/shot.h
===================================================================
--- tags/noiz2sa/noiz2sa-0.51a/src/shot.h	2008-04-05 00:17:39 UTC (rev 2211)
+++ trunk/user/games/noiz2sa/src/shot.h	2008-04-07 17:17:30 UTC (rev 2230)
@@ -1,31 +1,31 @@
-/*
- * $Id: shot.h,v 1.1.1.1 2002/11/03 11:08:24 kenta Exp $
- *
- * Copyright 2002 Kenta Cho. All rights reserved.
- */
-
-/**
- * Shot data.
- *
- * @version $Revision: 1.1.1.1 $
- */
-#include "vector.h"
-
-typedef struct {
-  Vector pos;
-  int cnt;
-} Shot;
-
-#define SHOT_MAX 16
-
-#define SHOT_SPEED 4096
-
-#define SHOT_WIDTH 8
-#define SHOT_HEIGHT 24
-
-extern Shot shot[];
-
-void initShots();
-void moveShots();
-void drawShots();
-void addShot(Vector *pos);
+/*
+ * $Id: shot.h,v 1.1.1.1 2002/11/03 11:08:24 kenta Exp $
+ *
+ * Copyright 2002 Kenta Cho. All rights reserved.
+ */
+
+/**
+ * Shot data.
+ *
+ * @version $Revision: 1.1.1.1 $
+ */
+#include "vector.h"
+
+typedef struct {
+  Vector pos;
+  int cnt;
+} Shot;
+
+#define SHOT_MAX 16
+
+#define SHOT_SPEED 4096
+
+#define SHOT_WIDTH (8 / SCREEN_DIVISOR)
+#define SHOT_HEIGHT (24 / SCREEN_DIVISOR)
+
+extern Shot shot[];
+
+void initShots();
+void moveShots();
+void drawShots();
+void addShot(Vector *pos);

Modified: trunk/user/games/noiz2sa/src/soundmanager.c
===================================================================
--- tags/noiz2sa/noiz2sa-0.51a/src/soundmanager.c	2008-04-05 00:17:39 UTC (rev 2211)
+++ trunk/user/games/noiz2sa/src/soundmanager.c	2008-04-07 17:17:30 UTC (rev 2230)
@@ -97,10 +97,10 @@
     return;
   }
 
-  audio_rate = 44100;
-  audio_format = AUDIO_S16;
-  audio_channels = 1;
-  audio_buffers = 4096;
+  audio_rate = 8192;
+  audio_format = AUDIO_S8;
+  audio_channels = 0;
+  audio_buffers = 16384;
 
   if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) {
     fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());



More information about the dslinux-commit mailing list