diff options
| -rw-r--r-- | Wolf3D.c | 186 | ||||
| -rw-r--r-- | calc.c | 33 | ||||
| -rw-r--r-- | calc.h | 21 | ||||
| -rw-r--r-- | draw.c | 299 | ||||
| -rw-r--r-- | draw.h | 20 | ||||
| -rw-r--r-- | engine.c | 848 | ||||
| -rw-r--r-- | engine.h | 10 | ||||
| -rw-r--r-- | global.c | 78 | ||||
| -rw-r--r-- | global.h | 68 | ||||
| -rw-r--r-- | hardware.c | 172 | ||||
| -rw-r--r-- | hardware.h | 43 | ||||
| -rw-r--r-- | key.c | 101 | ||||
| -rw-r--r-- | key.h | 57 | ||||
| -rw-r--r-- | ki.c | 167 | ||||
| -rw-r--r-- | ki.h | 9 | ||||
| -rw-r--r-- | mapgen.c | 414 | ||||
| -rw-r--r-- | mapgen.h | 18 | ||||
| -rw-r--r-- | menu.c | 132 | ||||
| -rw-r--r-- | menu.h | 6 | ||||
| -rw-r--r-- | sprites.c | 197 | ||||
| -rw-r--r-- | sprites.h | 16 | ||||
| -rw-r--r-- | syscalls.h | 25 | ||||
| -rw-r--r-- | syscalls.src | 34 |
23 files changed, 2954 insertions, 0 deletions
diff --git a/Wolf3D.c b/Wolf3D.c new file mode 100644 index 0000000..22f790f --- /dev/null +++ b/Wolf3D.c @@ -0,0 +1,186 @@ +/* wird zum Waffenwechsel werden.
+"Türen kann man nur öffnen" - was willst du sonst damit machen? Aufessen?
+*/
+
+#include "key.h"
+#include "global.h"
+#include "syscalls.h"
+#include "hardware.h"
+#include "mapgen.h"
+#include "ki.h"
+#include "engine.h"
+#include "sprites.h"
+
+#include "stdio.h"
+
+void main(void)
+{
+ char FPS[9];
+ char LIVE[13];
+ static int oldtime;
+ static int maintimer = 0;
+
+ if(RTC_Elapsed_ms(maintimer, 100))
+ {
+ maintimer = RTC_GetTicks();
+
+ if(player.health <= 50)
+ {
+ if(contrast > 10 || contrast < -10)
+ {
+ contradd *= -1;
+ }
+ contrast += contradd;
+ set_contrast(168 + contrast);
+ }
+
+ if(statustimer++ == 100)
+ {
+ statustimer = 0;
+ status = NULL;
+ }
+
+ if(BacklightIsOn() && statustimer % 5 == 0)
+ {
+ BacklightOff();
+ }
+ }
+
+ move();
+ if(output != 0)
+ {
+ unsigned int time;
+ oldtime = RTC_GetTicks();
+ clear_vram();
+ cast();
+
+ drawgun();
+
+ if(output == 2)
+ {
+ if(player.gunpos > 3 || player.gunpos < -3)
+ {
+ if(player.gunpos > 3)
+ player.gunpos = 3;
+
+ gundir *= -1;
+ }
+ player.gunpos += gundir;
+ }
+
+ sprintf(&FPS, "fps:%2.2f", 1 / fps);
+ PrintMini(0, 0, &FPS, MINI_OR);
+
+ sprintf(&LIVE, "health:%4d", player.health);
+ PrintMini(80, 0, &LIVE, MINI_OR);
+
+ if(status != NULL)PrintMini(0, 58, status, MINI_OR);
+
+ display_vram();
+ if(player.health <= 0)
+ {
+ exit = TRUE;
+ }
+ output = 0;
+
+ fps = (((RTC_GetTicks() * 15.625 - oldtime * 15.625)) / 1000);
+ }
+}
+
+int AddIn_main(int isAppli, unsigned short OptionNum)
+{
+ int c;
+ vram = Disp_GetVRAMPtr();
+
+ if(getCalc() == UNKNOWN)
+ {
+ clear_vram();
+ locate(1,1);
+ Print("Unknown hardware");
+ locate(1,2);
+ Print("detected.");
+ locate(1,3);
+ Print("All direct hardware");
+ locate(1,4);
+ Print("functions will be");
+ locate(1,5);
+ Print("disabled!");
+ locate(1,7);
+ Print("Press any key");
+ locate(1,8);
+ Print("to start the game");
+ GetKey(&c);
+ }
+
+ APP_EnableRestart();
+
+ table();
+ seedrandom();
+
+ if(ENEMYCNT)
+ {
+ sprites = (struct st_sprite *) malloc(ENEMYCNT * sizeof(struct st_sprite));
+ if(sprites == NULL)error();
+ }
+
+ spritecnt = ENEMYCNT;
+
+ for(c = 0; c < spritecnt; c++)
+ {
+ kisetpos(&sprites[c].x, &sprites[c].y);
+ sprites[c].texture.ptr = &enemy;
+ sprites[c].texture.width = 16;
+ sprites[c].texture.height = 32;
+ sprites[c].type = TYPE_ENEMY;
+ sprites[c].effect = 50;
+ }
+
+ maze();
+
+ player.x = 1.5;
+ player.y = 1.5;
+ player.dirX = -1;
+ player.dirY = 0;
+ player.planeX = 0;
+ player.planeY = 0.66;
+ player.weapon = GUN;
+ player.gunpos = 0;
+ player.health = 500;
+ contrast = 0;
+
+ Timer_Install(8, &timer, KISPEED);
+ Timer_Start(8);
+
+ exit = FALSE;
+
+ while(exit == FALSE)
+ {
+ main();
+ if((int)player.x == MAPSIZE - 1 && (int)player.y == MAPSIZE - 1)break;
+ }
+
+ Timer_Uninstall(8);
+ set_contrast(168);
+
+ if(player.health > 0 && exit == FALSE)
+ {
+ clear_vram();
+
+ locate(1, 1);
+ Print("You found the exit!");
+
+ display_vram();
+ Sleep(1000);
+ }
+ free(sprites);
+
+ Keyboard_ClrBuffer();
+}
+
+#pragma section _BR_Size
+unsigned long BR_Size;
+#pragma section
+#pragma section _TOP
+int InitializeSystem(int isAppli, unsigned short OptionNum)
+{return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}
+#pragma section
@@ -0,0 +1,33 @@ +#include "global.h"
+#include "calc.h"
+#include "syscalls.h"
+
+int TDist[64];
+
+static uint lastrandom = 0x123456;
+
+void seedrandom(void)
+{
+ lastrandom = RTC_GetTicks();
+}
+
+unsigned int random()
+{
+ lastrandom = (0x41C64E6D*lastrandom) + 0x3039;
+ return (lastrandom >> 16);
+}
+
+void table()
+{
+ int x;
+ for(x = 0; x < 64; x++)
+ {
+ TDist[x] = (64 << 8) / (2.0 * x - 64);
+ }
+}
+
+void fill(uint *ptr, uint element, uint arraysize)
+{
+ for(;arraysize > 0; arraysize--, ptr++)
+ *ptr = element;
+}
@@ -0,0 +1,21 @@ +#ifndef _CALC_H_
+#define _CALC_H_
+
+#define Abs(x) ((x < 0)? -x : x)
+#define degtorad(x) (x * 0.0174532925)
+#define sgn(x) ((int)((x > 0) ? 1 : (x == 0)?0:-1))
+
+#define GetBit(x, y) (x & (1 << y)) != 0
+#define SetBit(x, y) (x |= (1 << y))
+#define ClearBit(x, y) (x &= ~(1 << y))
+
+#define crand() random()
+
+void seedrandom(void);
+unsigned int random(void);
+void table(void);
+void fill(unsigned int *, unsigned int, unsigned int);
+
+extern int TDist[64];
+
+#endif
@@ -0,0 +1,299 @@ +#include "global.h"
+#include "draw.h"
+#include "sprites.h"
+#include "hardware.h"
+#include "key.h"
+#include "syscalls.h"
+
+int drawfloor = FALSE, drawheight = TRUE, drawtex = TRUE;
+
+void horizontal(int y, int x1, int x2)
+{
+ int checker, i;
+ if(y&~63 || (x1<0 && x2<0) || (x1>127 && x2>127)) return;
+ if(x1 < 0) x1 = 0;
+ if(x2 > 127) x2 = 127;
+ if(x1>>3 != x2>>3)
+ {
+ vram[(y<<4)+(x1>>3)] |= 255 >> (x1&7);
+ vram[(y<<4)+(x2>>3)] |= 255 << 7-(x2&7);
+ for(i=(x1>>3)+1 ; i<x2>>3 ; i++)
+ vram[(y<<4) + i] = 255;
+ }
+ else vram[(y<<4)+(x1>>3)] |= (255>>(x1%8 + 7-x2%8))<<(7-(x2&7));
+}
+
+void fillbox(int x1, int y1, int x2, int y2)
+{
+ int i;
+ if(x1 > x2)
+ {
+ i = x1;
+ x1 = x2;
+ x2 = i;
+ }
+ if(y1 > y2)
+ {
+ i = y1;
+ y1 = y2;
+ y2 = i;
+ }
+ for(i=y1 ; i<=y2 ; i++)
+ horizontal(i, x1, x2);
+}
+
+void locatePrintMini(int x, int y, const uchar *text)
+{
+ PrintMini((x - 2) * 6, (y - 2) * 8, text, 0);
+}
+
+void drawgenmap()
+{
+ int x, y;
+
+ for(x = 0; x < MAPSIZE; x++)
+ {
+ for(y = 0; y < MAPSIZE; y++)
+ {
+ if(map[x][y] == WALL || map[x][y] == CHECKED)
+ {
+ fillbox(x * sizex, y * sizey, (x + 1) * sizex, (y + 1) * sizey);
+ }
+ }
+ }
+}
+
+void showmap()
+{
+ int x, y, exit = FALSE;
+ int windowx = player.x, windowy = player.x, zoom = 8;
+ const char plsprite = 0xA9;
+ int lastkey, thiskey = 0;
+ do
+ {
+ int skew = 64 / zoom;
+
+ while(windowx + zoom * 2 >= MAPSIZE)
+ {
+ windowx--;
+ }
+
+ clear_vram();
+
+ for(x = windowx; x < windowx + zoom * 2; x++)
+ {
+ for(y = windowy; y < windowy + zoom; y++)
+ {
+ if(map[x][y] != SPACE)
+ {
+ fillbox((x - windowx) * skew, (y - windowy) * skew, (x + 1 - windowx) * skew, (y + 1 - windowy) * skew);
+ switch(map[x][y])
+ {
+ case WALL: break;
+ case DOOR:
+ PrintMini((x - windowx) * skew, (y - windowy) * skew, "I", MINI_OVER);
+ break;
+ }
+ }
+ else if(x == (int)player.x && y == (int)player.y)
+ {
+ PrintMini((player.x - windowx) * skew + 1, (player.y - windowy) * skew, &plsprite, MINI_OVER);
+ }
+ }
+ }
+
+ for(x = 0; x < spritecnt; x++)
+ {
+ if(sprites[x].x >= windowx && sprites[x].x < windowx + zoom * 2 && sprites[x].y >= windowy && sprites[x].y < windowy + zoom)
+ {
+ switch(sprites[x].type)
+ {
+ case TYPE_ENEMY:
+ PrintMini((sprites[x].x - windowx) * skew, (sprites[x].y - windowy) * skew, "!", MINI_OVER);
+ break;
+ case TYPE_PACK:
+ PrintMini((sprites[x].x - windowx) * skew, (sprites[x].y - windowy) * skew, "+", MINI_OVER);
+ break;
+ }
+ }
+ }
+
+ display_vram();
+
+ keyupdate();
+
+ if(lastkey != thiskey)
+ {
+ Sleep(500);
+ }
+ else if(lastkey == thiskey)
+ {
+ Sleep(125);
+ }
+
+ lastkey = thiskey;
+
+ if(keydown(KEY_CTRL_EXIT))exit = TRUE;
+ if(keydown(KEY_CTRL_UP) && windowy > 0)
+ {
+ windowy--;
+ thiskey = KEY_CTRL_UP;
+ }
+ if(keydown(KEY_CTRL_DOWN) && windowy + zoom < MAPSIZE)
+ {
+ windowy++;
+ thiskey = KEY_CTRL_DOWN;
+ }
+ if(keydown(KEY_CTRL_LEFT) && windowx > 0)
+ {
+ windowx--;
+ thiskey = KEY_CTRL_LEFT;
+ }
+ if(keydown(KEY_CTRL_RIGHT) && windowx + zoom * 2 < MAPSIZE)
+ {
+ windowx++;
+ thiskey = KEY_CTRL_RIGHT;
+ }
+ if(keydown(KEY_CHAR_PLUS) && zoom > 1)
+ {
+ zoom--;
+ thiskey = KEY_CHAR_PLUS;
+ }
+ if(keydown(KEY_CHAR_MINUS) && zoom < MAPSIZE / 2)
+ {
+ zoom++;
+ thiskey = KEY_CHAR_MINUS;
+ }
+ }while(exit == FALSE);
+}
+
+void drawgun()
+{
+ int i,u;
+
+ const int y = 47 + player.gunpos;
+
+ for(i = 0; i < 21; i++)
+ {
+ for(u = 0; u < 22; u++)
+ {
+ if(y + u <= 64)
+ {
+ switch(player.weapon)
+ {
+ case GUN:
+ if(gun[u][i] == 1)
+ {
+ (*(vram + ((y + u) << 4) + ((54 + i) >> 3))) |= (128 >> ((54 + i) & 7));
+ }
+ else
+ {
+ if(gun[u][i] == 2)
+ {
+ (*(vram + ((y + u) << 4) + ((54 + i) >> 3))) &= ( ~ (128 >> ((54 + i) & 7)));
+ }
+ }
+ break;
+
+ case KNIFE:
+ if(knife[u][i] == 1)
+ {
+ (*(vram + ((y + u) << 4) + ((54 + i) >> 3))) |= (128 >> ((54 + i) & 7));
+ }
+ else
+ {
+ if(knife[u][i] == 2)
+ {
+ (*(vram + ((y + u) << 4) + ((54 + i) >> 3))) &= ( ~ (128 >> ((54 + i) & 7)));
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+}
+
+void vertical(int x, int tex, int start, int end, int type, int color, float steps)
+{
+ int y = start;
+ int pos = 1 << 7, step;
+
+ uchar xbyte = x & 7;
+ uchar shiftbyte = (128 >> xbyte);
+ uchar *buffpos = (unsigned char*)(vram + (x >> 3));
+
+ if(drawtex == FALSE && type == 1)
+ {
+ if(start > end)
+ {
+ int tmp = start;
+ start = end;
+ end = tmp;
+ }
+ if(start < 0) start = 0;
+ if(end > 63) end = 63;
+
+ for(;start < end; start++)
+ pixel(x,start);
+ }
+
+ if(start > end)
+ {
+ int tmp = start;
+ start = end;
+ end = tmp;
+ }
+
+ switch(type)
+ {
+ case 1 :
+ if(steps == 0)
+ step = (16 << 8) / (end - start);
+ else
+ step = (16.0 / steps) * 128.0;
+
+ for(; y < end;pos += step, y++)
+ {
+ if(wall[color][pos >> 8][(int)(tex >> 2)] == 1)
+ (*(buffpos + (y << 4))) |= ((1 << 7) >> xbyte);
+ /*else
+ (*(buffpos + (y << 4))) &= ~((1 << 7) >> xbyte);*/
+ }
+ break;
+
+ case 2 :
+ if(steps == 0)
+ step = (16 << 8) / (end - start);
+ else
+ step = (16.0 / steps) * 128.0;
+
+ for(; y < end;pos += step, y ++)
+ {
+ (*(buffpos + (y << 4))) |= ((door[pos >> 8][(int)(tex >> 2)] << 7) >> xbyte);
+ }
+ break;
+
+ case 3 :
+ if(steps == 0)
+ step = (8 << 8) / (end - start);
+ else
+ step = (8.0 / steps) * 128.0;
+
+ for(; y < end;pos += step, y ++)
+ {
+ if(pack[pos >> 8][(int)(tex >> 3)] == 1)
+ {
+ (*(buffpos + (y << 4))) |= shiftbyte;
+ }
+ else
+ {
+ if(pack[pos >> 8][(int)(tex >> 3)] == 2)
+ {
+ (*(buffpos + (y << 4))) &= ( ~shiftbyte);
+ }
+ }
+ }
+ break;
+ }
+}
@@ -0,0 +1,20 @@ +#ifndef _DRAW_H_
+#define _DRAW_H_
+
+void locatePrintMini(int, int, const unsigned char *);
+
+#define pixel(x,y) (*(vram + (y << 4) + (x >> 3))) |= (128 >> (x & 7))
+#define clrpixel(x,y) (*(vram + (y << 4) + (x >> 3))) &= ~(128>>(x & 7))
+
+void vertical(int, int, int, int, int, int, float);
+
+void drawgun(void);
+void showmap(void);
+void drawgenmap(void);
+
+void horizontal(int, int, int);
+void fillbox(int, int, int, int);
+
+extern int drawtex, drawfloor, drawheight;
+
+#endif
\ No newline at end of file diff --git a/engine.c b/engine.c new file mode 100644 index 0000000..19a7cf9 --- /dev/null +++ b/engine.c @@ -0,0 +1,848 @@ +#include "global.h"
+#include "engine.h"
+#include "draw.h"
+#include "key.h"
+#include "calc.h"
+#include "hardware.h"
+#include "sprites.h"
+#include "menu.h"
+
+#include "mathf.h"
+
+float fps;
+
+void swap(float *a, float *b)
+{
+ float tmp = *a;
+ *a = *b;
+ *b = tmp;
+}
+
+void combSort(int* order, float* dist, int amount)
+{
+ int gap = amount, i;
+ int swapped = FALSE;
+ while(gap > 1 || swapped)
+ {
+ gap = (gap * 10) / 13;
+ if(gap == 9 || gap == 10) gap = 11;
+ if (gap < 1) gap = 1;
+ swapped = FALSE;
+ for (i = 0; i < amount - gap; i++)
+ {
+ int j = i + gap;
+ if (dist[i] < dist[j])
+ {
+ swap(&dist[i], &dist[j]);
+ swap(&order[i], &order[j]);
+ swapped = TRUE;
+ }
+ }
+ }
+}
+
+#define PI 3.141592653589793238464
+
+static void pshoot()
+{
+ float xadd, yadd, x, y;
+ int c;
+
+ for(c = 0; c < spritecnt; c++)
+ {
+ if(sprites[c].type == TYPE_ENEMY)
+ {
+ x = player.x;
+ y = player.y;
+ if(Abs(x - sprites[c].x) > Abs(y - sprites[c].y))
+ {
+ xadd = sgn(sprites[c].x - x);
+ yadd = ((sprites[c].y - y) / Abs(x - sprites[c].x));
+ }
+ else
+ {
+ xadd = ((sprites[c].x - x) / Abs(y - sprites[c].y));
+ yadd = sgn(sprites[c].y - y);
+ }
+
+ if(1/*TODOTODOTODOTODO*/)
+ {
+ while(x < MAPSIZE && y < MAPSIZE && x >= 0 && y >= 0)
+ {
+ x += xadd;
+ y += yadd;
+
+ if((int)y == (int)sprites[c].y && (int)x == (int)sprites[c].x)
+ {
+ sprites[c].effect -= 5;
+ if(sprites[c].effect <= 0)
+ {
+ sprites[c] = sprites[spritecnt];
+ sprites = (struct st_sprite *) realloc(sprites, spritecnt-- * sizeof(struct st_sprite));
+ if(sprites == NULL)error();
+ }
+ return;
+ }
+
+ if(solids[(int)(x + 0.5)][(int)(y + 0.5)] == SOLID)
+ {
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
+void move()
+{
+ float oldDirX, oldPlaneX, moveSpeed = fps * 1.25, rotSpeed = fps / 1.25;
+ float newx = 0, newy = 0;
+ keyupdate();
+ if(keydown(KEY_CTRL_DOWN) || keydown(KEY_CTRL_UP) || keydown(KEY_CTRL_LEFT) || keydown(KEY_CTRL_RIGHT))
+ {
+ if(keydown(KEY_CTRL_DOWN))
+ {
+ newy = player.y - (player.dirY * moveSpeed);
+ newx = player.x - (player.dirX * moveSpeed);
+ if(newx >= 0 && newx < MAPSIZE)
+ if(solids[(int)newx][(int)player.y] != SOLID)
+ {
+ player.x = newx;
+ }
+
+ if(newy >= 0 && newy < MAPSIZE)
+ if(solids[(int)player.x][(int)newy] != SOLID)
+ {
+ player.y = newy;
+ }
+ output = 2;
+ }
+ if(keydown(KEY_CTRL_UP))
+ {
+ newy = player.y + (player.dirY * moveSpeed);
+ newx = player.x + (player.dirX * moveSpeed);
+ if(newx >= 0 && newx < MAPSIZE)
+ if(solids[(int)newx][(int)player.y] != SOLID)
+ {
+ player.x = newx;
+ }
+ if(newy >= 0 && newy < MAPSIZE)
+ if(solids[(int)player.x][(int)newy] != SOLID)
+ {
+ player.y = newy;
+ }
+ output = 2;
+ }
+ if(keydown(KEY_CTRL_RIGHT))
+ {
+ oldDirX = player.dirX;
+ player.dirX = player.dirX * cosf(-rotSpeed) - player.dirY * sinf(-rotSpeed);
+ player.dirY = oldDirX * sinf(-rotSpeed) + player.dirY * cosf(-rotSpeed);
+ oldPlaneX = player.planeX;
+ player.planeX = player.planeX * cosf(-rotSpeed) - player.planeY * sinf(-rotSpeed);
+ player.planeY = oldPlaneX * sinf(-rotSpeed) + player.planeY * cosf(-rotSpeed);
+ output = (output < 2)?1:2;
+ }
+ if(keydown(KEY_CTRL_LEFT))
+ {
+ oldDirX = player.dirX;
+ player.dirX = player.dirX * cosf(rotSpeed) - player.dirY * sinf(rotSpeed);
+ player.dirY = oldDirX * sinf(rotSpeed) + player.dirY * cosf(rotSpeed);
+ oldPlaneX = player.planeX;
+ player.planeX = player.planeX * cosf(rotSpeed) - player.planeY * sinf(rotSpeed);
+ player.planeY = oldPlaneX * sinf(rotSpeed) + player.planeY * cosf(rotSpeed);
+ output = (output < 2)?1:2;
+ }
+ if(solids[(int)newx][(int)newy] == SPRITE)
+ {
+ int c;
+ for(c = 0; c < spritecnt; c++)
+ {
+ if(sprites[c].type == TYPE_PACK && (int)sprites[c].x == (int)newx && (int)sprites[c].y == (int)newy)
+ {
+ solids[(int)newx][(int)newy] = UNSOLID;
+ player.health += sprites[c].effect;
+
+ sprites[c] = sprites[spritecnt];
+ sprites = (struct st_sprite *) realloc(sprites, spritecnt-- * sizeof(struct st_sprite));
+ if(sprites == NULL)error();
+
+ output = 2;
+ status = packmsg;
+ statustimer = 0;
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ if(keydown(KEY_CTRL_MENU))
+ {
+ openmenu();
+ output = (output < 2)?1:2;
+ return;
+ }
+ }
+
+ if(keydown(KEY_CTRL_SHIFT))
+ {
+ switch(player.weapon)
+ {
+ case GUN:
+ pshoot();
+ break;
+ /*case KNIFE:
+ newy = player.y + player.dirY;
+ newx = player.x + player.dirX;
+ if(newx >= 0 && newx < MAPSIZE)
+ if(map[(int)(newx)][(int)(newy)] >= 10)
+ {enemies[map[(int)(newx)][(int)(newy)] - 10].health -= 15;}
+ break;*/
+ }
+
+ output = 2;
+ }
+ if(keydown(KEY_CTRL_ALPHA))
+ {
+ newy = player.y + player.dirY;
+ newx = player.x + player.dirX;
+ if(newx >= 0 && newx < MAPSIZE)
+ {
+ if(map[(int)(newx)][(int)(newy)] == DOOR)
+ {
+ map[(int)(newx)][(int)(newy)] = SPACE;
+ solids[(int)newx][(int)newy] = UNSOLID;
+ }
+ }
+ output = (output < 2)?1:2;
+ }
+ if(keydown(KEY_CTRL_OPTN))
+ {
+ player.weapon += 1;
+ if(player.weapon == WEAPON_OVERFLOW)
+ player.weapon = GUN;
+ }
+}
+
+void cast()
+{
+ float cameraX,rayDirX, rayDirY, sideDistX, sideDistY, deltaDistX, deltaDistY, perpWallDist, wallX, floorXWall, floorYWall, distWall;
+ int mapX, mapY, lineHeight, hit, side, x, tex, y, black, floorTexX, floorTexY, actualheight, heightdiff;
+ int stepX, drawStart, drawEnd, stepY;
+ int weight, currentFloorX, currentFloorY;
+ float ZBuffer[128], *spriteDist;
+ int *spriteOrder, *spritedrawn;
+ int foundsprite = FALSE, spritehere;
+
+ spriteDist = (float *) calloc(spritecnt, sizeof(float));
+ if(spriteDist == NULL)error();
+ spriteOrder = (int *) calloc(spritecnt, sizeof(int));
+ if(spriteOrder == NULL)error();
+
+ for(x = 0; x < spritecnt; x++)
+ {
+ spriteOrder[x] = x;
+ spriteDist[x] = ((player.x - sprites[x].x) * (player.x - sprites[x].x) + (player.y - sprites[x].y) * (player.y - sprites[x].y));
+ }
+
+ combSort(spriteOrder, spriteDist, spritecnt);
+ free(spriteDist);
+
+ spritedrawn = (int *) calloc(spritecnt, sizeof(int));
+
+ for(x = 0; x < 128; x++)
+ {
+ mapX = player.x;
+ mapY = player.y;
+
+ cameraX = x / 64.0 - 1;
+ rayDirX = player.dirX + player.planeX * cameraX;
+ rayDirY = player.dirY + player.planeY * cameraX;
+
+ deltaDistX = sqrtf(1 + (rayDirY * rayDirY) / (rayDirX * rayDirX));
+ deltaDistY = sqrtf(1 + (rayDirX * rayDirX) / (rayDirY * rayDirY));
+
+ hit = FALSE;
+ if (rayDirX < 0)
+ {
+ stepX = -1;
+ sideDistX = (player.x - mapX) * deltaDistX;
+ }
+ else
+ {
+ stepX = 1;
+ sideDistX = (mapX + 1.0 - player.x) * deltaDistX;
+ }
+ if (rayDirY < 0)
+ {
+ stepY = -1;
+ sideDistY = (player.y - mapY) * deltaDistY;
+ }
+ else
+ {
+ stepY = 1;
+ sideDistY = (mapY + 1.0 - player.y) * deltaDistY;
+ }
+
+ actualheight = 0;
+
+ spritehere = FALSE;
+
+ while (mapX < MAPSIZE && mapY < MAPSIZE && mapX >= 0 && mapY >= 0 && hit == 0)
+ {
+ if (sideDistX < sideDistY)
+ {
+ sideDistX += deltaDistX;
+ mapX += stepX;
+ side = 0;
+ }
+ else
+ {
+ sideDistY += deltaDistY;
+ mapY += stepY;
+ side = 1;
+ }
+
+ if(solids[mapX][mapY] == SPRITE)
+ {
+ foundsprite = TRUE;
+ spritehere = TRUE;
+ }
+
+ if(solids[mapX][mapY] == SOLID)
+ {
+ if(heights[mapX][mapY] == 0 || drawheight == FALSE)
+ {
+ hit = TRUE;
+ }
+ else
+ {
+ if (side == 0)
+ perpWallDist = Abs((mapX - player.x + (1 - stepX) / 2) / rayDirX);
+ else
+ perpWallDist = Abs((mapY - player.y + (1 - stepY) / 2) / rayDirY);
+
+ lineHeight = Abs((int)((32 - heights[mapX][mapY] )/ perpWallDist));
+
+ if(side == 1) wallX = player.x + ((mapY - player.y + (1 - stepY) / 2) / rayDirY) * rayDirX;
+ else wallX = player.y + ((mapX - player.x + (1 - stepX) / 2) / rayDirX) * rayDirY;
+ wallX -= floorf((wallX));
+
+ tex = (int)(wallX * 64);
+
+ drawStart = 32 - (lineHeight >> 1);
+ if(drawStart < 0) drawStart = 0;
+ drawEnd = (actualheight == 0)?32 + (Abs((int)(64 / perpWallDist)) >> 1):actualheight;
+ if(drawEnd >= 64) drawEnd = 63;
+
+ vertical(x, tex , drawStart, drawEnd, map[mapX][mapY], side, Abs((32 + (Abs((int)(64 / perpWallDist)) >> 1)) - (32 - (Abs((int)(64 / perpWallDist)) >> 1))));
+
+ if(side == 0 && rayDirX > 0)
+ {
+ floorXWall = mapX;
+ floorYWall = mapY + wallX;
+ }
+ else if(side == 0 && rayDirX < 0)
+ {
+ floorXWall = mapX + 1.0;
+ floorYWall = mapY + wallX;
+ }
+ else if(side == 1 && rayDirY > 0)
+ {
+ floorXWall = mapX + wallX;
+ floorYWall = mapY;
+ }
+ else
+ {
+ floorXWall = mapX + wallX;
+ floorYWall = mapY + 1.0;
+ }
+
+ distWall = perpWallDist;
+
+ if(drawfloor == TRUE && actualheight == 0)
+ {
+ for(y = drawEnd + 1; y < 64; y++)
+ {
+ weight = TDist[y] / distWall;
+
+ currentFloorX = (weight * floorXWall) + ((1 << 8) - weight) * player.x;
+ currentFloorY = (weight * floorYWall) + ((1 << 8) - weight) * player.y;
+
+ floorTexX = (currentFloorX >> 4) % 16;
+ floorTexY = (currentFloorY >> 4) % 16;
+
+ black = ((int)(currentFloorX >> 8) + (int)(currentFloorY >> 8)) % 2;
+
+ if(floor[floorTexY][floorTexX] == black)
+ (*(vram + (y << 4) + (x >> 3))) |= (128 >> (x & 7));
+ }
+ }
+ actualheight = drawStart;
+ }
+ }
+ }
+
+ if(hit == TRUE)
+ {
+ if (side == 0)
+ perpWallDist = Abs((mapX - player.x + (1 - stepX) / 2) / rayDirX);
+ else
+ perpWallDist = Abs((mapY - player.y + (1 - stepY) / 2) / rayDirY);
+
+ ZBuffer[x] = perpWallDist;
+
+ lineHeight = Abs((int)(64 / perpWallDist));
+
+ if(side == 1) wallX = player.x + ((mapY - player.y + (1 - stepY) / 2) / rayDirY) * rayDirX;
+ else wallX = player.y + ((mapX - player.x + (1 - stepX) / 2) / rayDirX) * rayDirY;
+ wallX -= floorf((wallX));
+
+ tex = (int)(wallX * 64);
+
+ drawStart = 32 - (lineHeight >> 1);
+ if(drawStart < 0) drawStart = 0;
+ drawEnd = (actualheight == 0)?(lineHeight >> 1) + 32:actualheight;
+ if(drawEnd >= 64) drawEnd = 63;
+
+ vertical(x, tex , drawStart, drawEnd, map[mapX][mapY], side, (actualheight > 0)?((lineHeight >> 1) + 32) - (32 - (lineHeight >> 1)):0);
+
+ if(drawfloor == TRUE)
+ {
+ if(side == 0 && rayDirX > 0)
+ {
+ floorXWall = mapX;
+ floorYWall = mapY + wallX;
+ }
+ else if(side == 0 && rayDirX < 0)
+ {
+ floorXWall = mapX + 1.0;
+ floorYWall = mapY + wallX;
+ }
+ else if(side == 1 && rayDirY > 0)
+ {
+ floorXWall = mapX + wallX;
+ floorYWall = mapY;
+ }
+ else
+ {
+ floorXWall = mapX + wallX;
+ floorYWall = mapY + 1.0;
+ }
+
+ distWall = perpWallDist;
+
+ for(y = drawEnd + 1; y < 64; y++)
+ {
+ weight = TDist[y] / distWall;
+
+ currentFloorX = (weight * floorXWall) + ((1 << 8) - weight) * player.x;
+ currentFloorY = (weight * floorYWall) + ((1 << 8) - weight) * player.y;
+
+ floorTexX = (currentFloorX >> 4) % 16;
+ floorTexY = (currentFloorY >> 4) % 16;
+
+ black = ((int)(currentFloorX >> 8) + (int)(currentFloorY >> 8)) % 2;
+
+ if(drawtex == TRUE)
+ {
+ if(floor[floorTexY][floorTexX] == black && y < 64 - actualheight)
+ (*(vram + (y << 4) + (x >> 3))) |= (128 >> (x & 7));
+ if(ceiling[floorTexY][floorTexX] == black)
+ (*(vram + (64 - y << 4) + (x >> 3))) |= (128 >> (x & 7));
+ }
+ else
+ {
+ if(black)
+ {
+ if(y < 64 - actualheight)
+ (*(vram + (y << 4) + (x >> 3))) |= (128 >> (x & 7));
+ }
+ else
+ (*(vram + (64 - y << 4) + (x >> 3))) |= (128 >> (x & 7));
+ }
+ }
+ }
+ }
+ }
+
+ #define uDiv 1
+ #define vDiv 1
+ #define vMove 0.0
+
+ for(x = 0; x < spritecnt; x++)
+ {
+ float spriteX = sprites[spriteOrder[x]].x - player.x;
+ float spriteY = sprites[spriteOrder[x]].y - player.y;
+ float invDet = 1.0 / (player.planeX * player.dirY - player.dirX * player.planeY);
+ float transformX = invDet * (player.dirY * spriteX - player.dirX * spriteY);
+ float transformY = invDet * (-player.planeY * spriteX + player.planeX * spriteY);
+ int vMoveScreen = (int)(vMove / transformY);
+ int spriteScreenX = (int)(64 * (1 + transformX / transformY));
+ int spriteHeight = Abs((int)(64 / transformY)) / vDiv;
+ int drawStartY = -spriteHeight / 2 + 32 + vMoveScreen;
+ int drawEndY = spriteHeight / 2 + 32 + vMoveScreen;
+ int spriteWidth = Abs((int)(64 / transformY)) / uDiv;
+ int drawStartX = -spriteWidth / 2 + spriteScreenX;
+ int drawEndX = spriteWidth / 2 + spriteScreenX;
+ int stripe;
+ int y;
+
+ if(drawStartY < 0)drawStartY = 0;
+ if(drawEndY > 63)drawEndY = 63;
+ if(drawStartX < 0)drawStartX = 0;
+ if(drawEndX > 127)drawEndX = 127;
+
+ for(stripe = drawStartX; stripe < drawEndX; stripe++)
+ {
+ int texX = (int)(256 * (stripe - (-spriteWidth / 2 + spriteScreenX)) * sprites[spriteOrder[x]].texture.width / spriteWidth) / 256;
+
+ if(transformY > 0 && stripe > 0 && stripe < 128 && transformY < ZBuffer[stripe])
+ {
+ for(y = drawStartY; y < drawEndY; y++)
+ {
+ int d = (y - vMoveScreen) * 256 - 8192 + spriteHeight * 128;
+ int texY = ((d * sprites[spriteOrder[x]].texture.height) / spriteHeight) / 256;
+
+ if(sprites[spriteOrder[x]].texture.ptr[texY * sprites[spriteOrder[x]].texture.width + texX] == 1)
+ {
+ pixel(stripe, y);
+ }
+ else
+ {
+ if(sprites[spriteOrder[x]].texture.ptr[texY * sprites[spriteOrder[x]].texture.width + texX] == 2)
+ {
+ clrpixel(stripe, y);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ free(spriteOrder);
+}
+/*void cast()
+{
+ float cameraX,rayDirX, rayDirY, sideDistX, sideDistY, deltaDistX, deltaDistY, perpWallDist, wallX, floorXWall, floorYWall, distWall;
+ int mapX, mapY, lineHeight, hit, side, x, tex, y, black, floorTexX, floorTexY, actualheight, heightdiff;
+ int stepX, drawStart, drawEnd, stepY;
+ int weight, currentFloorX, currentFloorY;
+ float *ZBuffer[128], *spriteDist;
+ int *highest[128], dims[128] = {0};
+ int *spriteOrder;
+ int foundsprite = FALSE, spritehere;
+
+ for(x = 0; x < 128; x++)
+ {
+ highest[x] = NULL;
+ ZBuffer[x] = NULL;
+
+ mapX = player.x;
+ mapY = player.y;
+
+ cameraX = x / 64.0 - 1;
+ rayDirX = player.dirX + player.planeX * cameraX;
+ rayDirY = player.dirY + player.planeY * cameraX;
+
+ deltaDistX = sqrtf(1 + (rayDirY * rayDirY) / (rayDirX * rayDirX));
+ deltaDistY = sqrtf(1 + (rayDirX * rayDirX) / (rayDirY * rayDirY));
+
+ hit = FALSE;
+ if (rayDirX < 0)
+ {
+ stepX = -1;
+ sideDistX = (player.x - mapX) * deltaDistX;
+ }
+ else
+ {
+ stepX = 1;
+ sideDistX = (mapX + 1.0 - player.x) * deltaDistX;
+ }
+ if (rayDirY < 0)
+ {
+ stepY = -1;
+ sideDistY = (player.y - mapY) * deltaDistY;
+ }
+ else
+ {
+ stepY = 1;
+ sideDistY = (mapY + 1.0 - player.y) * deltaDistY;
+ }
+
+ actualheight = 0;
+
+ spritehere = FALSE;
+
+ while (mapX < MAPSIZE && mapY < MAPSIZE && mapX >= 0 && mapY >= 0 && hit == 0)
+ {
+ if (sideDistX < sideDistY)
+ {
+ sideDistX += deltaDistX;
+ mapX += stepX;
+ side = 0;
+ }
+ else
+ {
+ sideDistY += deltaDistY;
+ mapY += stepY;
+ side = 1;
+ }
+
+ if(solids[mapX][mapY] == SPRITE)
+ {
+ foundsprite = TRUE;
+ spritehere = TRUE;
+ }
+
+ if(solids[mapX][mapY] == SOLID)
+ {
+ if(heights[mapX][mapY] == 0 || drawheight == FALSE)
+ {
+ hit = TRUE;
+ }
+ else
+ {
+ if (side == 0)
+ perpWallDist = Abs((mapX - player.x + (1 - stepX) / 2) / rayDirX);
+ else
+ perpWallDist = Abs((mapY - player.y + (1 - stepY) / 2) / rayDirY);
+
+ ZBuffer[x] = (float *) realloc(ZBuffer[x], ++dims[x] * sizeof(float));
+ *(ZBuffer[x] + dims[x] - 1) = perpWallDist;
+
+ lineHeight = Abs((int)((32 - heights[mapX][mapY] )/ perpWallDist));
+
+ if(side == 1) wallX = player.x + ((mapY - player.y + (1 - stepY) / 2) / rayDirY) * rayDirX;
+ else wallX = player.y + ((mapX - player.x + (1 - stepX) / 2) / rayDirX) * rayDirY;
+ wallX -= floorf((wallX));
+
+ tex = (int)(wallX * 64);
+
+ drawStart = 32 - (lineHeight >> 1);
+ if(drawStart < 0) drawStart = 0;
+ drawEnd = (actualheight == 0)?32 + (Abs((int)(64 / perpWallDist)) >> 1):actualheight;
+ if(drawEnd >= 64) drawEnd = 63;
+
+ vertical(x, tex , drawStart, drawEnd, map[mapX][mapY], side, Abs((32 + (Abs((int)(64 / perpWallDist)) >> 1)) - (32 - (Abs((int)(64 / perpWallDist)) >> 1))));
+
+ if(side == 0 && rayDirX > 0)
+ {
+ floorXWall = mapX;
+ floorYWall = mapY + wallX;
+ }
+ else if(side == 0 && rayDirX < 0)
+ {
+ floorXWall = mapX + 1.0;
+ floorYWall = mapY + wallX;
+ }
+ else if(side == 1 && rayDirY > 0)
+ {
+ floorXWall = mapX + wallX;
+ floorYWall = mapY;
+ }
+ else
+ {
+ floorXWall = mapX + wallX;
+ floorYWall = mapY + 1.0;
+ }
+
+ distWall = perpWallDist;
+
+ if(drawfloor == TRUE && actualheight == 0)
+ {
+ for(y = drawEnd + 1; y < 64; y++)
+ {
+ weight = TDist[y] / distWall;
+
+ currentFloorX = (weight * floorXWall) + ((1 << 8) - weight) * player.x;
+ currentFloorY = (weight * floorYWall) + ((1 << 8) - weight) * player.y;
+
+ floorTexX = (currentFloorX >> 4) % 16;
+ floorTexY = (currentFloorY >> 4) % 16;
+
+ black = ((int)(currentFloorX >> 8) + (int)(currentFloorY >> 8)) % 2;
+
+ if(floor[floorTexY][floorTexX] == black)
+ (*(vram + (y << 4) + (x >> 3))) |= (128 >> (x & 7));
+ }
+ }
+ actualheight = drawStart;
+
+ highest[x] = (int *) realloc(highest[x], dims[x] * sizeof(int));
+ *(highest[x] + dims[x] - 1) = actualheight;
+ }
+ }
+ }
+
+ if(hit == TRUE)
+ {
+ if (side == 0)
+ perpWallDist = Abs((mapX - player.x + (1 - stepX) / 2) / rayDirX);
+ else
+ perpWallDist = Abs((mapY - player.y + (1 - stepY) / 2) / rayDirY);
+
+ ZBuffer[x] = (float *) realloc(ZBuffer[x], ++dims[x] * sizeof(float));
+ *(ZBuffer[x] + dims[x] - 1) = perpWallDist;
+ highest[x] = (int *) realloc(highest[x], dims[x] * sizeof(int));
+ *(highest[x] + dims[x] - 1) = actualheight;
+
+
+ lineHeight = Abs((int)(64 / perpWallDist));
+
+ if(side == 1) wallX = player.x + ((mapY - player.y + (1 - stepY) / 2) / rayDirY) * rayDirX;
+ else wallX = player.y + ((mapX - player.x + (1 - stepX) / 2) / rayDirX) * rayDirY;
+ wallX -= floorf((wallX));
+
+ tex = (int)(wallX * 64);
+
+ drawStart = 32 - (lineHeight >> 1);
+ if(drawStart < 0) drawStart = 0;
+ drawEnd = (actualheight == 0)?(lineHeight >> 1) + 32:actualheight;
+ if(drawEnd >= 64) drawEnd = 63;
+
+ vertical(x, tex , drawStart, drawEnd, map[mapX][mapY], side, (actualheight > 0)?((lineHeight >> 1) + 32) - (32 - (lineHeight >> 1)):0);
+
+ if(drawfloor == TRUE)
+ {
+ if(side == 0 && rayDirX > 0)
+ {
+ floorXWall = mapX;
+ floorYWall = mapY + wallX;
+ }
+ else if(side == 0 && rayDirX < 0)
+ {
+ floorXWall = mapX + 1.0;
+ floorYWall = mapY + wallX;
+ }
+ else if(side == 1 && rayDirY > 0)
+ {
+ floorXWall = mapX + wallX;
+ floorYWall = mapY;
+ }
+ else
+ {
+ floorXWall = mapX + wallX;
+ floorYWall = mapY + 1.0;
+ }
+
+ distWall = perpWallDist;
+
+ for(y = drawEnd + 1; y < 64; y++)
+ {
+ weight = TDist[y] / distWall;
+
+ currentFloorX = (weight * floorXWall) + ((1 << 8) - weight) * player.x;
+ currentFloorY = (weight * floorYWall) + ((1 << 8) - weight) * player.y;
+
+ floorTexX = (currentFloorX >> 4) % 16;
+ floorTexY = (currentFloorY >> 4) % 16;
+
+ black = ((int)(currentFloorX >> 8) + (int)(currentFloorY >> 8)) % 2;
+
+ if(drawtex == TRUE)
+ {
+ if(floor[floorTexY][floorTexX] == black && y < 64 - actualheight)
+ (*(vram + (y << 4) + (x >> 3))) |= (128 >> (x & 7));
+ if(ceiling[floorTexY][floorTexX] == black)
+ (*(vram + (64 - y << 4) + (x >> 3))) |= (128 >> (x & 7));
+ }
+ else
+ {
+ if(black)
+ {
+ if(y < 64 - actualheight)
+ (*(vram + (y << 4) + (x >> 3))) |= (128 >> (x & 7));
+ }
+ else
+ (*(vram + (64 - y << 4) + (x >> 3))) |= (128 >> (x & 7));
+ }
+ }
+ }
+ }
+ }
+
+ if(foundsprite == TRUE)
+ {
+ spriteDist = (float *) calloc(spritecnt, sizeof(float));
+ if(spriteDist == NULL)error();
+ spriteOrder = (int *) calloc(spritecnt, sizeof(int));
+ if(spriteOrder == NULL)error();
+
+ for(x = 0; x < spritecnt; x++)
+ {
+ spriteOrder[x] = x;
+ spriteDist[x] = ((player.x - sprites[x].x) * (player.x - sprites[x].x) + (player.y - sprites[x].y) * (player.y - sprites[x].y));
+ }
+
+ combSort(spriteOrder, spriteDist, spritecnt);
+
+ #define uDiv 1
+ #define vDiv 1
+ #define vMove 0.0
+
+ for(x = 0; x < spritecnt; x++)
+ {
+ float spriteX = sprites[spriteOrder[x]].x - player.x;
+ float spriteY = sprites[spriteOrder[x]].y - player.y;
+ float invDet = 1.0 / (player.planeX * player.dirY - player.dirX * player.planeY);
+ float transformX = invDet * (player.dirY * spriteX - player.dirX * spriteY);
+ float transformY = invDet * (-player.planeY * spriteX + player.planeX * spriteY);
+ int vMoveScreen = (int)(vMove / transformY);
+ int spriteScreenX = (int)(64 * (1 + transformX / transformY));
+ int spriteHeight = Abs((int)(64 / transformY)) / vDiv;
+ int drawStartY = -spriteHeight / 2 + 32 + vMoveScreen;
+ int drawEndY = spriteHeight / 2 + 32 + vMoveScreen;
+ int spriteWidth = Abs((int)(64 / transformY)) / uDiv;
+ int drawStartX = -spriteWidth / 2 + spriteScreenX;
+ int drawEndX = spriteWidth / 2 + spriteScreenX;
+ int stripe;
+ int y;
+
+ if(drawStartY < 0)drawStartY = 0;
+ if(drawEndY > 63)drawEndY = 63;
+ if(drawStartX < 0)drawStartX = 0;
+ if(drawEndX > 127)drawEndX = 127;
+
+ //if(drawEndY > highest[x] && highest[x] != 0)drawEndY = highest[x];
+
+ for(stripe = drawStartX; stripe < drawEndX; stripe++)
+ {
+ int texX = (int)(256 * (stripe - (-spriteWidth / 2 + spriteScreenX)) * sprites[spriteOrder[x]].texture.width / spriteWidth) / 256, c = 0;
+
+ do
+ {
+ c++;
+ }while(*(ZBuffer[stripe] + c) != spriteDist[x] && c < dims[stripe]);
+
+ if(drawEndY > *(highest[x] + c))drawEndY = *(highest[x] + c);
+
+ if(transformY > 0 && stripe > 0 && stripe < 128 && transformY < *(ZBuffer[stripe] + c))
+ {
+ for(y = drawStartY; y < drawEndY; y++)
+ {
+ int d = (y - vMoveScreen) * 256 - 8192 + spriteHeight * 128;
+ int texY = ((d * sprites[spriteOrder[x]].texture.height) / spriteHeight) / 256;
+
+ if(sprites[spriteOrder[x]].texture.ptr[texY * sprites[spriteOrder[x]].texture.width + texX] == 1)
+ {
+ pixel(stripe, y);
+ }
+ else
+ {
+ if(sprites[spriteOrder[x]].texture.ptr[texY * sprites[spriteOrder[x]].texture.width + texX] == 2)
+ {
+ clrpixel(stripe, y);
+ }
+ }
+ }
+ }
+ }
+ }
+ free(spriteOrder);
+ free(spriteDist);
+ }
+}
+*/
\ No newline at end of file diff --git a/engine.h b/engine.h new file mode 100644 index 0000000..cde8f5e --- /dev/null +++ b/engine.h @@ -0,0 +1,10 @@ +#ifndef _ENGINE_H_
+#define _ENGINE_H_
+
+extern float fps;
+extern unsigned int time, oldtime;
+
+void cast(void);
+void move(void);
+
+#endif
\ No newline at end of file diff --git a/global.c b/global.c new file mode 100644 index 0000000..4f9e618 --- /dev/null +++ b/global.c @@ -0,0 +1,78 @@ +#include "global.h"
+#include "hardware.h"
+
+const uint sizex = 128 / MAPSIZE, sizey = 64 / MAPSIZE;
+int output = 1;
+
+int contrast = 0;
+int contradd = 5;
+
+int gundir = 1;
+
+int exit = FALSE;
+int demo = FALSE;
+
+struct st_sprite *sprites = NULL;
+struct st_player player;
+uint spritecnt = 0;
+
+const char *status = NULL;
+unsigned int statustimer = 0;
+
+uint map[MAPSIZE][MAPSIZE] = {0};/*
+{
+ { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 },
+ { 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 2 , 0 , 0 , 0 , 0 , 1 },
+ { 1 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 0 , 1 , 0 , 1 , 1 , 1 , 0 , 1 , 1 , 1 , 0 , 1 },
+ { 1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 1 },
+ { 1 , 0 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 },
+ { 1 , 0 , 2 , 0 , 1 , 0 , 2 , 0 , 0 , 0 , 2 , 1 , 1 , 1 , 1 , 0 , 0 , 0 , 0 , 1 },
+ { 1 , 0 , 1 , 0 , 0 , 0 , 1 , 1 , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 1 , 0 , 1 },
+ { 1 , 0 , 0 , 1 , 1 , 1 , 0 , 0 , 2 , 1 , 0 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 0 , 1 },
+ { 1 , 1 , 3 , 1 , 0 , 0 , 0 , 1 , 1 , 1 , 0 , 1 , 0 , 2 , 0 , 0 , 0 , 2 , 0 , 1 },
+ { 1 , 1 , 1 , 0 , 0 , 1 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 1 , 1 , 1 , 1 , 0 , 1 , 1 },
+ { 1 , 0 , 0 , 3 , 1 , 3 , 1 , 0 , 1 , 1 , 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, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
+ { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
+ { 0 , 0 , 32 , 0 , 0 , 0 , 0 , 0 , 0 , 32 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
+ { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
+ { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 32 , 0 , 0 , 0 , 0 },
+ { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
+};*/
+
+uint solids[MAPSIZE][MAPSIZE] = {0};
+
+void error(void)
+{
+ clear_vram();
+ PrintMini(1,1, "ERROR!");
+ display_vram();
+ while(1);
+}
diff --git a/global.h b/global.h new file mode 100644 index 0000000..d76cb76 --- /dev/null +++ b/global.h @@ -0,0 +1,68 @@ +#ifndef _GLOBAL_H_
+#define _GLOBAL_H_
+
+#define MAPSIZE 21
+
+#define ENEMYCNT 10
+
+#define TYPE_ENEMY 1
+#define TYPE_PACK 2
+
+#define UNSOLID 0
+#define SOLID 1
+#define SPRITE 2
+
+#define SPACE 0
+#define WALL 1
+#define DOOR 2
+
+#define CHECKED 5
+
+#define GUN 1
+#define KNIFE 2
+
+#define WEAPON_OVERFLOW 3
+
+#define NORTH 0
+#define EAST 1
+#define SOUTH 2
+#define WEST 3
+
+#define TRUE 0xFF
+#define FALSE 0
+
+#define NULL (void *) 0
+
+typedef unsigned short int usint;
+typedef unsigned short ushort;
+typedef unsigned char uchar;
+typedef unsigned int uint;
+typedef short int sint;
+typedef unsigned char bool;
+
+extern uint map[MAPSIZE][MAPSIZE];
+extern int heights[MAPSIZE][MAPSIZE];
+extern uint solids[MAPSIZE][MAPSIZE];
+
+extern int output;
+extern int exit;
+extern int demo;
+
+extern int contrast;
+extern int contradd;
+
+extern int gundir;
+
+extern const uint sizex, sizey;
+
+extern struct st_player{float dirX, dirY, planeX, planeY, x, y; int weapon, gunpos, health;} player;
+extern struct st_sprite{float x, y; int type, effect; struct{int *ptr; uint width, height;} texture;} *sprites;
+
+extern uint spritecnt;
+
+void error(void);
+
+extern const char *status;
+extern unsigned int statustimer;
+
+#endif
\ No newline at end of file diff --git a/hardware.c b/hardware.c new file mode 100644 index 0000000..846a390 --- /dev/null +++ b/hardware.c @@ -0,0 +1,172 @@ +#include "global.h"
+#include "hardware.h"
+
+char *vram, *vram2;
+
+void BacklightOn()
+{
+ if(!IsEmulator)
+ {
+ switch(getCalc())
+ {
+ case UNKNOWN: return;
+ case fx9860G_SLIM: (*(volatile struct st_port *)0xA4000126).DR.BIT.B5 = 1; break;
+ case fx9860GII: (*(volatile struct st_port *)0xA400012C).DR.BIT.B7 = 1; break;
+ case fx9860GII_2: (*(volatile struct st_port *)0xA4050138).DR.BIT.B4 = 1; break;
+ }
+ }
+}
+
+void BacklightOff()
+{
+ if(!IsEmulator)
+ {
+ switch(getCalc())
+ {
+ case UNKNOWN: return;
+ case fx9860G_SLIM: (*(volatile struct st_port *)0xA4000126).DR.BIT.B5 = 0; break;
+ case fx9860GII: (*(volatile struct st_port *)0xA400012C).DR.BIT.B7 = 0; break;
+ case fx9860GII_2: (*(volatile struct st_port *)0xA4050138).DR.BIT.B4 = 0; break;
+ }
+ }
+}
+
+void BacklightChange()
+{
+ if(!IsEmulator)
+ {
+ switch(getCalc())
+ {
+ case UNKNOWN: return;
+ case fx9860G_SLIM: (*(volatile struct st_port *)0xA4000126).DR.BIT.B5 = (*(volatile struct st_port *)0xA4000126).DR.BIT.B5 == 0; break;
+ case fx9860GII: (*(volatile struct st_port *)0xA400012C).DR.BIT.B7 = (*(volatile struct st_port *)0xA400012C).DR.BIT.B7 == 0; break;
+ case fx9860GII_2: (*(volatile struct st_port *)0xA4050138).DR.BIT.B4 = (*(volatile struct st_port *)0xA4050138).DR.BIT.B4 == 0; break;
+ }
+ }
+}
+
+int BacklightIsOn()
+{
+ if(!IsEmulator)
+ {
+ switch(getCalc())
+ {
+ case UNKNOWN: return 0;
+ case fx9860G_SLIM: return (*(volatile struct st_port *)0xA4000126).DR.BIT.B5; break;
+ case fx9860GII: return (*(volatile struct st_port *)0xA400012C).DR.BIT.B7; break;
+ case fx9860GII_2: return (*(volatile struct st_port *)0xA4050138).DR.BIT.B4; break;
+ }
+ }
+}
+
+void set_contrast(int contrast)
+{
+ if(!getCalc() == UNKNOWN && !IsEmulator)
+ {
+ char *LCD_register_selector = (char*)0xB4000000, *LCD_data_register = (char*)0xB4010000;
+ *LCD_register_selector = 6;
+ *LCD_data_register = contrast;
+ }
+}
+
+void display_vram()
+{
+ if(getCalc() == UNKNOWN && !IsEmulator)
+ {
+ Bdisp_PutDisp_DD();
+ }
+ else
+ {
+ char *LCD_register_selector = (char*)0xB4000000, *LCD_data_register = (char*)0xB4010000, *mvram;
+ int i, j;
+ mvram = vram;
+ for(i=0 ; i<64 ; i++)
+ {
+ *LCD_register_selector = 4;
+ *LCD_data_register = i|192;
+ *LCD_register_selector = 4;
+ *LCD_data_register = 0;
+ *LCD_register_selector = 7;
+ for(j=0 ; j<16 ; j++) *LCD_data_register = *mvram++;
+ }
+ }
+}
+
+void clear_vram()
+{
+ int i, end;
+ int *pointer_long, mvram;
+ char *pointer_byte;
+ mvram = (int)vram;
+ end = 4-mvram&3;
+ pointer_byte = (char*)mvram;
+ for(i=0 ; i<end ; i++) pointer_byte[i] = 0;
+ pointer_long = (int*) (mvram+end);
+ for(i=0 ; i<255 ; i++) pointer_long[i] = 0;
+ pointer_byte += 1020+end;
+ end = mvram&3;
+ for(i=0 ; i<end ; i++) pointer_byte[i] = 0;
+}
+
+short*APP_EnableRestart()
+{
+ if(getCalc() != UNKNOWN && !IsEmulator)
+ {
+ unsigned int ea;
+ unsigned int j;
+ short*pEnableRestartFlag;
+ ea = *(unsigned int*)0x8001007C;
+ ea += 0x0490*4;
+ if ( ea < 0x8001007C ) return 0;
+ if ( ea > 0x81000000 ) return 0;
+ ea = *(unsigned int*)( ea );
+ if ( ea < 0x8001007C ) return 0;
+ if ( ea > 0x81000000 ) return 0;
+ j = *(unsigned char*)( ea + 1 );
+ j *= 4;
+ ea = ( ea + j + 4 ) & 0xFFFFFFFC;
+ if ( ea < 0x8001007C ) return 0;
+ if ( ea > 0x81000000 ) return 0;
+ pEnableRestartFlag = (short*)(*( unsigned int*)( ea ) + 8 );
+ if ( ( (unsigned int)pEnableRestartFlag & 0xFF000000 ) != 0x88000000 ) return 0;
+ if ( pEnableRestartFlag ) *pEnableRestartFlag = 1;
+ return pEnableRestartFlag;
+ }
+ return NULL;
+}
+
+int getCalc(void)
+{
+ static int hardware = UNKNOWN;
+ if(hardware == UNKNOWN)
+ {
+ char v1, v2;
+ short v3, v4;
+
+ // check for calculator hardware type
+ if ( *(unsigned int*)0x80000300 == 0x80005D7C ){
+ if ( *(unsigned char*)0xA4000128 & 0x08 ){
+ hardware = fx9860G;
+ }
+ else{
+ hardware = fx9860G_SLIM;
+ }
+ }
+ else {
+ GlibGetOSVersionInfo( &v1, &v2, &v3, &v4 );
+ if ( ( v1 == 2 ) && ( v2 == 2 ) ){
+ hardware = fx9860GII_2;
+ }
+ else if ( ( *(unsigned int*)0x80000304 & 0x00FF0000 ) == 0x00AA0000 ){
+ // GII
+ hardware = fx9860GII;
+ }
+ else if ( ( *(unsigned int*)0x80000304 & 0x00FF0000 ) == 0x00550000 ){
+ // GII (French)
+ hardware = fx9860GII;
+ }
+ }
+ }
+
+ return hardware;
+}
diff --git a/hardware.h b/hardware.h new file mode 100644 index 0000000..40bd377 --- /dev/null +++ b/hardware.h @@ -0,0 +1,43 @@ +#ifndef _HARDWARE_H_
+#define _HARDWARE_H_
+
+#define IsEmulator !( *(int*)0x80000300)
+
+struct st_port {
+ union {
+ unsigned char BYTE;
+ struct{
+ unsigned char B7:1;
+ unsigned char B6:1;
+ unsigned char B5:1;
+ unsigned char B4:1;
+ unsigned char B3:1;
+ unsigned char B2:1;
+ unsigned char B1:1;
+ unsigned char B0:1;
+ } BIT;
+ } DR;
+};
+
+void BacklightOn(void);
+void BacklightOff(void);
+void BacklightChange(void);
+int BacklightIsOn(void);
+
+void set_contrast(int);
+
+void display_vram(void);
+void clear_vram(void);
+
+short *APP_EnableRestart(void);
+
+int getCalc(void);
+#define UNKNOWN 0
+#define fx9860G 1
+#define fx9860G_SLIM 2
+#define fx9860GII_2 3
+#define fx9860GII 4
+
+extern char *vram;
+
+#endif
\ No newline at end of file @@ -0,0 +1,101 @@ +#include "global.h"
+#include "key.h"
+#include "hardware.h"
+
+static const unsigned short* keyboard_register = (unsigned short*)0xA44B0000;
+static unsigned short lastkey[8];
+
+int PRGM_GetKey()
+{
+ unsigned char buffer[12];
+ Keyboard_PRGM_GetKey( buffer );
+ return (buffer[1] & 0x0F) * 10 + ((buffer[2] & 0xF0) >> 4);
+}
+
+static void delay()
+{
+ unsigned int i;
+ for(i=0 ; i<5 ; i++);
+}
+
+static unsigned char CheckKeyRow(int code)
+{
+ unsigned int result=0;
+ short*PORTB_CTRL=(void*)0xA4000102;
+ short*PORTM_CTRL=(void*)0xA4000118;
+ char*PORTB=(void*)0xA4000122;
+ char*PORTM=(void*)0xA4000138;
+ char*PORTA=(void*)0xA4000120;
+ short smask;
+ char cmask;
+ unsigned char column, row;
+
+ column = code>>4;
+ row = code &0x0F;
+
+ smask = 0x0003 << (( row %8)*2);
+ cmask = ~( 1 << ( row %8) );
+ if(row <8)
+ {
+ *PORTB_CTRL = 0xAAAA ^ smask;
+ *PORTM_CTRL = (*PORTM_CTRL & 0xFF00 ) | 0x00AA;
+ delay();
+ *PORTB = cmask;
+ *PORTM = (*PORTM & 0xF0 ) | 0x0F;
+ }
+ else
+ {
+ *PORTB_CTRL = 0xAAAA;
+ *PORTM_CTRL = ((*PORTM_CTRL & 0xFF00 ) | 0x00AA) ^ smask;
+ delay();
+ *PORTB = 0xFF;
+ *PORTM = (*PORTM & 0xF0 ) | cmask;
+ }
+ delay();
+ result = (~(*PORTA))>>column & 1;
+ delay();
+ *PORTB_CTRL = 0xAAAA;
+ *PORTM_CTRL = (*PORTM_CTRL & 0xFF00 ) | 0x00AA;
+ delay();
+ *PORTB_CTRL = 0x5555;
+ *PORTM_CTRL = (*PORTM_CTRL & 0xFF00 ) | 0x0055;
+ delay();
+
+ return result;
+}
+
+void keyupdate()
+ {
+ if(getCalc() == fx9860GII_2)
+ {
+ memcpy(lastkey, keyboard_register, sizeof(unsigned short) << 3);
+ }
+}
+
+int keydown(int code)
+{
+ if(getCalc() != UNKNOWN)
+ {
+ if(getCalc() == fx9860GII_2)
+ {
+ unsigned char row = code%10;
+
+ return (0 != (lastkey[row >> 1] & 1 << code / 10 - 1 + ((row & 1) << 3)));
+ }
+ else
+ {
+ return CheckKeyRow((code % 10) + ((code / 10 - 1) << 4));
+ }
+ }
+ else
+ {
+ if(IsEmulator)
+ {
+ return CheckKeyRow((code % 10) + ((code / 10 - 1) << 4));
+ }
+ else
+ {
+ return PRGM_GetKey() == code;
+ }
+ }
+}
@@ -0,0 +1,57 @@ +#ifndef _KEY_H_
+#define _KEY_H_
+
+#define KEY_CHAR_0 71
+#define KEY_CHAR_1 72
+#define KEY_CHAR_2 62
+#define KEY_CHAR_3 52
+#define KEY_CHAR_4 73
+#define KEY_CHAR_5 63
+#define KEY_CHAR_6 53
+#define KEY_CHAR_7 74
+#define KEY_CHAR_8 64
+#define KEY_CHAR_9 54
+#define KEY_CHAR_DP 61
+#define KEY_CHAR_EXP 51
+#define KEY_CHAR_PMINUS 41
+#define KEY_CHAR_PLUS 42
+#define KEY_CHAR_MINUS 32
+#define KEY_CHAR_MULT 43
+#define KEY_CHAR_DIV 33
+#define KEY_CHAR_FRAC 75
+#define KEY_CHAR_LPAR 55
+#define KEY_CHAR_RPAR 45
+#define KEY_CHAR_COMMA 35
+#define KEY_CHAR_STORE 25
+#define KEY_CHAR_LOG 66
+#define KEY_CHAR_LN 56
+#define KEY_CHAR_SIN 46
+#define KEY_CHAR_COS 36
+#define KEY_CHAR_TAN 26
+#define KEY_CHAR_SQUARE 67
+#define KEY_CHAR_POW 57
+#define KEY_CTRL_EXE 31
+#define KEY_CTRL_DEL 44
+#define KEY_CTRL_AC 10
+#define KEY_CTRL_FD 65
+#define KEY_CTRL_EXIT 47
+#define KEY_CTRL_SHIFT 78
+#define KEY_CTRL_ALPHA 77
+#define KEY_CTRL_OPTN 68
+#define KEY_CTRL_VARS 58
+#define KEY_CTRL_UP 28
+#define KEY_CTRL_DOWN 37
+#define KEY_CTRL_LEFT 38
+#define KEY_CTRL_RIGHT 27
+#define KEY_CTRL_F1 79
+#define KEY_CTRL_F2 69
+#define KEY_CTRL_F3 59
+#define KEY_CTRL_F4 49
+#define KEY_CTRL_F5 39
+#define KEY_CTRL_F6 29
+#define KEY_CTRL_MENU 48
+
+void keyupdate(void);
+int keydown(int);
+
+#endif
@@ -0,0 +1,167 @@ +#include "global.h"
+#include "ki.h"
+#include "calc.h"
+#include "sprites.h"
+
+#include "mathf.h"
+
+static int kshoot(float x, float y)
+{
+ float xadd, yadd;
+
+ if(Abs(x - player.x) > Abs(y - player.y))
+ {
+ xadd = sgn(player.x - x);
+ yadd = ((player.y - y) / Abs(x - player.x));
+ }
+ else
+ {
+ xadd = ((player.x - x) / Abs(y - player.y));
+ yadd =sgn(player.y - y);
+ }
+
+ while(x < MAPSIZE && y < MAPSIZE && x >= 0 && y >= 0)
+ {
+ if((int)y == (int)player.y && (int)x == (int)player.x)
+ {
+ return TRUE;
+ }
+ if(solids[(int)x][(int)y] == SOLID)
+ {
+ break;
+ }
+ x += xadd;
+ y += yadd;
+ }
+ return FALSE;
+}
+
+static void kimove()
+{
+ int c;
+ int dirx, diry;
+
+ for(c = 0; c < spritecnt; c++)
+ {
+ int fail[4] = {0}, success = FALSE;
+
+ if(sprites[c].type == TYPE_ENEMY)
+ {
+ while(!(fail[0] == TRUE && fail[1] == TRUE && fail[2] == TRUE && fail[3] == TRUE) && success == FALSE)
+ {
+ float newx, newy;
+
+ if(kshoot(sprites[c].x, sprites[c].y) == TRUE)
+ {
+ if(Abs((player.x) - sprites[c].x) > 3)
+ {
+ dirx = (player.x > sprites[c].x)?1:(player.x == sprites[c].x)?0:-1;
+ }
+ else
+ {
+ dirx = 0;
+ }
+
+ if(Abs((player.y) - sprites[c].y) > 3)
+ {
+ diry = (player.y > sprites[c].y)?1:(player.y == sprites[c].y)?0:-1;
+ }
+ else
+ {
+ diry = 0;
+ }
+ success = TRUE;
+ }
+ else
+ {
+ uint num;
+
+ do
+ {
+ num = random() % 4;
+ }while(fail[num] == TRUE);
+
+ fail[num] = TRUE;
+
+ switch(num)
+ {
+ case 0:
+ dirx = 0;
+ diry = -1;
+ break;
+ case 1:
+ dirx = 1;
+ diry = 0;
+ break;
+ case 2:
+ dirx = 0;
+ diry = 1;
+ break;
+ case 3:
+ diry = 0;
+ dirx = -1;
+ break;
+ }
+ }
+
+ newx = sprites[c].x + dirx;
+ newy = sprites[c].y + diry;
+
+ if(newx < MAPSIZE && newx >= 0 && newy < MAPSIZE && newy >= 0)
+ {
+ if(solids[(int)newx][(int)newy] == UNSOLID)
+ {
+ solids[(int)sprites[c].x][(int)sprites[c].y] = UNSOLID;
+ sprites[c].x = newx;
+ sprites[c].y = newy;
+ solids[(int)sprites[c].x][(int)sprites[c].y] = SPRITE;
+ success = TRUE;
+ }
+ }
+ }
+ }
+ }
+}
+
+static void kishoot(void)
+{
+ int c;
+
+ for(c = 0; c < spritecnt; c++)
+ {
+ if(sprites[c].type == TYPE_ENEMY)
+ {
+ if(kshoot(sprites[c].x, sprites[c].y) == TRUE)
+ {
+ player.health -= 5;
+ output = 1;
+ statustimer = 0;
+ status = hitmsg;
+ BacklightOn();
+ }
+ }
+ }
+}
+
+void timer(void)
+{
+ static int ki = 0;
+ if(++ki == 10)
+ {
+ kimove();
+ ki = 0;
+ output = 1;
+ }
+ kishoot();
+}
+
+void kisetpos(float *x, float *y)
+{
+ do
+ {
+ *x = crand() % MAPSIZE + 0.5;
+ *y = crand() % MAPSIZE + 0.5;
+ }while(solids[(int)*x][(int)*y] != UNSOLID);
+
+ solids[(int)*x][(int)*y] = SPRITE;
+}
@@ -0,0 +1,9 @@ +#ifndef _KI_H_
+#define _KI_H_
+
+#define KISPEED 500
+
+void kisetpos(float *, float *);
+void timer(void);
+
+#endif
\ No newline at end of file diff --git a/mapgen.c b/mapgen.c new file mode 100644 index 0000000..f18df4d --- /dev/null +++ b/mapgen.c @@ -0,0 +1,414 @@ +#include "global.h"
+#include "mapgen.h"
+#include "draw.h"
+#include "hardware.h"
+#include "sprites.h"
+
+static int cntunvisit(union st_field cnt)
+{
+ int c = 0;
+ if(cnt.side.west != SPACE)c++;
+ if(cnt.side.east != SPACE)c++;
+ if(cnt.side.north != SPACE)c++;
+ if(cnt.side.south != SPACE)c++;
+
+ return (c > 1)?c:0;
+}
+
+static int cntempty(int x, int y)
+{
+ union st_field c;
+ int cnt = 0;
+
+ c.byte = 0;
+
+ if(x - 1 > 0)c.side.west = map[x - 1][y];else c.side.west = WALL;
+ if(x + 1 < MAPSIZE - 1)c.side.east = map[x + 1][y];else c.side.east = WALL;
+ if(y - 1 > 0)c.side.north = map[x][y - 1];else c.side.north = WALL;
+ if(y + 1 < MAPSIZE - 1)c.side.south = map[x][y + 1];else c.side.south = WALL;
+
+ if(c.side.west == SPACE)cnt++;
+ if(c.side.east == SPACE)cnt++;
+ if(c.side.north == SPACE)cnt++;
+ if(c.side.south == SPACE)cnt++;
+
+ return cnt;
+}
+
+static int cntwall(int x, int y)
+{
+ union st_field c;
+ int cnt = 0;
+
+ c.byte = 0;
+
+ if(x - 1 > 0)c.side.west = map[x - 1][y];else c.side.west = WALL;
+ if(x + 1 < MAPSIZE - 1)c.side.east = map[x + 1][y];else c.side.east = WALL;
+ if(y - 1 > 0)c.side.north = map[x][y - 1];else c.side.north = WALL;
+ if(y + 1 < MAPSIZE - 1)c.side.south = map[x][y + 1];else c.side.south = WALL;
+
+ if(c.side.west == WALL)cnt++;
+ if(c.side.east == WALL)cnt++;
+ if(c.side.north == WALL)cnt++;
+ if(c.side.south == WALL)cnt++;
+
+ return cnt;
+}
+
+static union st_field get(int x, int y)
+{
+ union st_field c;
+
+ c.byte = 0;
+
+ if(x - 1 > 0)c.side.west = map[x - 1][y];
+ if(x + 1 < MAPSIZE - 1)c.side.east = map[x + 1][y];
+ if(y - 1 > 0)c.side.north = map[x][y - 1];
+ if(y + 1 < MAPSIZE - 1)c.side.south = map[x][y + 1];
+
+ return c;
+}
+
+static int hunt(int *x, int *y)
+{
+ for(*x = 1; *x < MAPSIZE - 1; *x+=2)
+ {
+ for(*y = 1; *y < MAPSIZE - 1; *y+=2)
+ {
+ if(map[*x][*y] == WALL)
+ {
+ if(cntunvisit(get(*x, *y)) > 1)
+ {
+ return TRUE;
+ }
+ }
+ }
+ }
+ return FALSE;
+}
+
+static int kill(int *x, int *y, union st_field this)
+{
+ int fail1 = FALSE, fail2 = FALSE, fail3 = FALSE, fail4 = FALSE;
+ while(!keydown(31))
+ {
+ if(cntunvisit(this) == 0)fail1 = fail2 = fail3 = fail4 = TRUE;
+
+ switch(random() % 4)
+ {
+ case 0:
+ if(this.side.west == WALL && fail1 == FALSE)
+ {
+ if(cntunvisit(get(*x - 2, *y)) > 0)
+ {
+ map[*x - 1][*y] = SPACE;
+ *x -= 2;
+ return TRUE;
+ }
+ else
+ {
+ fail1 = TRUE;
+ }
+ }
+ else
+ {
+ fail1 = TRUE;
+ }
+ break;
+
+ case 1:
+ if(this.side.east == WALL && fail2 == FALSE)
+ {
+ if(cntunvisit(get(*x + 2, *y)) > 0)
+ {
+ map[*x + 1][*y] = SPACE;
+ *x += 2;
+ return TRUE;
+ }
+ else
+ {
+ fail2 = TRUE;
+ }
+ }
+ else
+ {
+ fail2 = TRUE;
+ }
+ break;
+
+ case 2:
+ if(this.side.north == WALL && fail3 == FALSE)
+ {
+ if(cntunvisit(get(*x, *y - 2)) > 0)
+ {
+ map[*x][*y - 1] = SPACE;
+ *y -= 2;
+ return TRUE;
+ }
+ else
+ {
+ fail3 = TRUE;
+ }
+ }
+ else
+ {
+ fail3 = TRUE;
+ }
+ break;
+
+ case 3:
+ if(this.side.south == WALL && fail4 == FALSE)
+ {
+ if(cntunvisit(get(*x, *y + 2)) > 0)
+ {
+ map[*x][*y + 1] = SPACE;
+ *y += 2;
+ return TRUE;
+ }
+ else
+ {
+ fail4 = TRUE;
+ }
+ }
+ else
+ {
+ fail4 = TRUE;
+ }
+ break;
+ }
+
+ if(fail1 == TRUE && fail2 == TRUE && fail3 == TRUE && fail4 == TRUE)
+ {
+ return hunt(x, y);
+ }
+ }
+ return FALSE;
+}
+
+static int solve()
+{
+ int priotable[4];
+ int curx = 1, cury = 1;
+ int prex = 0, prey = -1;
+ int deltax = 1, deltay = 0;
+ int dir, dirx, diry;
+start:
+ for(curx = 0; curx < MAPSIZE; curx++)
+ {
+ for(cury = 0; cury < MAPSIZE; cury++)
+ {
+ if((curx != 1 && cury != 1) && (curx != MAPSIZE - 2 && cury != MAPSIZE - 2))
+ {
+ if(map[curx][cury] == SPACE)
+ {
+ if(cntempty(curx, cury) == 1)
+ {
+ map[curx][cury] = CHECKED;
+ clear_vram();
+ drawgenmap();
+ display_vram();
+ goto start;
+ }
+ }
+ }
+ }
+ }
+
+ curx = cury = 1;
+
+ while(curx != MAPSIZE - 2 || cury != MAPSIZE - 2)
+ {
+ deltax = curx - prex;
+ deltay = cury - prey;
+
+ if(deltax == 0)
+ {
+ if(deltay == 1)
+ dir = SOUTH;
+ else
+ dir = NORTH;
+ }
+ else
+ {
+ if(deltax == 1)
+ dir = EAST;
+ else
+ dir = WEST;
+ }
+
+ switch(dir)
+ {
+ case NORTH:
+ priotable[0] = EAST;
+ priotable[1] = NORTH;
+ priotable[2] = WEST;
+ priotable[3] = SOUTH;
+ break;
+ case SOUTH:
+ priotable[0] = WEST;
+ priotable[1] = SOUTH;
+ priotable[2] = EAST;
+ priotable[3] = NORTH;
+ break;
+ case EAST:
+ priotable[0] = SOUTH;
+ priotable[1] = EAST;
+ priotable[2] = NORTH;
+ priotable[3] = WEST;
+ break;
+ case WEST:
+ priotable[0] = NORTH;
+ priotable[1] = WEST;
+ priotable[2] = SOUTH;
+ priotable[3] = EAST;
+ }
+
+ for(dir = 0; dir < 4; dir++)
+ {
+ switch(priotable[dir])
+ {
+ case NORTH:
+ dirx = 0;
+ diry = -1;
+ break;
+ case EAST:
+ dirx = 1;
+ diry = 0;
+ break;
+ case SOUTH:
+ dirx = 0;
+ diry = 1;
+ break;
+ case WEST:
+ dirx = -1;
+ diry = 0;
+ break;
+ }
+ if(curx + dirx < MAPSIZE - 1 && curx + dirx > 0 && cury + diry < MAPSIZE - 1 && cury + diry > 0 && map[curx + dirx][cury + diry] == SPACE)
+ {
+ prex = curx;
+ prey = cury;
+ curx += dirx;
+ cury += diry;
+ break;
+ }
+ }
+
+ if(curx == 1 && cury == 1)
+ {
+ return FALSE;
+ }
+
+ if(IsEmulator())
+ {
+ clear_vram();
+ drawgenmap();
+ pixel((int)(curx * sizex + 1), (int)(cury * sizey + 1));
+ display_vram();
+ }
+ }
+
+ for(curx = 0; curx < MAPSIZE; curx++)
+ {
+ for(cury = 0; cury < MAPSIZE; cury++)
+ {
+ if(map[curx][cury] == 1)
+ {
+ map[curx][cury] = 1;
+ solids[curx][cury] = SOLID;
+ }
+ else
+ {
+ map[curx][cury] = 0;
+ solids[curx][cury] = UNSOLID;
+ }
+ }
+ }
+
+ for(curx = 0; curx < MAPSIZE; curx++)
+ {
+ for(cury = 0; cury < MAPSIZE; cury++)
+ {
+ if(map[curx][cury] == SPACE)
+ {
+ if(cntwall(curx, cury) >= 3)
+ {
+ sprites = (struct st_sprite *) realloc(sprites, (spritecnt + 1) * sizeof(struct st_sprite));
+ if(sprites == NULL)error();
+ sprites[spritecnt].x = curx + 0.5;
+ sprites[spritecnt].y = cury + 0.5;
+ sprites[spritecnt].texture.ptr = &pack;
+ sprites[spritecnt].texture.width = 8;
+ sprites[spritecnt].texture.height = 8;
+ sprites[spritecnt].type = TYPE_PACK;
+ sprites[spritecnt].effect = 50;
+ spritecnt++;
+ solids[curx][cury] = SPRITE;
+ }
+ }
+ else if(map[curx][cury] == WALL)
+ {
+ if(cntwall(curx, cury) == 2)
+ {
+ heights[curx][cury] = 32;
+ }
+ }
+ }
+ }
+
+ for(curx = 0; curx < MAPSIZE; curx++)
+ {
+ for(cury = 0; cury < MAPSIZE; cury++)
+ {
+ if(map[curx][cury] == SPACE && cntwall(curx, cury) < 2)
+ {
+ int dx, dy, fail1, fail2, fail3, fail4;
+ fail1 = fail2 = fail3 = fail4 = FALSE;
+
+ while(fail1 == FALSE && fail2 == FALSE && fail3 == FALSE & fail4 == FALSE)
+ {
+ switch(random() % 4)
+ {
+ case 0: dx = 0; dy = 1; fail1 = TRUE; break;
+ case 1: dx = 0; dy = -1; fail2 = TRUE; break;
+ case 2: dx = 1; dy = 0; fail3 = TRUE; break;
+ case 3: dx = -1; dy = 0; fail4 = TRUE; break;
+ }
+ if(curx + dx < MAPSIZE && curx + dx >= 0 && cury + dy < MAPSIZE && cury + dy >= 0)
+ {
+ if(map[curx + dx][cury + dy] == SPACE)
+ {
+ map[curx + dx][cury + dy] = DOOR;
+ solids[curx + dx][cury + dy] = SOLID;
+ fail1 = fail2 = fail3 = fail4 = TRUE;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ clear_vram();
+ drawgenmap();
+ display_vram();
+
+ return TRUE;
+}
+
+void maze()
+{
+ do
+ {
+ int x = 1, y = 1, exit = TRUE;
+
+ fill(&map, WALL, MAPSIZE * MAPSIZE);
+ while(exit == TRUE)
+ {
+ map[x][y] = SPACE;
+ exit = kill(&x, &y, get(x, y));
+ clear_vram();
+ drawgenmap();
+ display_vram();
+ }
+ }while(solve() == FALSE);
+}
diff --git a/mapgen.h b/mapgen.h new file mode 100644 index 0000000..972e43c --- /dev/null +++ b/mapgen.h @@ -0,0 +1,18 @@ +#ifndef _MAPGEN_H_
+#define _MAPGEN_H_
+
+union st_field
+{
+ int byte;
+ struct
+ {
+ int west;
+ int east;
+ int north;
+ int south;
+ }side;
+};
+
+void maze(void);
+
+#endif
\ No newline at end of file @@ -0,0 +1,132 @@ +#include "global.h"
+#include "menu.h"
+#include "key.h"
+#include "ki.h"
+#include "syscalls.h"
+#include "draw.h"
+
+#include "stdio.h"
+
+void openmenu()
+{
+ uchar text[30];
+ int choose = 0;
+ static const char arrow = 0x13;
+
+ Timer_Uninstall(8);
+
+ while(keydown(KEY_CTRL_MENU)){keyupdate();}
+ while(1)
+ {
+ PopUpWin(6);
+
+ sprintf(&text, "show map");
+ locatePrintMini(5,3, &text);
+
+ if(drawfloor == TRUE)
+ {
+ sprintf(&text, "disable floor and ceiling");
+ }
+ else
+ {
+ sprintf(&text, "enable floor and ceiling");
+ }
+
+ locatePrintMini(5,4, &text);
+
+ if(drawtex == TRUE)
+ {
+ sprintf(&text, "disable texture");
+ }
+ else
+ {
+ sprintf(&text, "enable texture");
+ }
+
+ locatePrintMini(5,5, &text);
+
+ if(drawheight == TRUE)
+ {
+ sprintf(&text, "disable height difference");
+ }
+ else
+ {
+ sprintf(&text, "enable height difference");
+ }
+
+ locatePrintMini(5,6, &text);
+
+ if(demo == TRUE)
+ {
+ sprintf(&text, "disable demo mode");
+ }
+ else
+ {
+ sprintf(&text, "enable demo mode");
+ }
+
+ locatePrintMini(5,7, &text);
+
+ sprintf(&text, "exit game");
+ locatePrintMini(5,8, &text);
+
+ locatePrintMini(4,3+choose, &arrow);
+
+ while(keydown(KEY_CTRL_UP) || keydown(KEY_CTRL_DOWN) || keydown(KEY_CTRL_EXE) || keydown(KEY_CTRL_MENU)){keyupdate();}
+
+ display_vram();
+
+ while(!keydown(KEY_CTRL_UP) && !keydown(KEY_CTRL_DOWN) && !keydown(KEY_CTRL_EXE) && !keydown(KEY_CTRL_MENU)){keyupdate();}
+ if(keydown(KEY_CTRL_UP))
+ {
+ choose--;
+ if(choose == -1)
+ choose = 0;
+ }
+ if(keydown(KEY_CTRL_DOWN))
+ {
+ choose++;
+ if(choose == 6)
+ choose = 5;
+ }
+ if(keydown(KEY_CTRL_MENU))
+ {
+ while(keydown(KEY_CTRL_MENU)){keyupdate();}
+ Timer_Install(8, &timer, KISPEED);
+ Timer_Start(8);
+ return;
+ }
+ if(keydown(KEY_CTRL_EXE))
+ {
+ switch(choose)
+ {
+ case 0:
+ while(keydown(KEY_CTRL_EXE)){keyupdate();}
+ showmap();
+ break;
+ case 1:
+ drawfloor = (drawfloor == TRUE)?FALSE:TRUE;
+ break;
+ case 2:
+ drawtex = (drawtex == TRUE)?FALSE:TRUE;
+ break;
+ case 3:
+ drawheight = (drawheight == TRUE)?FALSE:TRUE;
+ break;
+ case 4:
+ if(demo == TRUE)
+ {
+ demo = FALSE;
+ }
+ else
+ {
+ demo = TRUE;
+ }
+ break;
+ case 5:
+ exit = TRUE;
+ return;
+ }
+ }
+ }
+}
@@ -0,0 +1,6 @@ +#ifndef _MENU_H
+#define _MENU_H_
+
+void openmenu(void);
+
+#endif
\ No newline at end of file diff --git a/sprites.c b/sprites.c new file mode 100644 index 0000000..7baca5b --- /dev/null +++ b/sprites.c @@ -0,0 +1,197 @@ +#include "global.h"
+#include "sprites.h"
+
+const int wall[2][16][16] = {
+{
+ { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 },
+ { 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 },
+ { 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 1 },
+ { 1 , 0 , 1 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0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1 , 2 , 2 , 2 , 1 , 1 , 0 , 0 },
+ { 0 , 0 , 1 , 2 , 2 , 2 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1 , 2 , 2 , 2 , 1 , 1 , 0 },
+ { 0 , 1 , 2 , 2 , 2 , 2 , 1 , 2 , 1 , 1 , 1 , 1 , 2 , 1 , 2 , 2 , 2 , 2 , 2 , 1 , 0 },
+ { 0 , 1 , 2 , 2 , 2 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1 , 2 , 2 , 2 , 2 , 1 , 0 },
+ { 1 , 2 , 2 , 2 , 2 , 2 , 1 , 2 , 1 , 1 , 1 , 1 , 2 , 1 , 2 , 1 , 2 , 2 , 2 , 1 , 1 }
+};
+
+const char packmsg[11] = "Found pack";
+const char hitmsg[19] = "You were attacked!";
diff --git a/sprites.h b/sprites.h new file mode 100644 index 0000000..d826539 --- /dev/null +++ b/sprites.h @@ -0,0 +1,16 @@ +#ifndef _SPRITES_H_
+#define _SPRITES_H_
+
+extern const int knife[22][21];
+extern const int gun[22][21];
+extern const int ceiling[16][16];
+extern const int floor[16][16];
+extern const int enemy[32][16];
+extern const int pack[8][8];
+extern const int door[16][16];
+extern const int wall[2][16][16];
+
+extern const char packmsg[11];
+extern const char hitmsg[19];
+
+#endif
diff --git a/syscalls.h b/syscalls.h new file mode 100644 index 0000000..fcac81a --- /dev/null +++ b/syscalls.h @@ -0,0 +1,25 @@ +#ifndef _SYSCALLS_H_
+#define _SYSCALLS_H_
+
+char* Disp_GetVRAMPtr(void);
+
+int GetKey(unsigned int *);
+void locate(int, int);
+void Print(const unsigned char *);
+int Timer_Install(int, void (*)(void), int);
+int Timer_Uninstall(int);
+int Timer_Start(int);
+int itoa( int, unsigned char*, int);
+void PrintMini(int, int, const unsigned char *, int);
+int RTC_Elapsed_ms(int, int);
+void Keyboard_ClrBuffer(void);
+int RTC_Elapsed_ms(int, int);
+int GlibGetOSVersionInfo(char *, char *, short *, short *);
+int Keyboard_PRGM_GetKey(uchar *);
+
+#define MINI_OVER 0
+#define MINI_OR 1
+#define MINI_REV 2
+#define MINI_REVOR 3
+
+#endif
\ No newline at end of file diff --git a/syscalls.src b/syscalls.src new file mode 100644 index 0000000..a277d18 --- /dev/null +++ b/syscalls.src @@ -0,0 +1,34 @@ + .SECTION P,CODE,ALIGN=4
+ .MACRO SYSCALL FUNO, SYSCALLNAME, TAIL=nop
+ .export \SYSCALLNAME'
+\SYSCALLNAME'
+ mov.l #h'\FUNO, r0
+ mov.l #H'80010070, r2
+ jmp @r2
+ \TAIL'
+ .ENDM
+
+ SYSCALL 040C, _Serial_ReadOneByte
+ SYSCALL 040E, _Serial_BufferedTransmitOneByte
+ SYSCALL 0418, _Serial_Open
+ SYSCALL 0419, _Serial_Close
+ SYSCALL 0413, _Serial_ClearReceiveBuffer
+ SYSCALL 003B, _RTC_GetTicks
+ SYSCALL 0135, _Disp_GetVRAMPtr
+ SYSCALL 0420, _Sleep
+ SYSCALL 090F, _GetKey
+ SYSCALL 0807, _locate
+ SYSCALL 0808, _Print
+ SYSCALL 0118, _Timer_Install
+ SYSCALL 0119, _Timer_Uninstall
+ SYSCALL 011A, _Timer_Start
+ SYSCALL 0160, _itoa
+ SYSCALL 040E, _Serial_WriteByte
+ SYSCALL 0910, _PutKey
+ SYSCALL 0015, _GlibGetOSVersionInfo
+ SYSCALL 02A0, _USB_CaptureDisplay
+ SYSCALL 0C4F, _PrintMini
+ SYSCALL 0241, _Keyboard_ClrBuffer
+ SYSCALL 003C, _RTC_Elapsed_ms
+ SYSCALL 06C4, _Keyboard_PRGM_GetKey;
+ .end
|
