Basys 3 RISC-V computer

The Basys 3 Z-80 computer with the Z-80 replaced by an RV32IM processor
written from scratch (rtl/rv32_cpu.v): multi-cycle, 90 MHz, CSRs and
traps, interrupts, two hardware triggers and a resumable NMI for the
monitor. Passes riscv-tests rv32ui/um/mi.

rv32_system.v keeps all the Z-80 machine's peripherals, with I/O port N
at FFFFFF00h + N, 80 KB of RAM with BASIC preloaded, and a 32 KB monitor
ROM. BASIC, the five games and the monitor (with an RV32 disassembler,
assembler, breakpoints and single step) are ported to RISC-V GCC. Python
emulator and tests in tools/; full-system simulation in sim/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
brad ArantandClaude Opus 5.5 committed 2026-11-30 18:09:18 -08:00
commit 5930b958b4
103 files changed
+55677

No files matched your search

+226
View File
@@ -0,0 +1,226 @@
#!/usr/bin/env python3
"""Make data.h for raid.c: the sprite shapes (drawn here from polygons and
ellipses, in the isometric directions the game uses) and the level.
The world is a 2:1 isometric grid of tiles 32 pixels wide and 16 high. The
ship flies along the rows, towards the top right of the screen; a level is a
list of rows, numbered from where it starts. Each row is space or fortress
floor, and a fortress row can end in a wall across the flight path: a low wall
to fly over, or a tall one with a doorway to fly through. Ground objects stand
on tiles: turrets that fire at you, fuel tanks to shoot for fuel, radar dishes
for points, and the reactor core at the end of the level.
"""
import math
import random
import sys
# ------------------------------------------------------------- drawing
def blank():
return [[0] * 16 for _ in range(16)]
def poly(img, pts, c):
"""Fill a polygon given in pixel coordinates (centres at +0.5)."""
n = len(pts)
for y in range(16):
for x in range(16):
px, py = x + 0.5, y + 0.5
inside = False
for k in range(n):
(x1, y1), (x2, y2) = pts[k], pts[(k + 1) % n]
if (y1 > py) != (y2 > py):
if px < x1 + (py - y1) * (x2 - x1) / (y2 - y1):
inside = not inside
if inside:
img[y][x] = c
def ellipse(img, cx, cy, rx, ry, c):
for y in range(16):
for x in range(16):
if ((x + 0.5 - cx) / rx) ** 2 + ((y + 0.5 - cy) / ry) ** 2 <= 1:
img[y][x] = c
def rect(img, x0, y0, x1, y1, c):
for y in range(y0, y1):
for x in range(x0, x1):
img[y][x] = c
# the flight direction on screen (2, -1), and across the flight path, which in
# the 2:1 isometric view is (2, 1) - the direction the tiles' other edges run
F = (2 / math.sqrt(5), -1 / math.sqrt(5))
G = (2 / math.sqrt(5), 1 / math.sqrt(5))
def iso(pts, cx=8, cy=8, fwd=F):
"""Points given as (along, across) in the flight frame -> pixels."""
side = G
return [(cx + a * fwd[0] + b * side[0], cy + a * fwd[1] + b * side[1]) for a, b in pts]
def ship(body, wing, canopy, fwd=F):
img = blank()
poly(img, iso([(-2, -7.5), (1.5, -1.2), (1.5, 1.2), (-2, 7.5), (-4, 6.5), (-3, 0), (-4, -6.5)], fwd=fwd), wing)
poly(img, iso([(7.5, 0), (2, -2.2), (-6.5, -1.8), (-6.5, 1.8), (2, 2.2)], fwd=fwd), body)
poly(img, iso([(-6.5, -3.5), (-4, -0.5), (-4, 0.5), (-6.5, 3.5), (-7.5, 3), (-7.5, -3)], fwd=fwd), wing)
ellipse(img, *iso([(2.5, 0)], fwd=fwd)[0], 1.6, 1.3, canopy)
return img
SHIP = ship(15, 12, 6)
SHADOW = [[4 if c else 0 for c in row] for row in ship(1, 1, 1)]
FIGHTER = ship(13, 1, 11, fwd=(-F[0], -F[1]))
TURRET = blank()
ellipse(TURRET, 8, 11.5, 6.5, 3.5, 8)
ellipse(TURRET, 8, 9.5, 5, 3.5, 2)
ellipse(TURRET, 7, 8.5, 2, 1.3, 10)
poly(TURRET, [(6.5, 10), (8.5, 11), (3.5, 14.5), (2, 13.5)], 7)
TANK = blank()
rect(TANK, 3, 4, 13, 12, 9)
ellipse(TANK, 8, 12, 5, 2.5, 1)
rect(TANK, 3, 4, 13, 12, 9)
ellipse(TANK, 8, 4, 5, 2.5, 11)
for y in range(6, 11):
TANK[y][5] = 15
rect(TANK, 7, 6, 9, 11, 1)
rect(TANK, 7, 6, 11, 7, 1)
rect(TANK, 7, 8, 10, 9, 1)
RADAR = blank()
rect(RADAR, 7, 7, 9, 14, 7)
ellipse(RADAR, 8, 14, 4, 1.6, 8)
poly(RADAR, [(2, 2), (13, 5), (12, 8), (3, 6)], 14)
poly(RADAR, [(4, 3.5), (11, 5.5), (10.5, 6.8), (4.5, 5)], 6)
CORE = blank()
poly(CORE, [(8, 0.5), (15, 7), (8, 14.5), (1, 7)], 5)
poly(CORE, [(8, 3), (12.5, 7), (8, 11.5), (3.5, 7)], 13)
ellipse(CORE, 8, 7, 2.2, 2.2, 15)
def burst(seed, cols):
r = random.Random(seed)
img = blank()
for k in range(70):
a = r.uniform(0, 2 * math.pi)
d = r.uniform(0, 7) ** 0.9
x, y = int(8 + d * math.cos(a)), int(8 + d * math.sin(a) * 0.8)
if 0 <= x < 16 and 0 <= y < 16:
img[y][x] = cols[0] if d < 2.5 else cols[1] if d < 5 else cols[2]
return img
BOOM1 = burst(3, (15, 11, 9))
BOOM2 = burst(5, (11, 9, 1))
SHOT = blank()
ellipse(SHOT, 8, 8, 1.6, 1.2, 15)
SHOT[8][8] = 11
SHELL = blank()
ellipse(SHELL, 8, 8, 1.8, 1.8, 9)
SHELL[8][8] = 15
SHAPES = [("S_SHIP", SHIP), ("S_SHADOW", SHADOW), ("S_FIGHTER", FIGHTER), ("S_TURRET", TURRET),
("S_TANK", TANK), ("S_RADAR", RADAR), ("S_CORE", CORE), ("S_BOOM1", BOOM1),
("S_BOOM2", BOOM2), ("S_SHOT", SHOT), ("S_SHELL", SHELL)]
# --------------------------------------------------------------- level
BW = 10 # fortress width in tiles
LOW_H, TALL_H, DOOR_H = 20, 56, 30
# row byte: bit 0 fortress floor; bits 2:1 wall at the far edge of the row
# (0 none, 1 low, 2 tall with a door); bits 6:3 the door's first tile;
# bit 7 fighters attack (space)
FORT, WALL_LOW, WALL_DOOR, FIGHTERS = 1, 2, 4, 128
O_TURRET, O_TANK, O_RADAR, O_CORE = 1, 2, 3, 4
def level():
rnd = random.Random(1983)
rows = []
objs = []
def space(n, fighters):
rows.extend([FIGHTERS if fighters else 0] * n)
def fortress(n, walls, turrets, tanks, radars, core=False):
start = len(rows)
rows.extend([FORT] * n)
wall_rows = []
r = start + 10
k = 0
while r < start + n - 6 and k < len(walls):
if walls[k] == "L":
rows[r] |= WALL_LOW
else:
rows[r] |= WALL_DOOR | (rnd.randrange(0, BW - 1) << 3)
wall_rows.append(r)
r += rnd.randrange(9, 14)
k += 1
# objects: not on the rows just behind a wall, where its face hides them
hidden = {w + d for w in wall_rows for d in range(0, 4)}
free = [(rr, i) for rr in range(start + 4, start + n - 3) for i in range(1, BW - 1)
if rr not in hidden]
rnd.shuffle(free)
used = set()
def place(t, count):
nonlocal free
for _ in range(count):
while free:
rr, i = free.pop()
if all(abs(rr - a) > 1 or abs(i - b) > 1 for a, b in used):
used.add((rr, i)); objs.append((rr, t, i)); break
place(O_TURRET, turrets)
place(O_TANK, tanks)
place(O_RADAR, radars)
if core:
objs.append((start + n - 3, O_CORE, BW // 2))
space(14, False)
fortress(120, "LDLDDLDD", 10, 7, 3)
space(60, True)
fortress(140, "DLDDLDDLD", 13, 7, 3, core=True)
space(16, False)
objs.sort()
return rows, objs
def main(out):
rows, objs = level()
L = ["/* made by gen.py - edit that instead */", ""]
for i, (n, _) in enumerate(SHAPES):
L.append("#define %s %d" % (n, i))
L.append("#define N_SHAPES %d" % len(SHAPES))
L.append("#define BW %d" % BW)
L.append("#define LOW_H %d\n#define TALL_H %d\n#define DOOR_H %d" % (LOW_H, TALL_H, DOOR_H))
L.append("#define R_FORT 1\n#define R_WALL 6\n#define R_LOW 2\n#define R_DOOR 4\n#define R_FIGHTERS 128")
L.append("#define O_TURRET %d\n#define O_TANK %d\n#define O_RADAR %d\n#define O_CORE %d" %
(O_TURRET, O_TANK, O_RADAR, O_CORE))
L.append("static const u8 shape_data[N_SHAPES * 128] = {")
for n, img in SHAPES:
b = [img[y][x] << 4 | img[y][x + 1] for y in range(16) for x in range(0, 16, 2)]
L.append(" " + ",".join(str(v) for v in b) + ", /* %s */" % n)
L.append("};")
L.append("#define LEVEL_ROWS %d" % len(rows))
L.append("static const u8 level_rows[LEVEL_ROWS] = {")
for k in range(0, len(rows), 20):
L.append(" " + ",".join(str(v) for v in rows[k:k + 20]) + ",")
L.append("};")
L.append("#define N_OBJS %d" % len(objs))
L.append("/* row (2 bytes), type, tile across */")
L.append("static const u8 level_objs[N_OBJS * 4] = {")
for r, t, i in objs:
L.append(" %d,%d,%d,%d," % (r & 255, r >> 8, t, i))
L.append("};")
open(out, "w").write("\n".join(L) + "\n")
walls = sum(1 for r in rows if r & 6)
print("data.h: %d shapes, %d rows, %d walls, %d objects" % (len(SHAPES), len(rows), walls, len(objs)))
if __name__ == "__main__":
if len(sys.argv) > 2 and sys.argv[2] == "--show":
for n, img in SHAPES:
print(n)
for row in img:
print("".join(" .:-=+*#%@ABCDEF"[c] if c else " " for c in row))
main(sys.argv[1] if len(sys.argv) > 1 else "data.h")
+4
View File
@@ -0,0 +1,4 @@
10 REM BASTION RAID: LOAD THE GAME (MEMORY FILE RAIDGAME) AND PLAY IT
20 REM THE GAME RUNS AT A200H, PAST THIS PROGRAM, AND COMES BACK HERE
30 BLOAD "RAIDGAME": CALL 41472
40 CLS
+696
View File
@@ -0,0 +1,696 @@
/* Bastion Raid: an isometric scrolling shooter for the Basys 3 RISC-V computer.
Fly over a fortress that scrolls diagonally towards you. Climb over low
walls, fly low through the doorways in tall ones, shoot turrets before they
shoot you, and shoot fuel tanks to fill up. Between fortresses, fighters
come at you through space. The reactor core waits at the far end. Your
shadow on the floor and the altimeter show how high you are.
The world is drawn into the graphics layer, which the hardware scrolls
(ports 35h-37h): each frame the picture moves two pixels left and one
down, and only the two new columns and the new row are drawn, pixel by
pixel from the world's description (world()). Everything that moves is a
sprite. It runs at A200h, loaded by the RAID program in BASIC.
World coordinates: a pixel (WX, WY) of the unscrolled world has
s = WX + 2 WY (across the flight path) and d = 2 WY - WX (along it, growing
towards the viewer). Tiles are 32 x 32 in (s, d): tile i = s >> 5,
j = d >> 5, and level row r = -j. The ship flies towards smaller d. */
typedef unsigned char u8;
typedef signed char i8;
typedef unsigned short u16;
typedef short i16;
#include "basys3.h"
#define con_stat IO8(0x00)
#define con_data IO8(0x01)
#define gx_lo IO8(0x30)
#define gx_hi IO8(0x31)
#define gy_p IO8(0x32)
#define gpix IO8(0x33)
#define gfill IO8(0x34)
#define scr_xlo IO8(0x35)
#define scr_xhi IO8(0x36)
#define scr_y IO8(0x37)
#define sp_sel IO8(0x70)
#define sp_xlo IO8(0x71)
#define sp_xhi IO8(0x72)
#define sp_y IO8(0x73)
#define sp_shape IO8(0x74)
#define sp_ctl IO8(0x75)
#define sp_load IO8(0x76)
#define sp_data IO8(0x77)
#define frame_ctr IO8(0x78)
#define joy IO8(0x88)
#include "data.h" /* out/data.h, made by gen.py */
#define J_UP 1
#define J_DOWN 2
#define J_LEFT 4
#define J_RIGHT 8
#define J_FIRE 16
#define J_ENTER 32
#define J_ESC 128
/* sprites: lower numbers in front */
#define SP_SHIP 0
#define SP_SHOT 1 /* 3 */
#define SP_FIGHT 4 /* 4 */
#define SP_SHELL 8 /* 4 */
#define SP_BOOM 12 /* 3 */
#define SP_OBJ 15 /* 12 */
#define SP_SHADOW 27
#define NSHOT 3
#define NFIGHT 4
#define NSHELL 4
#define NBOOM 3
#define NOBJ 12
#define SHIP_D 128 /* the ship's ground point is 4 tiles nearer than the screen centre */
#define MAX_ALT 48
#define BACK_H 24 /* the fortress's back wall */
#define FRONT_H 20 /* and its front face, below the floor */
/* ---------------------------------------------------------------- state */
static i16 cx, cy; /* world pixel at the screen's top left */
static u16 fbx; /* the same, in the 320 x 240 buffer */
static u8 fby;
i16 cam_d; /* d at the screen's centre */
i16 ship_s, ship_d;
u8 alt, lives, fuel, level, inv, dead;
u8 shield; /* tests only: shells, fighters and objects can't hit */
static u8 fuel_tick, fire_held, dead_time;
static u16 score;
static i16 shot_s[NSHOT], shot_d[NSHOT];
static u8 shot_alt[NSHOT], shot_life[NSHOT];
static i16 fight_s[NFIGHT], fight_d[NFIGHT];
static u8 fight_alt[NFIGHT], fight_on[NFIGHT];
static i16 shell_s[NSHELL], shell_d[NSHELL];
static u8 shell_life[NSHELL];
static i16 boom_s[NBOOM], boom_d[NBOOM];
static u8 boom_alt[NBOOM], boom_t[NBOOM];
static i16 obj_s[NOBJ], obj_d[NOBJ];
static u8 obj_type[NOBJ], obj_on[NOBJ], obj_cool[NOBJ], obj_hits[NOBJ];
static u16 next_obj;
static u8 fight_timer;
static u8 last_frame, quit, hud_dirty;
static u8 shown_fuel, shown_alt;
static u16 rnd_state;
static const char *msg;
static u8 msg_time;
/* ----------------------------------------------------------------- text */
static void putch(char c) { while (!(con_stat & 2)); con_data = c; }
static void puts_(const char *s) { while (*s) putch(*s++); }
static void putn(u16 n, u8 width)
{
char b[6];
u8 i = 0;
do { b[i++] = '0' + n % 10; n /= 10; } while (n);
while (width > i) { putch('0'); width--; }
while (i) putch(b[--i]);
}
static void at(u8 r, u8 c) { putch(27); putch('['); putn(r, 0); putch(';'); putn(c, 0); putch('H'); }
static void ink(const char *s) { putch(27); putch('['); puts_(s); putch('m'); }
static void centre(u8 r, const char *s)
{
u8 n = 0;
while (s[n]) n++;
at(r, 41 - n / 2);
puts_(s);
}
static u16 rnd(void)
{
rnd_state ^= rnd_state << 7;
rnd_state ^= rnd_state >> 9;
rnd_state ^= rnd_state << 8;
return rnd_state;
}
static void wait_frame(void)
{
while (frame_ctr == last_frame);
last_frame = frame_ctr;
}
static u8 drain_keys(void)
{
u8 c, p = 0;
while (con_stat & 1) {
c = con_data;
if (c == 'p' || c == 'P') p = 1;
}
return p;
}
/* ---------------------------------------------------------------- world */
static u8 row_info(i16 r)
{
return (r >= 0 && r < LEVEL_ROWS) ? level_rows[r] : 0;
}
/* The colour of world point (s, d). */
static u8 world(i16 s, i16 d)
{
i16 jw, jlo, k2, sb, db;
u8 ri, k, ib, g, h;
/* walls across the path: the face of the wall at the far edge of row
-jw covers the 2H units of d in front of the line d = 32 jw. The
nearest wall is tried first. */
jlo = (d >> 5) + 1;
for (jw = (d + 2 * TALL_H) >> 5; jw >= jlo; jw--) {
ri = row_info(-jw);
if (!(ri & R_WALL)) continue;
k2 = (jw << 5) - d;
h = (ri & R_DOOR) ? TALL_H : LOW_H;
k = (u8)(k2 >> 1);
if (k > h) continue;
sb = s + k2;
if (sb < 0 || sb >= 32 * BW) continue;
ib = (u8)(sb >> 5);
if (ri & R_DOOR) {
g = (ri >> 3) & 15;
if (ib >= g && ib < g + 2) {
if (k < DOOR_H) continue; /* the doorway */
if (k < DOOR_H + 3) return 14; /* its lintel */
}
}
if (k >= h - 1) return (ri & R_DOOR) ? 15 : 11; /* the top */
if (!(k & 7) || ((sb + ((k & 8) << 1)) & 31) < 2) return 8;
return (ri & R_DOOR) ? 7 : 3;
}
/* the fortress's back wall, rising from its far side (s = 0) */
if (s < 0 && s >= -2 * BACK_H) {
db = d - s;
if (row_info(-(db >> 5)) & R_FORT) {
k = (u8)((-s) >> 1);
if (k >= BACK_H - 1) return 7;
return (k & 3) ? 8 : 0;
}
}
/* its front face, below the near side (s = 32 BW) */
if (s >= 32 * BW && s < 32 * BW + 2 * FRONT_H) {
k2 = s - 32 * BW;
db = d - k2;
if (row_info(-(db >> 5)) & R_FORT)
return ((db & 31) < 2) ? 0 : 4;
}
/* the floor */
if (s >= 0 && s < 32 * BW && (row_info(-(d >> 5)) & R_FORT)) {
if ((s & 31) < 2 || (d & 31) < 2) return 0;
if ((((s >> 5) + (d >> 5)) & 3) == 0 && (s & 31) > 13 && (s & 31) < 18 &&
(d & 31) > 13 && (d & 31) < 18) return 7;
return 8;
}
/* space */
if (((s * 5 + d * 3) & 255) == 7 && !((s ^ d) & 0x60))
return (s & 16) ? 15 : 7;
return 0;
}
/* Draw screen columns xs and xs + 1 (xs even) from the world. */
static void draw_cols(u16 xs)
{
i16 wx = cx + xs, s = wx + 2 * cy, d = 2 * cy - wx;
u16 fx = fbx + xs;
u8 y, fy = fby, c0, c1, flo, fhi;
if (fx >= 320) fx -= 320;
flo = (u8)fx; fhi = (u8)(fx >> 8);
for (y = 0; y < 240; y++) {
c0 = world(s, d);
c1 = world(s + 1, d - 1);
gx_lo = flo; gx_hi = fhi; gy_p = fy;
gpix = c0; gpix = c1;
s += 2; d += 2;
if (++fy == 240) fy = 0;
}
}
/* Draw screen row ys from the world. */
static void draw_row(u8 ys)
{
i16 wy = cy + ys, s = cx + 2 * wy, d = 2 * wy - cx;
u16 x, fx = fbx;
u8 fy = fby + ys;
if (fy >= 240) fy -= 240;
gx_lo = (u8)fx; gx_hi = (u8)(fx >> 8); gy_p = fy;
for (x = 0; x < 320; x++) {
gpix = world(s, d);
s++; d--;
if (++fx == 320) { fx = 0; gx_lo = 0; gx_hi = 0; gy_p = fy; }
}
}
/* Show the camera's view. The border bit hides the screen's edges, where
advance() draws the next columns and row while this frame is on screen. */
static void set_scroll(void)
{
scr_xlo = (u8)fbx; scr_xhi = (u8)(fbx >> 8) | 2; scr_y = fby;
}
/* Put the camera at level row r (the screen centre), and draw it all. */
static void camera_at(i16 r)
{
u8 y;
/* centre: s = 16 BW (the fortress's middle), d = -32 r + 16 */
i16 sc = 16 * BW, dc = -32 * r + 16;
/* WX = (s - d) / 2, WY = (s + d) / 4, both even-friendly */
cx = ((sc - dc) >> 1) - 160;
cy = ((sc + dc) >> 2) - 120;
cx &= ~1;
cam_d = 2 * (cy + 120) - (cx + 160);
fbx = (u16)(cx % 320); if ((i16)fbx < 0) fbx += 320;
{ i16 t = cy % 240; if (t < 0) t += 240; fby = (u8)t; }
for (y = 0; y < 240; y++) draw_row(y);
}
/* Fly on: the camera moves 2 right and 1 up; draw what comes into view. */
static void advance(void)
{
cx += 2; cy -= 1;
cam_d -= 4;
fbx += 2; if (fbx >= 320) fbx -= 320;
fby = fby ? fby - 1 : 239;
draw_cols(318);
draw_row(0);
}
/* ------------------------------------------------------------- sprites */
static void spr_place(u8 n, i16 s, i16 d, u8 up, u8 shape, u8 ctl)
{
i16 x = ((s - d) >> 1) - cx - 8, y = ((s + d) >> 2) - cy - 8 - up;
sp_sel = n;
if (x < -15 || x > 319 || y < -15 || y > 239) { sp_ctl = 0; return; }
sp_xlo = (u8)x; sp_xhi = (u8)(x >> 8) & 1; sp_y = (u8)y;
sp_shape = shape; sp_ctl = ctl;
}
static void spr_off(u8 n) { sp_sel = n; sp_ctl = 0; }
static void all_off(void) { u8 i; for (i = 0; i < 32; i++) spr_off(i); }
static void load_shapes(void)
{
const u8 *p = shape_data;
u8 s, i;
for (s = 0; s < N_SHAPES; s++) {
sp_load = s;
for (i = 0; i < 128; i++) sp_data = *p++;
}
}
static i16 absd(i16 v) { return v < 0 ? -v : v; }
static void boom(i16 s, i16 d, u8 up)
{
u8 i, best = 0;
for (i = 0; i < NBOOM; i++) if (boom_t[i] < boom_t[best]) best = i;
boom_s[best] = s; boom_d[best] = d; boom_alt[best] = up; boom_t[best] = 24;
}
static void say(const char *s) { msg = s; msg_time = 120; hud_dirty = 1; }
/* ------------------------------------------------------------------ HUD */
static void bar(u8 n, u8 of)
{
u8 i;
putch('[');
for (i = 0; i < of; i++) putch(i < n ? '#' : '-');
putch(']');
}
static void hud(void)
{
hud_dirty = 0;
shown_fuel = fuel; shown_alt = alt / 6;
at(1, 1); ink("0;93"); puts_("BASTION RAID ");
ink("0;37"); puts_("SCORE "); ink("0;97"); putn(score, 6);
ink("0;37"); puts_(" LEVEL "); ink("0;97"); putn(level, 0);
ink("0;37"); puts_(" SHIPS "); ink("0;97"); putn(lives, 0);
puts_("\033[K");
at(2, 1); ink(fuel < 25 ? "0;91" : "0;37"); puts_("FUEL "); bar((fuel + 9) / 10, 10);
ink("0;37"); puts_(" ALT "); ink("0;96"); bar(shown_alt + 1, 9);
if (msg && msg_time) { ink("0;93"); puts_(" "); puts_(msg); }
puts_("\033[K");
ink("0");
}
/* ---------------------------------------------------------------- rules */
/* Does the wall at the far edge of row r stop something at s, height a? */
static u8 wall_stops(i16 r, i16 s, u8 a, u8 half)
{
u8 ri = row_info(r), g;
if (!(ri & R_WALL) || s < -half || s >= 32 * BW + half) return 0;
if (ri & R_LOW) return a <= LOW_H + 2;
if (a > TALL_H) return 0;
g = (ri >> 3) & 15;
return !(s - half >= 32 * g && s + half < 32 * g + 64 && a + 8 < DOOR_H);
}
static void crash(u8 wall)
{
u8 i;
if (inv || dead || (shield && !wall)) return;
boom(ship_s, ship_d, alt);
spr_off(SP_SHIP); spr_off(SP_SHADOW);
dead = 1; dead_time = 90;
for (i = 0; i < NSHELL; i++) { shell_life[i] = 0; spr_off(SP_SHELL + i); }
}
static void objects_in(void)
{
const u8 *o;
i16 r, ahead = -((cam_d - 12 * 32) >> 5);
u8 k;
while (next_obj < N_OBJS) {
o = level_objs + next_obj * 4;
r = o[0] | o[1] << 8;
if (r > ahead) break;
for (k = 0; k < NOBJ && obj_on[k]; k++);
if (k == NOBJ) break;
obj_on[k] = 1; obj_type[k] = o[2];
obj_s[k] = 32 * o[3] + 16; obj_d[k] = -32 * r + 16;
obj_cool[k] = 40 + (rnd() & 63);
obj_hits[k] = o[2] == O_CORE ? 4 : 1;
next_obj++;
}
}
static void hit_object(u8 k)
{
if (--obj_hits[k]) { boom(obj_s[k], obj_d[k], 4); return; }
obj_on[k] = 0;
spr_off(SP_OBJ + k);
boom(obj_s[k], obj_d[k], 0);
switch (obj_type[k]) {
case O_TURRET: score += 100; break;
case O_TANK: score += 150; fuel = fuel > 75 ? 100 : fuel + 25; say("FUEL"); break;
case O_RADAR: score += 300; break;
case O_CORE: score += 2000; say("REACTOR DESTROYED!"); break;
}
hud_dirty = 1;
}
static void objects(void)
{
static const u8 shapes[5] = { 0, S_TURRET, S_TANK, S_RADAR, S_CORE };
u8 k, i;
for (k = 0; k < NOBJ; k++) {
if (!obj_on[k]) continue;
if (obj_d[k] > cam_d + 8 * 32) { obj_on[k] = 0; spr_off(SP_OBJ + k); continue; }
spr_place(SP_OBJ + k, obj_s[k], obj_d[k], 4, shapes[obj_type[k]], 1);
if (!dead && alt < 12 && absd(obj_s[k] - ship_s) < 16 && absd(obj_d[k] - ship_d) < 16) {
hit_object(k); crash(0); continue;
}
if (obj_type[k] == O_TURRET && !dead && obj_d[k] < ship_d && obj_d[k] > ship_d - 8 * 32) {
if (obj_cool[k]) obj_cool[k]--;
else {
for (i = 0; i < NSHELL && shell_life[i]; i++);
if (i < NSHELL) {
shell_s[i] = obj_s[k]; shell_d[i] = obj_d[k]; shell_life[i] = 70;
}
obj_cool[k] = (level > 3 ? 40 : 100 - 20 * level) + (rnd() & 63);
}
}
}
}
static void shells(void)
{
u8 i;
for (i = 0; i < NSHELL; i++) {
if (!shell_life[i]) continue;
shell_life[i]--;
shell_d[i] += 6;
if (shell_s[i] < ship_s) shell_s[i]++; else if (shell_s[i] > ship_s) shell_s[i]--;
/* moving towards the viewer, it crosses the far edge of row -(d >> 5) */
if (!shell_life[i] || (((shell_d[i] - 6) >> 5) != (shell_d[i] >> 5) &&
wall_stops(-(shell_d[i] >> 5), shell_s[i], 10, 2))) {
shell_life[i] = 0; spr_off(SP_SHELL + i); continue;
}
spr_place(SP_SHELL + i, shell_s[i], shell_d[i], 10, S_SHELL, 1);
if (!dead && absd(shell_s[i] - ship_s) < 12 && absd(shell_d[i] - ship_d) < 12 && alt < 22) {
shell_life[i] = 0; spr_off(SP_SHELL + i);
crash(0);
}
}
}
static void fighters(void)
{
u8 i, k;
if (!dead && (row_info(-(cam_d >> 5) + 4) & R_FIGHTERS) && !--fight_timer) {
fight_timer = (level > 3 ? 25 : 55 - 10 * level) + (rnd() & 31);
for (i = 0; i < NFIGHT && fight_on[i]; i++);
if (i < NFIGHT) {
fight_on[i] = 1;
fight_s[i] = 24 + (rnd() % (32 * BW - 48));
fight_d[i] = cam_d - 7 * 32;
fight_alt[i] = 6 + (rnd() % 40);
}
}
for (i = 0; i < NFIGHT; i++) {
if (!fight_on[i]) continue;
fight_d[i] += 6;
if (!(last_frame & 3)) {
if (fight_alt[i] < alt) fight_alt[i]++; else if (fight_alt[i] > alt) fight_alt[i]--;
}
if (fight_d[i] > cam_d + 8 * 32) { fight_on[i] = 0; spr_off(SP_FIGHT + i); continue; }
spr_place(SP_FIGHT + i, fight_s[i], fight_d[i], fight_alt[i], S_FIGHTER, 1);
if (!dead && absd(fight_s[i] - ship_s) < 16 && absd(fight_d[i] - ship_d) < 16 &&
absd(fight_alt[i] - alt) < 10) {
fight_on[i] = 0; spr_off(SP_FIGHT + i);
boom(fight_s[i], fight_d[i], fight_alt[i]);
crash(0);
}
for (k = 0; k < NSHOT; k++)
if (shot_life[k] && absd(shot_s[k] - fight_s[i]) < 16 && absd(shot_d[k] - fight_d[i]) < 20 &&
absd(shot_alt[k] - fight_alt[i]) < 12) {
shot_life[k] = 0; spr_off(SP_SHOT + k);
fight_on[i] = 0; spr_off(SP_FIGHT + i);
boom(fight_s[i], fight_d[i], fight_alt[i]);
score += 200; hud_dirty = 1;
break;
}
}
}
static void shots(u8 j)
{
u8 i, k;
i16 od;
if (!(j & J_FIRE)) fire_held = 0;
else if (!fire_held && !dead) {
fire_held = 1;
for (i = 0; i < NSHOT && shot_life[i]; i++);
if (i < NSHOT) {
shot_s[i] = ship_s; shot_d[i] = ship_d - 12; shot_alt[i] = alt; shot_life[i] = 28;
}
}
for (i = 0; i < NSHOT; i++) {
if (!shot_life[i]) continue;
od = shot_d[i];
shot_d[i] -= 12;
shot_life[i]--;
if ((od >> 5) != (shot_d[i] >> 5) && wall_stops(-(od >> 5), shot_s[i], shot_alt[i], 2)) {
shot_life[i] = 0;
boom(shot_s[i], (od >> 5) << 5, shot_alt[i]);
}
if (shot_alt[i] < 16)
for (k = 0; k < NOBJ && shot_life[i]; k++)
if (obj_on[k] && absd(obj_s[k] - shot_s[i]) < 16 && absd(obj_d[k] - shot_d[i]) < 16) {
shot_life[i] = 0;
hit_object(k);
}
if (!shot_life[i]) { spr_off(SP_SHOT + i); continue; }
spr_place(SP_SHOT + i, shot_s[i], shot_d[i], shot_alt[i], S_SHOT, 1);
}
}
static void booms(void)
{
u8 i;
for (i = 0; i < NBOOM; i++) {
if (!boom_t[i]) continue;
boom_t[i]--;
if (!boom_t[i]) { spr_off(SP_BOOM + i); continue; }
spr_place(SP_BOOM + i, boom_s[i], boom_d[i], boom_alt[i], (boom_t[i] & 4) ? S_BOOM1 : S_BOOM2, 1);
}
}
static void fly(u8 j)
{
i16 od = ship_d;
if (dead) return;
if (j & J_LEFT) ship_s -= 3;
if (j & J_RIGHT) ship_s += 3;
if (ship_s < 16) ship_s = 16;
if (ship_s > 32 * BW - 16) ship_s = 32 * BW - 16;
if ((j & J_UP) && alt < MAX_ALT) alt++;
if ((j & J_DOWN) && alt > 2) alt--;
ship_d = cam_d + SHIP_D;
if ((od >> 5) != (ship_d >> 5) && !inv && wall_stops(-(od >> 5), ship_s, alt, 10)) {
say("YOU HIT THE WALL");
crash(1);
return;
}
if (++fuel_tick >= 24) {
fuel_tick = 0;
if (fuel) fuel--;
if (!fuel) { say("OUT OF FUEL"); crash(0); return; }
if (fuel != shown_fuel) hud_dirty = 1;
}
if (alt / 6 != shown_alt) hud_dirty = 1;
spr_place(SP_SHIP, ship_s, ship_d, alt, S_SHIP, (inv & 4) ? 0 : 1);
if ((row_info(-(ship_d >> 5)) & R_FORT) && ship_s >= 0 && ship_s < 32 * BW)
spr_place(SP_SHADOW, ship_s, ship_d, 0, S_SHADOW, 1);
else
spr_off(SP_SHADOW);
}
/* ------------------------------------------------------------- screens */
static void clear_all(void)
{
gfill = 0; /* also sprites off, scroll to 0 */
while (gfill & 1);
all_off();
}
static u8 wait_fire(void)
{
u8 j;
while (joy & (J_FIRE | J_ENTER | J_ESC)) { wait_frame(); drain_keys(); }
for (;;) {
wait_frame(); drain_keys(); rnd();
j = joy;
if (j & J_ESC) return 0;
if (j & (J_FIRE | J_ENTER)) return 1;
}
}
static u8 title(void)
{
clear_all();
puts_("\033[0m\033[2J");
camera_at(12);
set_scroll();
ship_s = 16 * BW; ship_d = cam_d + SHIP_D; alt = 24;
spr_place(SP_SHIP, ship_s, ship_d, alt, S_SHIP, 1);
ink("1;93"); centre(5, "B A S T I O N R A I D");
ink("0;97");
centre(8, "Fly over the fortress and destroy its reactor core.");
centre(10, "UP / DOWN climb and dive LEFT / RIGHT steer SPACE fire");
centre(12, "Climb over low walls. Fly low through the doors in tall ones.");
centre(13, "Your shadow and the altimeter show your height.");
centre(14, "Shoot fuel tanks for fuel. Turrets and fighters shoot back.");
centre(16, "P pauses. ESC gives up.");
ink("1;96"); centre(28, "PRESS SPACE TO BEGIN");
ink("0");
return wait_fire();
}
static void reset_level(void)
{
u8 i;
for (i = 0; i < NSHOT; i++) shot_life[i] = 0;
for (i = 0; i < NFIGHT; i++) fight_on[i] = 0;
for (i = 0; i < NSHELL; i++) shell_life[i] = 0;
for (i = 0; i < NBOOM; i++) boom_t[i] = 0;
for (i = 0; i < NOBJ; i++) obj_on[i] = 0;
next_obj = 0;
fight_timer = 30;
clear_all();
camera_at(-6);
set_scroll();
ship_s = 16 * BW; alt = 24; ship_d = cam_d + SHIP_D;
inv = 90; dead = 0;
}
/* Play until the ships run out (or Esc); returns 1 to go on to the title. */
static void play(void)
{
u8 j, i;
lives = 3; score = 0; level = 1;
puts_("\033[2J");
for (;;) {
fuel = 100; fuel_tick = 0; fire_held = 1;
reset_level();
msg = 0; msg_time = 0;
say("LEVEL START");
hud();
for (;;) {
wait_frame();
set_scroll();
if (drain_keys()) {
at(2, 50); ink("0;93"); puts_("PAUSED - P TO GO ON\033[K"); ink("0");
for (;;) {
wait_frame();
if (joy & J_ESC) { quit = 1; return; }
if (drain_keys()) break;
}
hud_dirty = 1;
}
j = joy;
if (j & J_ESC) return;
fly(j);
objects_in();
objects();
shots(j);
shells();
fighters();
booms();
if (inv) inv--;
if (msg_time && !--msg_time) hud_dirty = 1;
if (hud_dirty) hud();
if (dead) {
if (!--dead_time) {
if (!--lives) {
hud();
ink("0;44;97");
centre(13, " ");
centre(14, " GAME OVER ");
centre(15, " ");
ink("0");
for (i = 0; i < 120; i++) { wait_frame(); drain_keys(); }
return;
}
dead = 0; inv = 120;
if (fuel < 40) fuel = 40;
alt = 24;
hud_dirty = 1;
}
}
if (-(ship_d >> 5) >= LEVEL_ROWS) break; /* through the level */
advance();
}
score += 500;
level++;
say("LEVEL CLEARED");
hud();
for (i = 0; i < 90; i++) { wait_frame(); drain_keys(); }
}
}
int main(void)
{
rnd_state = 0xBEEF ^ frame_ctr;
last_frame = frame_ctr;
puts_("\033[?3l\033[?25l");
load_shapes();
quit = 0;
while (!quit) {
if (!title()) break;
play();
}
clear_all();
puts_("\033[0m\033[2J\033[H\033[?25h");
while (con_stat & 1) (void)con_data;
}
+758
View File
@@ -0,0 +1,758 @@
:10A20000973200009382C2F3173300001303C30197
:10A2100063F8620023A00200938242006FF05FFFA8
:10A2200017130000670003E0834700F093F727004F
:10A23000E38C07FEA300A0F067800000130101FF7C
:10A240002324810023261100130405000345040084
:10A25000631A05008320C10003248100130101015A
:10A26000678000001304140097000000E78000FCE2
:10A270006FF0DFFD130101FE232C8100232A9100E2
:10A28000232E110093840500130400009306A00000
:10A29000130690003377D5029307040093870701D4
:10A2A000B3872700130414001374F40F1307070374
:10A2B000238CE7FE930705003355D502E36CF6FCCB
:10A2C000636E9400631804028320C101032481019A
:10A2D000832441011301010267800000130500037C
:10A2E0009384F4FF97000000E78040F493F4F40FA8
:10A2F0006FF01FFD1304F4FF1374F40F93070401B0
:10A30000B387270003C587FF97000000E78000F2AE
:10A310006FF05FFB130101FF2322910093040500FE
:10A320001305B001232611002324810013840500A6
:10A3300097000000E78080EF1305B005970000004C
:10A34000E780C0EE9305000013850400970000002D
:10A35000E78080F21305B00397000000E78000ED6E
:10A36000130504009305000097000000E780C0F08B
:10A37000032481008320C10083244100130580044D
:10A380001301010117030000670043EA130101FFF5
:10A3900023248100130405001305B00123261100B6
:10A3A00097000000E78080E81305B00597000000E3
:10A3B000E780C0E71305040097000000E78040E84D
:10A3C000032481008320C1001305D006130101017D
:10A3D00017030000670083E5130101FF23248100B8
:10A3E0002326110013840500930700003307F400AF
:10A3F00003470700631A070293D7170093059002DB
:10A40000B385F54093F5F50F97000000E780C0F0A5
:10A4100013050400032481008320C10013010101FE
:10A42000170300006700C3E19387170093F7F70F46
:10A430006FF0DFFBB7D7000003D547141317750083
:10A440003345E50013150501135505011357950014
:10A450003345E500131785003345E5001315050165
:10A46000135505012392A71467800000B7D7000099
:10A4700003C7A714834680F7E38EE6FE034780F701
:10A480002385E7146780000013050000930600058C
:10A49000834700F093F7170063940700678000007C
:10A4A000034710F01377F70D6304D70093070500F7
:10A4B000138507006FF0DFFDB7D7000003C7E72162
:10A4C000A30AE0F283D7E72193D7870093E7270019
:10A4D000230BF0F2B7D7000083C7C721A30BF0F21C
:10A4E00067800000B7D8000083D828223388C54091
:10A4F000135818403308184113180801135808015D
:10A50000B7D80000839808222308A0F61305780026
:10A5100013150501135505011303E014636EA3021F
:10A52000B385C500130680FF33061641B306D64037
:10A5300093D52540B385D500139605019395050164
:10A5400093D50541930610FF1356060163C6D50047
:10A550009306F00E63D6B600A30A00F667800000EB
:10A56000930688FF93F5F60F93D68600A308B0F6FE
:10A5700093F616002309D0F69376F60FA309D0F6CA
:10A58000230AE0F6A30AF0F667800000B7D70000C0
:10A590009386071B03C8160003C7071B9387071B77
:10A5A0003337E800B308D70003C8260083C6080085
:10A5B0006374D80013072000B7D6000013181700E3
:10A5C0009386061CB38606012390A600B7D600002A
:10A5D0009386861BB38606012390B600B7D600008B
:10A5E0009386461BB306D700B387E70013078001A5
:10A5F0002380C6002380E70067800000130101FF6D
:10A6000023202101130905001305B005232481002F
:10A6100023229100232611009384050013040000D7
:10A6200097000000E78080C01305D0026374240106
:10A6300013053002130414001374F40F9700000084
:10A64000E780C0BEE39284FE032481008320C10022
:10A6500083244100032901001305D00513010101E2
:10A6600017030000670083BC130101FE23282101AA
:10A6700037D9000003473921B7D7000023840714D6
:10A68000B7D70000A383E714B7D70000232C8100BD
:10A6900003C4572193076000930510003354F4025C
:10A6A00013051000B7D70000232E1100232A9100B4
:10A6B000232631012324410137CA0000B7C400001A
:10A6C000B7C900002383871497000000E780C0C447
:10A6D0001305CA6D97000000E78080CB37C50000E6
:10A6E0001305456E97000000E78080B51385446D23
:10A6F00097000000E780C0C937C500001305456F0B
:10A7000097000000E780C0B31385C96F9700000071
:10A71000E78000C8B7D7000003D5A72093056000E5
:10A7200097000000E78040B51385446D9700000056
:10A73000E78000C637C5000013054570970000008C
:10A74000E78000B01385C96F97000000E78040C420
:10A75000B7D7000003C5272193050000970000002C
:10A76000E78080B11385446D97000000E78040C208
:10A7700037C500001305057197000000E78040AC65
:10A780001385C96F97000000E78080C0B7D700002D
:10A7900003C5472193050000B7C9000097000000DA
:10A7A000E78080AD1385C97197000000E78040A95C
:10A7B000130520009305100097000000E780C0B546
:10A7C00003473921930780011385446D63E6E70051
:10A7D00037C500001305C56C97000000E78040BB3B
:10A7E00037C500001305057297000000E78040A5FB
:10A7F000034539219307A0009305A0001305950098
:10A800003345F5021375F50F97000000E78040DF30
:10A810001385446D97000000E78080B737C50000BE
:10A820001305857297000000E78080A137C50000FE
:10A830001305057397000000E78080B51305140029
:10A84000930590001375F50F97000000E78040DB3B
:10A85000B7D7000003A40714630C0402B7D70000A5
:10A8600083C7C713638607021305CA6D97000000EC
:10A87000E78000B237C5000013058573970000001C
:10A88000E780009C1305040097000000E780409BD0
:10A890001385C97197000000E780809A0324810125
:10A8A0008320C10183244101032901018329C100BF
:10A8B000032A810037C500001305C5731301010287
:10A8C000170300006700C3AC230A00F2834740F37C
:10A8D00093F71700E39C07FE130700022308F0F626
:10A8E00093871700A30A00F693F7F70FE398E7FEA4
:10A8F00067800000130101FF23248100B7D7000007
:10A9000037D4000083C717210347042123261100F1
:10A91000B3E7E7006392070AB7D7000083C7F720C1
:10A9200063840700630A0508B7D7000003C65721F0
:10A93000B7D7000083956721B7D70000039587211B
:10A9400097000000E780C0C4230800F6A30A00F6C1
:10A950009307B0012308F0F6A30A00F6930710004E
:10A960002308F4201307A005B7D700002386E720AB
:10A97000B7D700002384071C130780002308E0F6E4
:10A98000A30A00F69387871CA38007001307900093
:10A990002308E0F6A30A00F6238107001307A000AE
:10A9A0002308E0F6A30A00F6A38107009307B0008E
:10A9B0002308F0F6A30A00F68320C10003248100D7
:10A9C0001301010167800000B7D7000093870715C6
:10A9D000B387A70083C6070037D7000013070718FF
:10A9E0009386F6FF93F6F60F2380D700B7D70000C3
:10A9F0001316150093878719638006023307C70073
:10AA0000B387C700831507000395070013064000AE
:10AA1000170300006700C3B7B7D60000130101FF9A
:10AA2000938686162324810023261100B386A60070
:10AA3000238006009306F50093F6F60F2308D0F660
:10AA40003307C700B387C700A30A00F683150700C2
:10AA5000130405000395070013060000970000008B
:10AA6000E78000B3B7D7000093874717B387870005
:10AA700083C70700130730006380E70C6368F702A1
:10AA8000130710006388E70413072000638EE704B0
:10AA90008320C10003248100B7D7000013071000F2
:10AAA0002384E714130101016780000013074000AD
:10AAB000E390E7FE37D700008357A7209387077DF1
:10AAC0002315F720B7C7000037D700009387877496
:10AAD0006F00400537D700008357A72093874706AC
:10AAE0002315F7206FF0DFFA37D700008357A72030
:10AAF0001306B004938767092315F72037D70000A2
:10AB000083463721938706006374D6009307B00409
:10AB100093879701A309F720B7C7000037D7000034
:10AB2000938707742320F714B7D700001307800713
:10AB3000238EE7126FF0DFF537D700008357A72089
:10AB40009387C7126FF0DFF9131705011357070139
:10AB50009307D01563ECE706B7D700009387C7A526
:10AB60003385A7008347050013F5670063020506D8
:10AB70003307D0401305000063CCE5041387F613B8
:10AB80006348B70413F52700630605001335760103
:10AB90006780000013078003636CC7029397270048
:10ABA00093F7071E3387D54013051000634CF70059
:10ABB000B385D5009387070463D6F5001336660185
:10ABC000133516001375F50F67800000130500009C
:10ABD000678000009386050793D6564013D65540EC
:10ABE0009396060193D6060113160601139E0501DE
:10ABF000B30ED04013560601135E0E019396560015
:10AC0000130F1600B386C641130101FF131F0F0176
:10AC1000939E0E0113930601B7D2000023268100F4
:10AC2000232491002322210193070500135F0F4184
:10AC300093DE0E01135303019303D0159382C2A533
:10AC40001304F0139304D0013305D041131505010B
:10AC5000135505416350E5099396070193D6060104
:10AC60001385060313150501135505011307F0029B
:10AC7000636EA7143307DE4013170701135707410C
:10AC8000135757403307E0401317070113570701C5
:10AC90009306D01563EAE622B7D600009386C6A5D0
:10ACA0003387E6000347070013771700630E07207A
:10ACB000B307F04093D717401307600113057000E6
:10ACC0006346F70A93F73700B337F0001395370060
:10ACD0006F00C00963EED30D3387D20183460700AE
:10ACE00013F766006306070C1315030193FF460074
:10ACF000135505419308400163840F0093088003B6
:10AD0000135515401377F50F63E4E80A3308F30091
:10AD10001318080113580801636C0409131808017B
:10AD200013580841135558401379F50F63860F02E5
:10AD300093D6360093F6F600636ED900938616001C
:10AD400063CAA60063F6E406930700021305E00059
:10AD500063FEE700930F40009388F8FF63421703F8
:10AD60001305F00063940F001305B0000324C10025
:10AD70008324810003294100130101016780000041
:10AD80009377770013058000E38207FE13171700FF
:10AD900013770701330707011377E701E30807FC7F
:10ADA00013057000E3940FFC130530006FF01FFCD7
:10ADB000938E1E00930603FE939E0E0113930601CD
:10ADC00093DE0E01135303016FF01FE8138506ECA9
:10ADD000131505011355050113077002636CA704D1
:10ADE0003307AE4013150701131707011357074127
:10ADF000135757403307E040131707011357070154
:10AE00009306D0151355050163E0E60CB7D6000094
:10AE10009386C6A53387E60003470700137717001C
:10AE20006304070A1375E5013335A00013152500E7
:10AE30006FF0DFF31307F0136368D708B306C04061
:10AE40009396060193D606011307D015636ED706B5
:10AE500037D700001307C7A53307D70003470700FC
:10AE6000137717006302070613F7E70113050000C5
:10AE7000E30E07EE13F7E501E30A07EE13D7574099
:10AE80003306E6001376360013058000E31006EE65
:10AE900093F7F701938727FF9397070193D707014C
:10AEA00013073000E364F7EC13F5F501130525FFF4
:10AEB00013150501135505019307300033B5A7009D
:10AEC000130575006FF09FEA1307500093063000DA
:10AED000B386D502130500003387E7023307D70096
:10AEE0001377F70F93067000E312D7E8B3C5F500A8
:10AEF00093F50506E39C05E693F707011305F000BB
:10AF0000E39607E6130570006FF05FE6B7D7000021
:10AF100083D7072237D7000003572722B307F5004E
:10AF20009397170093970701130101FE93D7070129
:10AF300023244101338AE700B387E740232A9100A5
:10AF400093940701B7D700002328210103D9E721F3
:10AF5000B7D7000083C7C721232C8100131A0A0129
:10AF60003305F500232E1100232631012322510140
:10AF70001374F50F9307F00E135A0A0193D40401CA
:10AF800063F68700130404011374F40F9377F90F29
:10AF90002308F0F293578900A308F0F2230980F206
:10AFA00093090000930A0014B385344133053A0134
:10AFB000939505011315050193D5054113550541D9
:10AFC0001309190097000000E78000C11319090157
:10AFD000A309A0F213590901631A5901230800F2C9
:10AFE000A30800F2230980F21309000093891900D5
:10AFF0009399090193D90901E39859FB8320C10171
:10B000000324810183244101032901018329C10013
:10B01000032A8100832A4100130101026780000096
:10B02000130101F923261106232481062322910608
:10B0300023202107232E3105232C4105232A5105E6
:10B0400023286105232671052324810523229105E8
:10B050002320A105232EB103834780F737C7FFFFC5
:10B060001307F7EEB3C7E70037D700002312F71432
:10B07000034780F737C50000B7D700001305C57533
:10B080002385E71497F0FFFFE780801BB7D7000008
:10B090009387C7BB130700009306B000230BE0F6AD
:10B0A0001386070883C5070093871700A30BB0F624
:10B0B000E39AC7FE130717001377F70FE310D7FEC5
:10B0C000B7D70000A3840714B7D7000093878790F1
:10B0D0002322F102B7D700009387C79A2324F102F5
:10B0E000B7D7000003C497146310041E97F0FFFF46
:10B0F000E780C07D37C500001305857697F0FFFF18
:10B10000E78000149307800637D700002311F72249
:10B11000B7D60000130740F52390E622130700E995
:10B12000B7D60000239DE62037D70000231FF72065
:10B130009307400437D70000230EF7209304000F35
:10B1400013050400130414001374F40F9700000097
:10B15000E78000DCE31694FE97F0FFFFE7800036FF
:10B160009307000A37D40000231CF420B7D700004F
:10B1700003D6A721B7D70000B7D4000013060608EE
:10B180001316060113560641239BC720930780011F
:10B1900013070000930680019305000AA38AF42098
:10B1A000130500009307100097F0FFFFE780C033FE
:10B1B00037C500001305457797F0FFFFE780401D76
:10B1C000B7C500009385C5771305500097F0FFFFC2
:10B1D000E780C02037C500001305C56F97F0FFFF5B
:10B1E000E780001BB7C500009385457913058000F3
:10B1F00097F0FFFFE780801EB7C500009385857C30
:10B200001305A00097F0FFFFE780401DB7D50000B1
:10B210009385C5801305C00097F0FFFFE780001CF1
:10B22000B7D500009385C5841305D00097F0FFFFC4
:10B23000E780C01AB7D500009385C5871305E000E5
:10B2400097F0FFFFE7808019B7D500009385858BC5
:10B250001305000197F0FFFFE780401837D5000085
:10B260001305458D97F0FFFFE7808012B7D50000EA
:10B270001305C0019385C58D97F0FFFFE780001689
:10B28000B7C700001385C77397F0FFFFE780401032
:10B29000834780F893F7070B639C070897F0FFFF3D
:10B2A000E780001D97F0FFFFE780401E97F0FFFF4B
:10B2B000E7808018834780F813F7F70F939787018B
:10B2C00093D7874163D0070897F0FFFFE7800060BE
:10B2D00037D500001305458F97F0FFFFE78040F654
:10B2E000834700F093F71700638407006F10803ADC
:10B2F0008320C10603248106832441060329010615
:10B300008329C105032A8105832A4105032B0105F1
:10B31000832BC104032C8104832C4104032D0104DD
:10B32000832DC1031305000013010107678000008E
:10B3300097F0FFFFE780C01397F0FFFFE78000154D
:10B340006FF01FF593770703E38A07F4B7D7000080
:10B3500013073000238AE72037C50000B7D7000065
:10B360002395072037D70000930710001305C576F3
:10B370002309F72097F0FFFFE78080ECB7D70000A4
:10B3800093874717232EF100B7D700001307400615
:10B39000A389E720B7D7000037DA0000238707200A
:10B3A00013071000B7D70000A386E72093074A1FB2
:10B3B00023810700B7D70000B7D9000023AE071CD0
:10B3C000B7D7000023A4071CB7DA00009387091B36
:10B3D0002381070093878A1623A0070023A2070072
:10B3E00023A40700B7D7000037D70000239607141F
:10B3F0009307E001A305F7142398091A231A0A1EDC
:10B4000097F0FFFFE780804C930780F437D7000068
:10B410002311F722930740FE37D700002310F722AD
:10B420009307000D37D70000231DF72093078008EE
:10B4300037D70000231FF720930740FD37D70000C0
:10B44000230EF72093074A1F2322F1009387091B3D
:10B450002320F10293878A16130900002326F100A6
:10B460009309000F13050900130919001379F90F47
:10B4700097000000E780C0A9E31639FF97F0FFFFAF
:10B48000E780C0039307000A231CF4209307800180
:10B49000A38AF420B7D7000083D7A72137D70000AD
:10B4A00093870708231BF7209307A00537D70000D1
:10B4B000A308F72003274102B7D7000023880720FD
:10B4C000B7D7000023A0E714B7D700001307800701
:10B4D000238EE712B7D70000130710002384E71468
:10B4E00097F0FFFFE7808018B7D700009387C7A5C4
:10B4F000232CF10097F0FFFFE78080F797F0FFFF24
:10B50000E780C0FB97F0FFFFE78040F86302050883
:10B51000930520031305200097F0FFFFE780C0DFAD
:10B5200037C500001305C56D97F0FFFFE78040E6C3
:10B5300037D500001305459197F0FFFFE78040D015
:10B54000B7C700001385C77397F0FFFFE78040E49B
:10B5500097F0FFFFE780C0F1834780F8939787015A
:10B5600093D7874163DA07009307100037D70000AD
:10B57000A304F7146FF0DFB697F0FFFFE78000F148
:10B58000E30805FCB7D70000130710002384E71475
:10B59000834780F813F9F70F9397870193D7874173
:10B5A000E3C007B4B7D7000083C70721639807102B
:10B5B000B7D7000003956721937749006388070098
:10B5C000835784219387D7FF231CF4209377890026
:10B5D000638807008357842193873700231CF42056
:10B5E000031784219307F00063C8E7009307000165
:10B5F000231CF4206F00C00093070013E3CAE7FE8A
:10B6000093771900638C070083C754211307F00256
:10B610006366F70093871700A38AF42093772900C5
:10B62000638C070083C75421130720006376F7005B
:10B630009387F7FFA38AF420B7D7000083D9A72107
:10B64000B7D700001355554093890908939909010C
:10B6500093D90941239B372193D759406302F516AB
:10B66000B7D7000083C71721639C071403C6542172
:10B67000831584219306A0003305A04097F0FFFFB7
:10B68000E780C04C630E0512B7D700009387C792BE
:10B6900037D700002320F714B7D70000130780071F
:10B6A000238EE712B7D70000130710002384E71496
:10B6B0001305100097F0FFFFE7800024B7D70000C4
:10B6C0008397A721B7DB000037DC0000938707E8EA
:10B6D00093D75740B307F0409399070193D9094195
:10B6E000938B8B19130C0C18B7D7000003DBC7140E
:10B6F0009307B00263E0672383278102931A2B002C
:10B70000B38AFA0003D70A009317070193D70741BA
:10B7100063C2F920130A00001306C0008327C1008A
:10B72000B307FA0083C607006392061E9306100053
:10B730002380D7008327C10183C62A00B38747012E
:10B740002380D70083C73A0093161A003386DB00A4
:10B7500093975700938707012310F600930700FE85
:10B760003307F702B306DC00130707012390E60056
:10B7700097F0FFFFE78040CCB7D700009387C7154D
:10B780001375F50303C72A00B38747011305850224
:10B790002380A700930740006304F70013071000FD
:10B7A000B7D7000093870715B38747012380E700C9
:10B7B000130B1B00B7D70000239667156FF0DFF25D
:10B7C00037D700008347E72093067001938717005F
:10B7D00093F7F70F63EEF60A2307F72083C6542189
:10B7E000B7D7000003C7671493076000B3D7F6020A
:10B7F0006308F700B7D70000130710002384E7148D
:10B80000B7D7000083C717218315842113070000D1
:10B8100093D7270093C7170093F7170013860900E3
:10B820001305000097F0FFFFE78000CCB7D70000BA
:10B83000039667211307D01593575640B307F0407E
:10B840009397070193D70701636AF70A03278101DA
:10B85000B307F70083C7070093F717006380070A51
:10B86000831584219307F0131397050113570701DC
:10B8700063E6E70893071000130710009306000023
:10B880001305B00197F0FFFFE78000C66FF01FE3DC
:10B890002307072037D70000834737216386070037
:10B8A0009387F7FFA309F72083473721639A07029D
:10B8B000B7D700009387079437D700002320F714E9
:10B8C000B7D7000013078007238EE712B7D7000011
:10B8D000130710002384E714130500006FF09FDDA9
:10B8E00037D7000003477714E30AF7EEB7D7000015
:10B8F000130710002384E7146FF05FEE9307B00185
:10B900002308F0F6A30A00F66FF05FDB130A1A00B3
:10B91000E316CAE0832AC100B7DB0000B7D90000F4
:10B9200037DA0000938BCB15130A0A18938989190B
:10B93000930C0000130BC00083C70A006388070242
:10B94000B7D700008397A721031C0A0093FDFC0FC3
:10B950001385FD00938707101375F50F63D08713C8
:10B9600023800A002308A0F6A30A00F6938C1C008B
:10B97000938A1A00938B1B0093892900130A2A00CB
:10B98000E39C6CFBB7D600009386861FB7D70000F8
:10B99000137909012328D10083C7471F37D7000037
:10B9A00037D60000B7D9000063160922A306072086
:10B9B000032B4100832B01019389C91F13094620E2
:10B9C000930A1000130DF000930C400083470B0006
:10B9D00063880736039C09009387F7FF2300FB0069
:10B9E000130A4CFF83C70B00931D0A01131A0A01A7
:10B9F000135A0A412324F1002390490113555C4056
:10BA000093575A4093DD0D016300F5048317090035
:10BA10000326810093062000938507003305A0408C
:10BA2000232AF10097F0FFFFE7804012630E050024
:10BA3000032681000325410123000B0093750CFEB2
:10BA400097F0FFFFE780C0B4832781006376FD2C69
:10BA500083470B0013F5FA0F6380072E83268100BE
:10BA600083150900930710001307900013060A00BE
:10BA700097F0FFFFE78040A76F00802C8327C1016C
:10BA800037D700001307479AB387FC0003CD0700A0
:10BA900083950900930710003307A70103470700A8
:10BAA0009306400013060C002324B10097F0FFFF1B
:10BAB000E78080A3B7D7000083C70721E39807EA90
:10BAC00003C754219307B00083258100E3E8E73CD6
:10BAD000835784219306F000B387F540139707013D
:10BAE000135707411357F740B347F700B387E740B1
:10BAF0009397070193D70741E3C2F63AB7D70000FF
:10BB000083D76721B307FC401397070113570741F9
:10BB10001357F740B347F700B387E7409397070100
:10BB200093D70741E3CCF63613850D0097F0FFFF5E
:10BB3000E780C0E91305000097F0FFFFE780C0DB56
:10BB40006FF0DFE2938717006398A704B7D7000070
:10BB500083C7272113073000130C8002636AF700A4
:10BB60001307C0FEB387E7029387470613FCF70F5E
:10BB700097F0FFFFE780408C1375F503330CAC00A2
:10BB800023808B016FF09FDE37D700009307000002
:10BB90001307871C13054000B386E70003C60600A1
:10BBA000E31206FA37D70000939717001307471DD3
:10BBB0003307F7002310B70037D700001307C71C5F
:10BBC000B307F70023908701930760042380F600F2
:10BBD0006FF0DFF7B7D500008346D72083C5052176
:10BBE000B3E6B600E39606DC93061000A306D72062
:10BBF000638007028327410083C717006386070617
:10BC00008327410083C72700E39407DA93072000C6
:10BC100083558421B7D600001397170093864620DA
:10BC2000B386E6002390B600B7D600009386C61F01
:10BC30003387E600B7D6000083D66621938646FF99
:10BC40002310D7000327010183C654213387E7005F
:10BC50002300D70003274100B387E7001307C00183
:10BC60002380E7006FF0DFD4930710006FF05FFAD6
:10BC70008327C100B307FC0083C707006380070860
:10BC80000355090083570700B387A74013950701A1
:10BC9000135505411355F540B347F500B387A74049
:10BCA0009397070193D70741634AF60483D70600A9
:10BCB000B387B74113950701135505411355F54057
:10BCC000B347F500B387A7409397070193D7074180
:10BCD0006346F60223000B001375FC0F2326D102E6
:10BCE000232AE10097F0FFFFE78040CE8326C102C0
:10BCF000032741019305C0001306F000130C1C003C
:10BD00001307270093862600E304BCD483470B0067
:10BD1000E39007F66FF0DFD3B7D7000093860718DC
:10BD2000B7D7000013878719130C00001306F00023
:10BD30009305C0006FF09FFD2308A0F6A30A00F64C
:10BD4000938A1A00130B1B001309290093892900F9
:10BD5000938B1B00E39C9AC737DC0000B7DB000025
:10BD600037DA0000130C8C1C938B4B1D130ACA1C72
:10BD70001309800037DB0000930AC00003470C0062
:10BD80006300070803560A001307F7FF83970B00A9
:10BD900013066600131D0601831684211377F70F1F
:10BDA000135D0D41931906012300EC002310AA0135
:10BDB00093D9090163D4D718938717002390FB0008
:10BDC000630A07029307ADFF13555D4093D75740B1
:10BDD000839C0B00638AA716930620001306A0001D
:10BDE00093850C003305A04097F0FFFFE78000D655
:10BDF000630C051423000C00230820F7A30A00F6A7
:10BE0000130919001379F90F130C1C00938B2B00E5
:10BE1000130A2A00E31459F7B7D7000083C7072194
:10BE2000B7D90000138DC91D6398071CB7D7000050
:10BE30000397A7219307400013575740B387E74064
:10BE40009397070193D707011307D0156366F71A75
:10BE500003278101B307F7008387070063DE071814
:10BE600037D700008347B7149387F7FF93F7F70F8F
:10BE7000A305F71463920718B7D7000083C72721DB
:10BE800013073000130A9001636AF700130760FF7D
:10BE9000B387E7029387770313FAF70F97E0FFFF63
:10BEA000E78080591375F501330AAA00B7D700005F
:10BEB000A385471593064000130A0000B307AA01A3
:10BEC00003C7070063160712130710002380E7005B
:10BED00097E0FFFFE7804056930600113375D502C7
:10BEE00037D7000093171A001307C71E3307F70050
:10BEF000130585012310A70037D700001307471E3D
:10BF00003307F700B7D7000083D7A721938707F23D
:10BF10002310F70097E0FFFFE7800052130780022D
:10BF20003375E502B7D700009387071EB307FA0001
:10BF3000130565002380A7006F00000CE3D2F6E82C
:10BF40009387F7FF6FF09FE7930710001307A00098
:10BF50009306A00013060D0093850C00130509003D
:10BF600097E0FFFFE780405883470B21E39A07E8FB
:10BF7000835784211307B000B385FC4093970501D4
:10BF800093D7074193D7F740B3C5B700B385F540C2
:10BF90009395050193D50541E344B7E6B7D7000073
:10BFA00083D76721B389F9409397090193D7074154
:10BFB00093D7F740B3C93701B389F9409399090181
:10BFC00093D90941E34E37E303C754219307500146
:10BFD000E3E8E7E223000C00230820F71305000044
:10BFE000A30A00F697F0FFFFE78000916FF05FE192
:10BFF000130A1A00E314DAECB7DC000037DC0000A7
:10C00000B7DA0000938CCC1E130C4C1E938A0A1EC8
:10C01000930B400037DA00009309800083470D003E
:10C02000638E070403560C008347AA1413066600A8
:10C030001318060113160601135606412310CC00EF
:10C0400093F7370013580801639C070083C70A0061
:10C0500003C7542163F4E70E938717002380FA0087
:10C06000B7D700008397A7219387071063DEC70C1B
:10C0700023000D00230870F7A30A00F6938B1B0022
:10C0800093FBFB0F130D1D00938C2C00130C2C0045
:10C09000938A1A00E3943BF9032B0102B7DA0000FC
:10C0A00037DA0000B7D90000938A0A1C130A8A1BEA
:10C0B0009389491B130CF00083470B00638E070024
:10C0C0009387F7FF93F7F70F2300FB006398072888
:10C0D000230820F7A30A00F6130919001379F90FB2
:10C0E000130B1B00938A2A00130A2A009389190054
:10C0F000E31489FD37DA000083471A2163860700BD
:10C100009387F7FFA308FA2037D900008347C913A4
:10C11000B7D90000638C07269387F7FF93F7F70FD3
:10C12000230EF91263940726930710002384F91451
:10C1300097E0FFFFE78080536F00C025E372F7F2BE
:10C140009387F7FF6FF09FF1839D0C0003CB0A00EC
:10C15000930710001307200093060B0093850D0032
:10C1600013850B002324010197E0FFFFE780C03710
:10C17000B7D7000083C70721639E070A835784212E
:10C180001307F000B38DFD4093970D0193D707413E
:10C1900093D7F740B3CDB701B38DFD40939D0D010B
:10C1A00093DD0D416348B709B7D7000083D76721F6
:10C1B000032881003308F8409317080193D70741FB
:10C1C00093D7F74033C807013308F8401318080124
:10C1D0001358084163400707B7D7000083C75721AA
:10C1E000330BFB4093170B0193D7074193D7F740CD
:10C1F00033CB6701330BFB40131B0B01135B0B01AC
:10C200009307900063E8670323000D00230870F78D
:10C21000A30A00F603950C0003C60A0083150C0060
:10C2200097E0FFFFE780C0361305000097E0FFFFAF
:10C23000E780806CB7D700009386C71FB7D7000090
:10C2400013864720930800001308F0001305300000
:10C250008327410013871800B385F80083C70500C2
:10C260006384070E03D30C0083570600B38767402F
:10C2700013930701135303411353F340B347F300E0
:10C28000B38767409397070193D70741634EF80A36
:10C2900003530C0083D70600B3876740139307014D
:10C2A000135303411353F340B347F300B38767407D
:10C2B0009397070193D70741130330016346F308AF
:10C2C00083270101B388F80083C7080083C80A00E8
:10C2D000B38717419398070193D8084193D8F84042
:10C2E000B3C7F800B38717419397070193D70701A6
:10C2F0009308B00063EAF804238005001377F70F72
:10C300002308E0F6A30A00F623000D00230870F7C7
:10C31000A30A00F603C60A0083150C0003950C005F
:10C3200097E0FFFFE780C02637D700008357A7209C
:10C330009387870C2315F720B7D700001307100049
:10C340002384E7146FF09FD3930807001306260099
:10C3500093862600E31EA7EE6FF05FD293F74700A7
:10C3600083950A0003160A0083C6090013870B0091
:10C37000638407001307700093071000130509007A
:10C3800097E0FFFFE78040166FF01FD583C7891441
:10C39000E39007DA37D70000834707216388070E49
:10C3A000B7D6000083C7C6209387F7FF93F7F70F30
:10C3B0002386F620639C070CB7D6000083C746216E
:10C3C0009387F7FF93F7F70F238AF6206394070804
:10C3D00097E0FFFFE780802937D500001305C5945B
:10C3E00097E0FFFFE780C0FA37D40000930544953B
:10C3F0001305D00097E0FFFFE78040FEB7D50000AF
:10C40000938545971305E00097E0FFFFE78000FD67
:10C41000930544951305F00097E0FFFFE78000FCCB
:10C4200037C500001305C57397E0FFFFE78040F6AE
:10C43000130480071304F4FF97E0FFFFE780400335
:10C440001374F40F97E0FFFFE7804004E31404FE49
:10C450006FE01FC993078007A308FA20B7D7000031
:10C4600083C6372123080720130770026366D700AD
:10C4700013078002A389E720B7D7000013078001C4
:10C48000A38AE720930710002384F914B7D700008C
:10C4900083976721130730EA93D7574063CAE71899
:10C4A00037D700008357272237D600009305F013B3
:10C4B000938627002311D72237D70000035907227C
:10C4C000B7D600001309F9FF13190901135909011F
:10C4D0002310272303D7A6211307C7FF239DE62098
:10C4E0008356E62113872600131707011357070108
:10C4F00063F8E500938626EC1397060113570701AE
:10C50000B7D60000231FE62003C7C621130AF00E8A
:10C51000630607001307F7FF137AF70F0357E621A7
:10C520009387071413191900939707011319090129
:10C5300093D7070113590901B38927013309F9403A
:10C540009307E71393970701139B0901238E462155
:10C55000939909011319090193D707019306F01361
:10C56000135B0B0193D909411359094163F8F60094
:10C570001307E7FF9317070193D70701130B0B1E50
:10C58000131B0B0193FBF70F93DA8700135B0B016F
:10C59000130C000F930509001385090013190901F5
:10C5A0009399090197E0FFFFE780006393D90901A0
:10C5B00013590901930C05009305F9FF1385190020
:10C5C000939505011315050193D5054113550541B3
:10C5D00097E0FFFFE7804060230870F3A30850F363
:10C5E000230940F393892900A30990F31309290033
:10C5F000130A1A0093970901131909019399090164
:10C60000A309A0F2137AFA0F93D7070193D909412E
:10C610001359094163148A01130A0000E39C67F768
:10C620001305000097F0FFFFE780808E6FE09FEC1E
:10C6300037D700008357A7209387471F2315F7207C
:10C6400037D7000083472721938717002309F72056
:10C65000B7D700009387479937D700002320F714F6
:10C6600093078007230EF91297E0FFFFE780000091
:10C670001309A0051309F9FF97E0FFFFE78040DFEA
:10C680001379F90F97E0FFFFE78040E0E31409FE1C
:10C690006FE09FCF834710F06FE09FC493071000B7
:10C6A0006316FDACB7D70000839767216350FCACDD
:10C6B000938717F0634CFCAA83C70B00638607CCF3
:10C6C0009387F7FF2380FB006FF04FAA303B39318F
:10C6D00000000000303B333700000000303B3933AE
:10C6E0000000000042415354494F4E2052414944FA
:10C6F0002020200053434F5245200000303B393763
:10C70000000000002020204C4556454C2000000031
:10C710002020205348495053200000001B5B4B0051
:10C720004655454C20000000202020414C5420005C
:10C73000303B39360000000020202000300000008F
:10C740004655454C0000000052454143544F52208D
:10C7500044455354524F5945442100001B5B3F331D
:10C760006C1B5B3F32356C001B5B306D1B5B324AD0
:10C7700000000000313B393300000000422041201E
:10C780005320542049204F204E2020205220412069
:10C7900049204400466C79206F7665722074686584
:10C7A00020666F72747265737320616E64206465B5
:10C7B0007374726F79206974732072656163746F2A
:10C7C0007220636F72652E005550202F20444F5702
:10C7D0004E20636C696D6220616E642064697665C9
:10C7E0002020202020204C454654202F205249470D
:10C7F00048542073746565722020202020205350F7
:10C80000414345206669726500000000436C696D14
:10C8100062206F766572206C6F772077616C6C7325
:10C820002E20466C79206C6F77207468726F756764
:10C83000682074686520646F6F727320696E20745D
:10C84000616C6C206F6E65732E000000596F7572FD
:10C8500020736861646F7720616E6420746865205E
:10C86000616C74696D657465722073686F77207987
:10C870006F7572206865696768742E0053686F6F02
:10C8800074206675656C2074616E6B7320666F72C0
:10C89000206675656C2E2054757272657473206104
:10C8A0006E642066696768746572732073686F6F61
:10C8B00074206261636B2E00502070617573657324
:10C8C0002E20204553432067697665732075702EAE
:10C8D00000000000313B3936000000005052455343
:10C8E0005320535041434520544F20424547494E21
:10C8F000000000001B5B306D1B5B324A1B5B481B5A
:10C900005B3F3235680000004C4556454C2053547F
:10C9100041525400504155534544202D205020543D
:10C920004F20474F204F4E1B5B4B0000594F552067
:10C93000484954205448452057414C4C00000000C1
:10C940004F5554204F46204655454C00303B34341B
:10C950003B393700202020202020202020202020AC
:10C9600020202020202020202020202020202020C7
:10C9700020200000202020202020202020204741AF
:10C980004D45204F56455220202020202020202099
:10C99000202000004C4556454C20434C4541524513
:10C9A0004400000000030405060000001E0001070B
:10C9B0002A0001043000020731000105340001059E
:10C9C0004000030743000203480003084B00010630
:10C9D0004B0002014F0002025F00010560000301ED
:10C9E0006500020565000208720002047900010674
:10C9F0007E0001047E00010781000105CB000107D4
:10CA0000E1000304E8000301EB000204F300010667
:10CA1000F700020104010101070101010F010108F2
:10CA20001001010216010302190101071B01010394
:10CA30001B01020724010103250102052601020151
:10CA4000280101062F010105300101083A01010406
:10CA500040010208440102024B01040500000000ED
:10CA600000000000000000000000010101010101C0
:10CA700001010101030101010101010101050101A0
:10CA80000101010101010103010101010101010194
:10CA90000101012D0101010101010101010101015A
:10CAA0002D01010101010101010101010103010148
:10CAB0000101010101012D0101010101010101013A
:10CAC0000101250101010101010101010101010132
:10CAD0000101010101010101010101010101010146
:10CAE0000101808080808080808080808080808044
:10CAF0008080808080808080808080808080808036
:10CB00008080808080808080808080808080808025
:10CB10008080808080808080808080808080010113
:10CB200001010101010101013D01010101010101B9
:10CB300001010103010101010101010101012D01B7
:10CB400001010101010101010101011501010101C1
:10CB500001010101010101010301010101010101C3
:10CB6000010101010145010101010101010145012D
:10CB700001010101010101010101010301010101A3
:10CB80000101010101011501010101010101010181
:10CB90000101010101010101010101010101010185
:10CBA000010101010101010101010000000000007B
:10CBB0000000000000000000000000000000000075
:10CBC0000000000000000000000000000000000065
:10CBD0000000000000000000000000000000000055
:10CBE0000000000000000000000FFF00CCCCCC0FC4
:10CBF000F666F000CCCCCFFFF6660000000FFFFF1A
:10CC0000FFF00000CCCFFFFFFCC00000CCCCCF0C6D
:10CC1000CCCC000000CCC000CCCC00000000C00098
:10CC200000C0000000000000000000000000000044
:10CC300000000000000000000000000000000000F4
:10CC400000000000000000000000000000000000E4
:10CC500000000000000000000000000000000000D4
:10CC600000000000000000000004440044444404AC
:10CC700044444000444444444444000000044444C8
:10CC800044400000444444444440000044444404BC
:10CC900044440000004440004444000000004000C0
:10CCA0000040000000000000000000000000000044
:10CCB0000000000000000000000000000000000074
:10CCC0000000000000000000000000000000000064
:10CCD0000000000000000100000100000000111130
:10CCE000000111000000111110D111110000011DEF
:10CCF000DDDDD11100000DDDDDDDD0000000BBBDAC
:10CD0000DDD11111000DBBBDD011111100DDD0001E
:10CD10000000000000000000000000000000000013
:10CD20000000000000000000000000000000000003
:10CD300000000000000000000000000000000000F3
:10CD400000000000000000000000000000000000E3
:10CD500000000000000000000000000000000000D3
:10CD6000000000000000000000000000000002229F
:10CD700022200000000022AA2222000000022AAA8B
:10CD8000A2222000000222AA222220000082227277
:10CD9000222228000888277722228880008777228D
:10CDA000222888000077788888888000000008881A
:10CDB000888000000000000000000000000000006B
:10CDC0000000000000000000000000000000BBBBED
:10CDD000BBBB0000000BBBBBBBBBB000000BBBBBB5
:10CDE000BBBBB0000009BBBBBBBB900000099F915F
:10CDF0001119900000099F911999900000099F91C5
:10CE00001199900000099F911999900000099F9134
:10CE100019999000000999999999900000011111B0
:10CE2000111110000000111111110000000000008C
:10CE300000000000000000000000000000000000F2
:10CE400000000000000000000000000000EE0000F4
:10CE50000000000000EEEEE000000000000E666E34
:10CE6000EEE00000000EEE66666EE00000000EEEE2
:10CE7000E66E00000000000770EE000000000007F2
:10CE800070000000000000077000000000000007B4
:10CE900070000000000000077000000000000008A3
:10CEA00080000000000088888888000000008888D2
:10CEB00088880000000000088000000000000000DA
:10CEC00000000000000000055000000000000055B8
:10CED000550000000000055DD5500000000055DD44
:10CEE000DD55000000055DFFFFD550000055DDFF5A
:10CEF000FFDD55000555DDFFFFDD555000555DFF99
:10CF0000FFD55500000555DDDD5550000000555D8D
:10CF1000D555000000000555555000000000005593
:10CF20005500000000000005500000000000000057
:10CF300000000000000000000000000000000000F1
:10CF400000000000000000000000000000000000E1
:10CF5000000000000000009900000000000099B0EF
:10CF60000009900000090B00BB0000000000BBFF9F
:10CF70000FB00000009B0FFFF0BB00000000B00FDF
:10CF8000F00BB0000090B0FFF00090000000BB0B71
:10CF9000B0000000000000B0000000000000090028
:10CFA0000000000000000000000000000000000081
:10CFB0000000000000000000000000000000000071
:10CFC0000000000000000000000000000000000061
:10CFD0000000000000000101010000000000000945
:10CFE000010000000009900009000000000000009E
:10CFF00000091000000990BBBB99910000090BBB10
:10D00000BB909100000000B0B090010000000999B1
:10D01000000900000001010009900000000000115B
:10D0200001100000000000000000000000000000EF
:10D0300000000000000000000000000000000000F0
:10D0400000000000000000000000000000000000E0
:10D0500000000000000000000000000000000000D0
:10D0600000000000000000000000000000000000C0
:10D07000000000000000000FF00000000000000FA2
:10D08000B0000000000000000000000000000000F0
:10D090000000000000000000000000000000000090
:10D0A0000000000000000000000000000000000080
:10D0B0000000000000000000000000000000000070
:10D0C0000000000000000000000000000000000060
:10D0D0000000000000000000000000000000000050
:10D0E0000000000000000000000000000000000937
:10D0F00090000000000000999900000000000099D5
:10D10000F90000000000000990000000000000008D
:10D11000000000000000000000000000000000000F
:10D1200000000000000000000000000000000000FF
:0CD13000000000000000000000000000F3
:040000030000A20057
:00000001FF
+128
View File
@@ -0,0 +1,128 @@
#!/usr/bin/env python3
"""Run Bastion Raid in tools/rv32emu.py on a model of the board (tools/boardemu.py)
and take screenshots.
python3 test-raid.py [--shots DIR] [--play]
It checks the title screen, measures the Z-80 instructions each frame takes
(a 60 Hz frame has about 550,000 at 90 MHz), flies into the fortress, and with
--play lets an autopilot fly the whole level: it steers through every doorway
at the right height, climbs over low walls and shoots ahead. The autopilot
can't be hit by shells or fighters (it keeps the ship invulnerable), so this
checks the level and the rules, not its skill.
"""
import argparse
import os
import sys
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(HERE, "..", "..", "tools"))
sys.path.insert(0, HERE)
from boardemu import Board, load_ihx, load_font, load_syms # noqa: E402
UP, DOWN, LEFT, RIGHT, FIRE, ENTER, ESC = 1, 2, 4, 8, 16, 32, 128
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--shots", help="write PNG screenshots here")
ap.add_argument("--play", action="store_true", help="fly the level with the autopilot")
a = ap.parse_args()
mem, hi = load_ihx(os.path.join(HERE, "raid.ihx"))
b = Board(mem, code_end=hi)
font = load_font() if a.shots else None
if a.shots:
os.makedirs(a.shots, exist_ok=True)
sym = {"_" + n: a for n, a in load_syms(os.path.join(HERE, "out", "raid.sym")).items()}
errors = 0
def check(what, ok):
nonlocal errors
print(("PASS " if ok else "FAIL ") + what)
errors += not ok
def i16(n):
v = b.m[sym[n]] | b.m[sym[n] + 1] << 8
return v - 65536 if v & 0x8000 else v
def hud():
return "\n".join(b.screen_text().display[:2])
b.run_frames(5)
check("title screen", "B A S T I O N R A I D" in "\n".join(b.screen_text().display))
if a.shots: b.shot(os.path.join(a.shots, "1-title.png"), font)
b.run_frames(3, FIRE)
b.run_frames(5)
check("game starts", "LEVEL 1" in hud() and "SHIPS 3" in hud())
c0 = b.steps
b.run_frames(60)
per = (b.steps - c0) / 60
print("%.0f instructions a frame (%.0f%% of a 60 Hz frame at 90 MHz)" % (per, per / 5500))
check("a frame fits in a 60th of a second", per < 500000)
if a.shots: b.shot(os.path.join(a.shots, "2-approach.png"), font)
alt0 = b.m[sym["_alt"]]
b.run_frames(10, UP)
check("climbing raises the ship", b.m[sym["_alt"]] == alt0 + 10)
b.run_frames(60)
if a.shots: b.shot(os.path.join(a.shots, "3-fortress.png"), font)
print(hud())
if a.play:
sys.path.insert(0, HERE)
import gen
rows, objs = gen.level()
frame = 0
best_row = 0
worst = 0
while frame < 6000 and b.pc != 0:
b.m[sym["_shield"]] = 1
b.m[sym["_fuel"]] = 100
if b.m[sym["_dead"]]:
r = -(i16("_ship_d") >> 5)
print("autopilot crashed at row %d: ship s %d, height %d; rows here %s" %
(r, i16("_ship_s"), b.m[sym["_alt"]], rows[r - 2:r + 3]))
break
ship_s, ship_d, alt = i16("_ship_s"), i16("_ship_d"), b.m[sym["_alt"]]
row = -(ship_d >> 5)
best_row = max(best_row, row)
# the next wall within 6 rows decides where to be
want_s, want_alt = 16 * gen.BW, 24
for r in range(row, min(row + 6, len(rows))):
ri = rows[r]
if ri & 4:
g = (ri >> 3) & 15
want_s, want_alt = 32 * g + 32, 10
break
if ri & 2:
want_alt = 30
break
j = 0
if ship_s < want_s - 2: j |= RIGHT
elif ship_s > want_s + 2: j |= LEFT
if alt < want_alt: j |= UP
elif alt > want_alt: j |= DOWN
if frame % 6 == 0: j |= FIRE
c0 = b.steps
b.run_frames(1, j)
worst = max(worst, b.steps - c0)
frame += 1
if frame == 700 and a.shots: b.shot(os.path.join(a.shots, "4-doorway.png"), font)
if "LEVEL 2" in hud():
break
check("autopilot flew the level (got to row %d of %d)" % (best_row, len(rows)),
"LEVEL 2" in hud())
print("slowest frame: %d instructions (%.0f%% of a 60 Hz frame)" % (worst, worst / 5500))
check("every frame fits in a 60th of a second", worst < 550000)
print(hud())
b.run_frames(120) # level 2 starts
b.run_frames(5, ESC) # give up: back to the title
b.run_frames(5)
check("Esc gives up the game", "PRESS SPACE TO BEGIN" in "\n".join(b.screen_text().display))
b.run_frames(5, ESC) # Esc at the title: back to BASIC
b.run_frames(5)
check("Esc returns to BASIC", b.pc == 0)
sys.exit(1 if errors else 0)
if __name__ == "__main__":
main()