chore: version Zelda 1 port and engineering records
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { Inventory } from @zelda1:inventory;
|
||||
import { BombRouteLinkChecks } from @zelda1:link;
|
||||
declare service BombRouteEnemyChecks {
|
||||
fn combat() -> int {
|
||||
let unlocked=Stage.advance(240,141,2,0,0,false,false);
|
||||
Inventory.reset(); Loot.reset(); Link.start_game(); BombRouteLinkChecks.position(224,141);
|
||||
let sword=Inventory.take_sword(1); e0.kind=9; e0.reset(128,141,0); e0.cloud=0; e0.direction=1;
|
||||
BombRouteLinkChecks.hit(128,141); e0.update(0,255);
|
||||
if e0.hp!=1 || e0.hurt_timer!=16 || e0.dying!=0 || Loot.unharmed_kills()!=0 { return 1; }
|
||||
BombRouteLinkChecks.hit(e0.x,e0.y); e0.update(0,255);
|
||||
if e0.hp!=1 { return 2; }
|
||||
for i: int from 0 until 40 { Loot.tick(); e0.update(0,255); }
|
||||
BombRouteLinkChecks.hit(e0.x,e0.y); e0.update(0,255);
|
||||
if e0.hp!=0 || Loot.unharmed_kills()!=1 { return 3; }
|
||||
for i: int from 0 until 18 { e0.update(0,0); }
|
||||
// The native first blue cycle is 1: r=0 produces a bomb pack.
|
||||
loot0.reset(); Enemies.finish(e0,loot0,0);
|
||||
if loot0.id!=0 { return 4; }
|
||||
loot0.lifetime=239;
|
||||
let taken=loot0.update(loot0.x,loot0.y-3,true,false,0);
|
||||
if !taken || Inventory.read_slot(1)!=4 { return 5; }
|
||||
BombRouteLinkChecks.position(128,141); let placed=BombRouteLinkChecks.bomb();
|
||||
if !placed || Inventory.read_slot(1)!=3 { return 6; }
|
||||
return 0;
|
||||
}
|
||||
fn visual() -> void {
|
||||
Inventory.reset(); Link.start_game(); BombRouteLinkChecks.position(240,141); Enemies.reset();
|
||||
Enemies.spawn_north(); active_room=5;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
declare service BombRouteLinkChecks {
|
||||
fn position(x: int,y: int) -> void { controller.place_for_stage(state,x,y,2,true); vitals.reset(); }
|
||||
fn hit(x: int,y: int) -> void { beam.x=x; beam.y=y; beam.phase=16; beam.direction=1; }
|
||||
fn bomb() -> bool { Inventory.ensure_selection(); Link.use_b(true); return bomb0.phase==1; }
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { BombRouteStageChecks } from @zelda1:stage;
|
||||
import { BombRouteEnemyChecks, Enemies } from @zelda1:enemies/octorok;
|
||||
import { InventoryScreen } from @zelda1:screens/inventory;
|
||||
import { Scene } from @zelda1:scene;
|
||||
import { Hud } from @zelda1:hud;
|
||||
import { Link } from @zelda1:link;
|
||||
import { Gfx } from @sdk:gfx;
|
||||
import { Color } from @core:color;
|
||||
import { Pad, Button } from @sdk:input;
|
||||
declare global phase: int=0;
|
||||
declare global failures: int=0;
|
||||
declare global view: int=0;
|
||||
[Init] fn init() -> void {}
|
||||
[Frame] fn frame() -> void {
|
||||
if phase==0 { let good=BombRouteStageChecks.check(); if !good { failures+=1; } phase=1; }
|
||||
else if phase==1 { let good=BombRouteStageChecks.reverse(); if !good { failures+=2; } phase=2; }
|
||||
else if phase==2 { let good=BombRouteStageChecks.check(); if !good { failures+=4; } phase=3; }
|
||||
else if phase==3 { let good=BombRouteEnemyChecks.combat(); if good!=0 { failures+=8+good; } phase=4; }
|
||||
else if phase==4 { BombRouteEnemyChecks.visual(); Scene.reset(); phase=5; }
|
||||
if Pad.pressed(Button.Select) { view=(view+1)%2; if view==1 { InventoryScreen.open(); } else { InventoryScreen.reset(); Scene.reset(); } }
|
||||
if view==1 { let closed=InventoryScreen.advance(false,0); InventoryScreen.draw(); }
|
||||
else { if Scene.ensure_ready() { Hud.draw(); Link.draw(); Enemies.draw(); } }
|
||||
Scene.draw_frame();
|
||||
Gfx.fill_rect(0,0,3,3,if phase<5 { Color.rgb(0,0,255) } else if failures==0 { Color.rgb(0,255,0) } else { Color.rgb(failures as long,0,0) });
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
declare service BombRouteStageChecks {
|
||||
fn enter() -> void { Stage.reset(); flow.active=2; }
|
||||
fn hop(left: bool) -> bool {
|
||||
let old=Stage.id(); let x=if left { 0 } else { 240 }; let dir=if left { 2 } else { 1 };
|
||||
let c=Stage.advance(x,141,dir,0,0,false,false);
|
||||
if !Stage.scrolling() || c!=2 { return false; }
|
||||
for i: int from 0 until 63 { let command=Stage.advance(flow.x,flow.y,dir,0,0,false,false); }
|
||||
if !Stage.scrolling() { return false; }
|
||||
let final_command=Stage.advance(flow.x,flow.y,dir,0,0,false,false);
|
||||
if Stage.scrolling() { return false; }
|
||||
let id=Stage.id(); return id==old+(if left { 1 } else { -1 });
|
||||
}
|
||||
fn check() -> bool {
|
||||
BombRouteStageChecks.enter();
|
||||
for i: int from 0 until 3 { let good=BombRouteStageChecks.hop(true); if !good { return false; } }
|
||||
let id=Stage.id(); let room=Stage.room_id(); return id==5 && room==100;
|
||||
}
|
||||
fn reverse() -> bool {
|
||||
for i: int from 0 until 3 { let good=BombRouteStageChecks.hop(false); if !good { return false; } }
|
||||
let id=Stage.id(); return id==2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
import { WorldFlags } from @zelda1:world;
|
||||
import { OverworldStart } from @zelda1:stages/overworld_start;
|
||||
import { Inventory } from @zelda1:inventory;
|
||||
import { Stage } from @zelda1:stage;
|
||||
import { Link, WallLinkChecks } from @zelda1:link;
|
||||
import { Scene } from @zelda1:scene;
|
||||
declare global wall_error: int=0;
|
||||
declare service WallGameChecks {
|
||||
fn check_phase(n: int) -> void {
|
||||
if n==0 {
|
||||
game.boot(); game.new_game(); for i: int from 0 until 76 { game.update(false,false,false,false,false,false,false,false); }
|
||||
let tested=WallLinkChecks.phases(); if !tested { wall_error=1; }
|
||||
let enter=OverworldStart.can_enter(64,77,0); let tile=OverworldStart.tile_at(8,3);
|
||||
if enter || tile!=217 { wall_error=2; }
|
||||
WallLinkChecks.place(120,141,1);
|
||||
} else if n==1 {
|
||||
for i: int from 0 until 22 { game.update(true,false,false,false,false,false,false,false); }
|
||||
let bombs=Inventory.read_slot(1); if bombs!=4 { wall_error=3; }
|
||||
WallLinkChecks.place(64,93,8); game.update(false,false,false,false,false,true,false,false);
|
||||
let opened=WorldFlags.secret_found(119); if opened { wall_error=4; }
|
||||
} else if n==2 {
|
||||
for i: int from 0 until 47 { game.update(false,false,false,false,false,false,false,false); }
|
||||
let opened=WorldFlags.secret_found(119); if opened { wall_error=5; }
|
||||
} else if n==3 {
|
||||
game.update(false,false,false,false,false,false,false,false);
|
||||
let opened=WorldFlags.secret_found(119); let tile=OverworldStart.tile_at(8,3); let enter=OverworldStart.can_enter(64,77,0);
|
||||
if !opened || tile!=36 || !enter { wall_error=6; }
|
||||
} else if n==4 {
|
||||
for i: int from 0 until 140 { game.update(false,false,false,true,false,false,false,false); }
|
||||
let id=Stage.id(); if id!=1 { wall_error=7; }
|
||||
} else if n==5 {
|
||||
WallLinkChecks.place(120,157,8);
|
||||
for i: int from 0 until 6 { game.update(false,false,false,true,false,false,false,false); }
|
||||
let sword=Inventory.sword_level(); if sword!=1 { wall_error=8; }
|
||||
WallLinkChecks.place(112,221,4);
|
||||
for i: int from 0 until 66 { game.update(false,false,true,false,false,false,false,false); }
|
||||
let id=Stage.id(); let opened=WorldFlags.secret_found(119); if id!=0 || !opened { wall_error=9; }
|
||||
} else if n==6 {
|
||||
game.continue_game(); for i: int from 0 until 76 { game.update(false,false,false,false,false,false,false,false); }
|
||||
let opened=WorldFlags.secret_found(119); let sword=Inventory.sword_level(); if !opened || sword!=1 { wall_error=10; }
|
||||
} else if n==7 {
|
||||
game.new_game(); for i: int from 0 until 76 { game.update(false,false,false,false,false,false,false,false); }
|
||||
let opened=WorldFlags.secret_found(119); let sword=Inventory.sword_level(); if opened || sword!=0 { wall_error=11; }
|
||||
} else if n==8 {
|
||||
game.update(false,false,false,false,false,false,true,false);
|
||||
for i: int from 0 until 35 { game.update(false,false,false,false,false,false,false,false); }
|
||||
} else if n==9 {
|
||||
for i: int from 0 until 32 { game.update(false,false,false,false,false,false,false,false); }
|
||||
} else if n==10 {
|
||||
game.update(false,false,false,false,false,false,true,false);
|
||||
for i: int from 0 until 59 { game.update(false,false,false,false,false,false,false,false); }
|
||||
} else if n==11 {
|
||||
WallLinkChecks.place(120,61,8); game.update(false,false,false,true,false,false,false,false);
|
||||
for i: int from 0 until 22 { game.update(false,false,false,false,false,false,false,false); }
|
||||
} else if n==12 {
|
||||
for i: int from 0 until 22 { game.update(false,false,false,false,false,false,false,false); }
|
||||
} else if n==13 {
|
||||
WallLinkChecks.place(120,221,4); game.update(false,false,true,false,false,false,false,false);
|
||||
for i: int from 0 until 22 { game.update(false,false,false,false,false,false,false,false); }
|
||||
} else if n==14 {
|
||||
for i: int from 0 until 22 { game.update(false,false,false,false,false,false,false,false); }
|
||||
let closed=OverworldStart.wall_closed(); if !closed { wall_error=12; }
|
||||
}
|
||||
game.draw();
|
||||
}
|
||||
fn failure_code() -> int { return wall_error; }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { WorldFlags } from @zelda1:world;
|
||||
declare service WallLinkChecks {
|
||||
fn place(x: int,y: int,facing: int) -> void { controller.place_for_stage(state,x,y,facing,true); vitals.reset(); }
|
||||
fn phases() -> bool {
|
||||
Link.start_game(); WorldFlags.reset();
|
||||
for phase: int from 0 until 5 {
|
||||
if phase!=3 { bomb0.x=64; bomb0.y=77; bomb0.phase=phase; bomb0.timer=10; Link.update(false,false,false,false,false); let opened=WorldFlags.secret_found(119); if opened { return false; } }
|
||||
}
|
||||
bomb0.x=80; bomb0.y=77; bomb0.phase=3; bomb0.timer=10;
|
||||
bomb1.x=64; bomb1.y=77; bomb1.phase=3; bomb1.timer=10;
|
||||
Link.update(false,false,false,false,false); let opened=WorldFlags.secret_found(119); if opened { return false; }
|
||||
bomb0.reset(); Link.update(false,false,false,false,false); let opened_after=WorldFlags.secret_found(119); if !opened_after { return false; }
|
||||
Link.start_game(); WorldFlags.reset(); return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import { Enemies } from @zelda1:enemies/octorok;
|
||||
import { Link, LinkCombatChecks } from @zelda1:link;
|
||||
import { Stage } from @zelda1:stage;
|
||||
import { Inventory } from @zelda1:inventory;
|
||||
import { WorldFlags } from @zelda1:world;
|
||||
import { Loot } from @zelda1:loot;
|
||||
declare global test_rock: Rock = new Rock(0,0,0,0,0);
|
||||
declare global enemy_check_failures: int = 0;
|
||||
declare global enemy_check_count: int = 0;
|
||||
declare service EnemyCombatChecks {
|
||||
fn check(passed: bool) -> void { enemy_check_count+=1; if !passed { enemy_check_failures+=1; } }
|
||||
fn bounce_case(facing: int, incoming: int, dx: int, dy: int) -> void {
|
||||
Inventory.reset(); LinkCombatChecks.place(120,141,facing);
|
||||
let x=120; let y=141;
|
||||
if incoming==1 { x-=6; } else if incoming==2 { x+=6; }
|
||||
else if incoming==4 { y-=6; } else { y+=6; }
|
||||
test_rock.launch(x,y,incoming); test_rock.update();
|
||||
EnemyCombatChecks.check(test_rock.direction!=0 && test_rock.bounce==facing && test_rock.distance==0);
|
||||
x=test_rock.x; y=test_rock.y; test_rock.update();
|
||||
EnemyCombatChecks.check(test_rock.x==x+dx && test_rock.y==y+dy && test_rock.distance==2);
|
||||
for tick: int from 0 until 14 { test_rock.update(); }
|
||||
EnemyCombatChecks.check(test_rock.direction!=0 && test_rock.distance==30);
|
||||
test_rock.update(); EnemyCombatChecks.check(test_rock.direction==0);
|
||||
let partial=Inventory.read_slot(25); EnemyCombatChecks.check(partial==255);
|
||||
}
|
||||
fn run() -> int {
|
||||
Stage.reset(); EnemyCombatChecks.bounce_case(8,4,1,-2); EnemyCombatChecks.bounce_case(4,8,-1,2);
|
||||
EnemyCombatChecks.bounce_case(2,1,-2,-1); EnemyCombatChecks.bounce_case(1,2,2,-1);
|
||||
Inventory.reset(); LinkCombatChecks.place(120,141,8);
|
||||
test_rock.launch(120,147,8); test_rock.update();
|
||||
let partial=Inventory.read_slot(25); EnemyCombatChecks.check(partial==127 && test_rock.direction==0);
|
||||
test_rock.launch(120,147,8); test_rock.update();
|
||||
partial=Inventory.read_slot(25); EnemyCombatChecks.check(partial==127 && test_rock.direction!=0);
|
||||
// Visit the northern stage with the player at its actual entrance.
|
||||
Inventory.reset(); WorldFlags.reset(); Enemies.reset(); Loot.reset(); Stage.reset(); Link.start_game();
|
||||
let command=Stage.advance(120,61,8,0,0,false,true);
|
||||
for tick: int from 0 until 44 { command=Stage.advance(120,61,8,0,0,false,false); }
|
||||
command=Stage.advance(120,221,8,0,0,false,false); LinkCombatChecks.place(120,221,8);
|
||||
Enemies.update(); let alive=Enemies.alive_count(); EnemyCombatChecks.check(alive==4);
|
||||
EnemyCombatChecks.check(e0.x==80 && e0.y==93 && e1.x==80 && e1.y==157);
|
||||
// A completed death advances room/cycle/drop; leaving clears the drop.
|
||||
e0.hp=0; e0.dying=0; Loot.monster_killed(1); Enemies.update();
|
||||
alive=Enemies.alive_count(); EnemyCombatChecks.check(alive==3 && room_killed==1 && loot0.id==24);
|
||||
WorldFlags.mark_room_item_taken(103); Enemies.leave_room();
|
||||
EnemyCombatChecks.check(loot0.id<0);
|
||||
let count=WorldFlags.kill_count(103); EnemyCombatChecks.check(count==1);
|
||||
Enemies.update(); alive=Enemies.alive_count(); EnemyCombatChecks.check(alive==3 && e3.hp<0 && e3.dying==0);
|
||||
// Killing the remaining three keeps the room empty on immediate reentry.
|
||||
e0.hp=0; e0.dying=0; e1.hp=0; e1.dying=0; e2.hp=0; e2.dying=0;
|
||||
Enemies.update(); Enemies.leave_room(); count=WorldFlags.kill_count(103); EnemyCombatChecks.check(count==7);
|
||||
Enemies.update(); alive=Enemies.alive_count(); EnemyCombatChecks.check(alive==0);
|
||||
let taken=WorldFlags.room_item_taken(103); EnemyCombatChecks.check(taken);
|
||||
WorldFlags.clear_history(); Enemies.abandon_room(); Enemies.update();
|
||||
alive=Enemies.alive_count(); EnemyCombatChecks.check(alive==4);
|
||||
// Death abandons this visit; it does not save its in-room kill count.
|
||||
e0.hp=0; e0.dying=0; Enemies.update(); Enemies.abandon_room(); Enemies.update();
|
||||
alive=Enemies.alive_count(); EnemyCombatChecks.check(alive==4);
|
||||
Enemies.abandon_room(); return enemy_check_failures;
|
||||
}
|
||||
fn count() -> int { return enemy_check_count; }
|
||||
fn draw_bounces(clock: int) -> void {
|
||||
for col: int from 0 until 4 {
|
||||
let facing=if col==0 { 8 } else if col==1 { 4 } else if col==2 { 2 } else { 1 };
|
||||
test_rock.launch(48+col*48,208,1); test_rock.bounce=facing;
|
||||
for tick: int from 0 until clock%16 { test_rock.update(); }
|
||||
test_rock.draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { Link } from @zelda1:link;
|
||||
import { Inventory } from @zelda1:inventory;
|
||||
import { Stage } from @zelda1:stage;
|
||||
declare global test_beam: SwordBeam = new SwordBeam(0,0,0,0,0);
|
||||
declare global link_check_failures: int = 0;
|
||||
declare global link_check_count: int = 0;
|
||||
declare service LinkCombatChecks {
|
||||
fn check(passed: bool) -> void { link_check_count+=1; if !passed { link_check_failures+=1; } }
|
||||
fn place(x: int, y: int, facing: int) -> void { controller.place_for_stage(state,x,y,facing,true); vitals.reset(); }
|
||||
fn run() -> int {
|
||||
Inventory.reset(); Stage.reset(); Link.start_game();
|
||||
let full=Inventory.full_hearts(); LinkCombatChecks.check(full);
|
||||
let damage=Inventory.damage_life(128); full=Inventory.full_hearts(); LinkCombatChecks.check(!full);
|
||||
let launched=test_beam.launch(120,141,8); LinkCombatChecks.check(!launched && test_beam.phase==0);
|
||||
Inventory.reset(); damage=Inventory.damage_life(127);
|
||||
full=Inventory.full_hearts(); LinkCombatChecks.check(full);
|
||||
launched=test_beam.launch(120,141,8); LinkCombatChecks.check(launched && test_beam.x==120 && test_beam.y==125);
|
||||
launched=test_beam.launch(120,141,8); LinkCombatChecks.check(!launched);
|
||||
test_beam.update(); LinkCombatChecks.check(test_beam.y==122);
|
||||
let hit=test_beam.hits(160,122,8); LinkCombatChecks.check(!hit);
|
||||
hit=test_beam.hits(120,122,8); LinkCombatChecks.check(hit && test_beam.phase==17 && test_beam.radius==2);
|
||||
hit=test_beam.hits(120,122,8); LinkCombatChecks.check(!hit);
|
||||
for tick: int from 0 until 21 { test_beam.update(); }
|
||||
LinkCombatChecks.check(test_beam.phase==17 && test_beam.radius==23);
|
||||
test_beam.update(); LinkCombatChecks.check(test_beam.phase==0);
|
||||
Inventory.reset();
|
||||
launched=test_beam.launch(120,141,1); LinkCombatChecks.check(launched && test_beam.x==136 && test_beam.y==141);
|
||||
test_beam.update(); LinkCombatChecks.check(test_beam.x==139);
|
||||
test_beam.reset(); launched=test_beam.launch(120,141,2); LinkCombatChecks.check(launched && test_beam.x==104);
|
||||
test_beam.reset(); launched=test_beam.launch(120,141,4); LinkCombatChecks.check(launched && test_beam.y==157);
|
||||
test_beam.reset(); launched=test_beam.launch(4,141,2); LinkCombatChecks.check(!launched && test_beam.phase==0);
|
||||
launched=test_beam.launch(120,141,8);
|
||||
for tick: int from 0 until 22 { test_beam.update(); }
|
||||
LinkCombatChecks.check(test_beam.phase==17);
|
||||
// Actual weapon timing: the beam begins when extended state 2 reaches 3.
|
||||
Link.start_game(); let taken=Inventory.take_sword(1); LinkCombatChecks.check(taken);
|
||||
for tick: int from 0 until 12 { Link.update(false,false,false,false,tick==0); Link.draw(); }
|
||||
LinkCombatChecks.check(beam.phase==0 && state.sword_state==2);
|
||||
Link.update(false,false,false,false,false); Link.draw();
|
||||
LinkCombatChecks.check(beam.phase==16 && beam.y==125 && state.sword_state==3);
|
||||
// Stage reposition invalidates the shot; a partial heart suppresses the next.
|
||||
Link.start_game(); LinkCombatChecks.check(beam.phase==0);
|
||||
damage=Inventory.damage_life(128);
|
||||
for tick: int from 0 until 13 { Link.update(false,false,false,false,tick==0); Link.draw(); }
|
||||
LinkCombatChecks.check(beam.phase==0);
|
||||
Link.start_game(); return link_check_failures;
|
||||
}
|
||||
fn count() -> int { return link_check_count; }
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { Link, LinkInventoryChecks } from @zelda1:link;
|
||||
import { Inventory } from @zelda1:inventory;
|
||||
import { InventoryScreen } from @zelda1:screens/inventory;
|
||||
declare service GameInventoryChecks {
|
||||
fn run() -> bool {
|
||||
game.boot(); game.update(false,false,false,false,false,false,true,false);
|
||||
for i: int from 0 until 76 { game.update(false,false,false,false,false,false,false,false); }
|
||||
if game.mode!=5 { return false; }
|
||||
let taken=Inventory.take_drop(0); Inventory.ensure_selection();
|
||||
game.update(false,false,false,false,false,true,false,false);
|
||||
let x=Link.x(); let y=Link.y(); let signature=LinkInventoryChecks.paused_signature();
|
||||
game.update(false,false,false,false,false,false,true,false);
|
||||
for i: int from 0 until 70 { game.update(true,false,false,false,false,true,false,false); }
|
||||
if !InventoryScreen.active() || Link.x()!=x || Link.y()!=y || LinkInventoryChecks.paused_signature()!=signature { return false; }
|
||||
game.update(false,false,false,false,false,false,true,false);
|
||||
for i: int from 0 until 59 { game.update(false,false,false,false,false,false,false,false); }
|
||||
if InventoryScreen.opened() { return false; }
|
||||
game.update(false,false,false,false,false,false,false,false);
|
||||
if LinkInventoryChecks.paused_signature()==signature { return false; }
|
||||
game.boot(); return game.mode==0 && !InventoryScreen.opened();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
import { LinkInventoryChecks } from @zelda1:link;
|
||||
import { GameInventoryChecks } from @zelda1:game;
|
||||
import { Gfx } from @sdk:gfx;
|
||||
import { Color } from @core:color;
|
||||
import { InventoryScreen } from @zelda1:screens/inventory;
|
||||
import { Stage } from @zelda1:stage;
|
||||
import { Link } from @zelda1:link;
|
||||
import { InventoryGraphics } from @zelda1:screens/inventory;
|
||||
declare global test_extra: int=0;
|
||||
declare global test_batch: int=0;
|
||||
declare global test_count: int=0;
|
||||
declare global test_failed: int=0;
|
||||
declare global test_results: array<int> = new array<int>(2048);
|
||||
declare service InventoryChecks {
|
||||
fn check(value: bool) -> void { test_results[test_count]=if value { 1 } else { 0 }; test_count+=1; if !value { test_failed+=1; } }
|
||||
fn selection_case(values: array<int>, start: int, direction: int, expected: int) -> void { let s=new BSelection(values,start,0); s.search(direction,start); InventoryChecks.check(s.selected==expected); }
|
||||
// ORACLE_BATCHES
|
||||
fn batch_138() -> void {}
|
||||
fn batch_139() -> void {}
|
||||
fn extra() -> int {
|
||||
Inventory.reset(); Stage.reset(); Link.start_game();
|
||||
inventory_slots[7]=2; inventory_slots[15]=1; Inventory.ensure_selection();
|
||||
if selection.selected!=7 { return 1; }
|
||||
let damage=Inventory.damage_life(300); Link.use_b(true);
|
||||
let heal_active=Link.healing(); let potion_count=Inventory.read_slot(7);
|
||||
if !heal_active { return 20+potion_count; } if potion_count!=1 { return 30+potion_count; }
|
||||
for tick: int from 0 until 200 { if Link.healing() { Link.heal_frame(); } }
|
||||
let still_healing=Link.healing(); let full=Inventory.full_hearts(); if still_healing || !full { return 3; }
|
||||
Link.use_b(true); for tick: int from 0 until 200 { if Link.healing() { Link.heal_frame(); } }
|
||||
Inventory.ensure_selection(); if selection.selected!=15 { return 40+selection.selected; } let remaining_potions=Inventory.read_slot(7); if remaining_potions!=0 { return 60+remaining_potions; }
|
||||
inventory_slots[1]=3; inventory_slots[29]=1; selection.selected=0; selection.previous=0;
|
||||
Inventory.select_direction(1); if selection.selected!=1 { return 5; }
|
||||
Inventory.select_direction(1); if selection.selected!=1 { return 6; }
|
||||
Inventory.select_direction(0); Inventory.select_direction(1); if selection.selected!=15 { return 7; }
|
||||
Inventory.select_direction(0); Inventory.select_direction(1); if selection.selected!=0 { return 8; }
|
||||
inventory_slots[30]=1; let displayed=Inventory.selected_display_slot(); if displayed!=30 { return 9; }
|
||||
return 0;
|
||||
}
|
||||
fn frame() -> void {
|
||||
if test_batch==0 { InventoryChecks.batch_0(); }
|
||||
if test_batch==1 { InventoryChecks.batch_1(); }
|
||||
if test_batch==2 { InventoryChecks.batch_2(); }
|
||||
if test_batch==3 { InventoryChecks.batch_3(); }
|
||||
if test_batch==4 { InventoryChecks.batch_4(); }
|
||||
if test_batch==5 { InventoryChecks.batch_5(); }
|
||||
if test_batch==6 { InventoryChecks.batch_6(); }
|
||||
if test_batch==7 { InventoryChecks.batch_7(); }
|
||||
if test_batch==8 { InventoryChecks.batch_8(); }
|
||||
if test_batch==9 { InventoryChecks.batch_9(); }
|
||||
if test_batch==10 { InventoryChecks.batch_10(); }
|
||||
if test_batch==11 { InventoryChecks.batch_11(); }
|
||||
if test_batch==12 { InventoryChecks.batch_12(); }
|
||||
if test_batch==13 { InventoryChecks.batch_13(); }
|
||||
if test_batch==14 { InventoryChecks.batch_14(); }
|
||||
if test_batch==15 { InventoryChecks.batch_15(); }
|
||||
if test_batch==16 { InventoryChecks.batch_16(); }
|
||||
if test_batch==17 { InventoryChecks.batch_17(); }
|
||||
if test_batch==18 { InventoryChecks.batch_18(); }
|
||||
if test_batch==19 { InventoryChecks.batch_19(); }
|
||||
if test_batch==20 { InventoryChecks.batch_20(); }
|
||||
if test_batch==21 { InventoryChecks.batch_21(); }
|
||||
if test_batch==22 { InventoryChecks.batch_22(); }
|
||||
if test_batch==23 { InventoryChecks.batch_23(); }
|
||||
if test_batch==24 { InventoryChecks.batch_24(); }
|
||||
if test_batch==25 { InventoryChecks.batch_25(); }
|
||||
if test_batch==26 { InventoryChecks.batch_26(); }
|
||||
if test_batch==27 { InventoryChecks.batch_27(); }
|
||||
if test_batch==28 { InventoryChecks.batch_28(); }
|
||||
if test_batch==29 { InventoryChecks.batch_29(); }
|
||||
if test_batch==30 { InventoryChecks.batch_30(); }
|
||||
if test_batch==31 { InventoryChecks.batch_31(); }
|
||||
if test_batch==32 { InventoryChecks.batch_32(); }
|
||||
if test_batch==33 { InventoryChecks.batch_33(); }
|
||||
if test_batch==34 { InventoryChecks.batch_34(); }
|
||||
if test_batch==35 { InventoryChecks.batch_35(); }
|
||||
if test_batch==36 { InventoryChecks.batch_36(); }
|
||||
if test_batch==37 { InventoryChecks.batch_37(); }
|
||||
if test_batch==38 { InventoryChecks.batch_38(); }
|
||||
if test_batch==39 { InventoryChecks.batch_39(); }
|
||||
if test_batch==40 { InventoryChecks.batch_40(); }
|
||||
if test_batch==41 { InventoryChecks.batch_41(); }
|
||||
if test_batch==42 { InventoryChecks.batch_42(); }
|
||||
if test_batch==43 { InventoryChecks.batch_43(); }
|
||||
if test_batch==44 { InventoryChecks.batch_44(); }
|
||||
if test_batch==45 { InventoryChecks.batch_45(); }
|
||||
if test_batch==46 { InventoryChecks.batch_46(); }
|
||||
if test_batch==47 { InventoryChecks.batch_47(); }
|
||||
if test_batch==48 { InventoryChecks.batch_48(); }
|
||||
if test_batch==49 { InventoryChecks.batch_49(); }
|
||||
if test_batch==50 { InventoryChecks.batch_50(); }
|
||||
if test_batch==51 { InventoryChecks.batch_51(); }
|
||||
if test_batch==52 { InventoryChecks.batch_52(); }
|
||||
if test_batch==53 { InventoryChecks.batch_53(); }
|
||||
if test_batch==54 { InventoryChecks.batch_54(); }
|
||||
if test_batch==55 { InventoryChecks.batch_55(); }
|
||||
if test_batch==56 { InventoryChecks.batch_56(); }
|
||||
if test_batch==57 { InventoryChecks.batch_57(); }
|
||||
if test_batch==58 { InventoryChecks.batch_58(); }
|
||||
if test_batch==59 { InventoryChecks.batch_59(); }
|
||||
if test_batch==60 { InventoryChecks.batch_60(); }
|
||||
if test_batch==61 { InventoryChecks.batch_61(); }
|
||||
if test_batch==62 { InventoryChecks.batch_62(); }
|
||||
if test_batch==63 { InventoryChecks.batch_63(); }
|
||||
if test_batch==64 { InventoryChecks.batch_64(); }
|
||||
if test_batch==65 { InventoryChecks.batch_65(); }
|
||||
if test_batch==66 { InventoryChecks.batch_66(); }
|
||||
if test_batch==67 { InventoryChecks.batch_67(); }
|
||||
if test_batch==68 { InventoryChecks.batch_68(); }
|
||||
if test_batch==69 { InventoryChecks.batch_69(); }
|
||||
if test_batch==70 { InventoryChecks.batch_70(); }
|
||||
if test_batch==71 { InventoryChecks.batch_71(); }
|
||||
if test_batch==72 { InventoryChecks.batch_72(); }
|
||||
if test_batch==73 { InventoryChecks.batch_73(); }
|
||||
if test_batch==74 { InventoryChecks.batch_74(); }
|
||||
if test_batch==75 { InventoryChecks.batch_75(); }
|
||||
if test_batch==76 { InventoryChecks.batch_76(); }
|
||||
if test_batch==77 { InventoryChecks.batch_77(); }
|
||||
if test_batch==78 { InventoryChecks.batch_78(); }
|
||||
if test_batch==79 { InventoryChecks.batch_79(); }
|
||||
if test_batch==80 { InventoryChecks.batch_80(); }
|
||||
if test_batch==81 { InventoryChecks.batch_81(); }
|
||||
if test_batch==82 { InventoryChecks.batch_82(); }
|
||||
if test_batch==83 { InventoryChecks.batch_83(); }
|
||||
if test_batch==84 { InventoryChecks.batch_84(); }
|
||||
if test_batch==85 { InventoryChecks.batch_85(); }
|
||||
if test_batch==86 { InventoryChecks.batch_86(); }
|
||||
if test_batch==87 { InventoryChecks.batch_87(); }
|
||||
if test_batch==88 { InventoryChecks.batch_88(); }
|
||||
if test_batch==89 { InventoryChecks.batch_89(); }
|
||||
if test_batch==90 { InventoryChecks.batch_90(); }
|
||||
if test_batch==91 { InventoryChecks.batch_91(); }
|
||||
if test_batch==92 { InventoryChecks.batch_92(); }
|
||||
if test_batch==93 { InventoryChecks.batch_93(); }
|
||||
if test_batch==94 { InventoryChecks.batch_94(); }
|
||||
if test_batch==95 { InventoryChecks.batch_95(); }
|
||||
if test_batch==96 { InventoryChecks.batch_96(); }
|
||||
if test_batch==97 { InventoryChecks.batch_97(); }
|
||||
if test_batch==98 { InventoryChecks.batch_98(); }
|
||||
if test_batch==99 { InventoryChecks.batch_99(); }
|
||||
if test_batch==100 { InventoryChecks.batch_100(); }
|
||||
if test_batch==101 { InventoryChecks.batch_101(); }
|
||||
if test_batch==102 { InventoryChecks.batch_102(); }
|
||||
if test_batch==103 { InventoryChecks.batch_103(); }
|
||||
if test_batch==104 { InventoryChecks.batch_104(); }
|
||||
if test_batch==105 { InventoryChecks.batch_105(); }
|
||||
if test_batch==106 { InventoryChecks.batch_106(); }
|
||||
if test_batch==107 { InventoryChecks.batch_107(); }
|
||||
if test_batch==108 { InventoryChecks.batch_108(); }
|
||||
if test_batch==109 { InventoryChecks.batch_109(); }
|
||||
if test_batch==110 { InventoryChecks.batch_110(); }
|
||||
if test_batch==111 { InventoryChecks.batch_111(); }
|
||||
if test_batch==112 { InventoryChecks.batch_112(); }
|
||||
if test_batch==113 { InventoryChecks.batch_113(); }
|
||||
if test_batch==114 { InventoryChecks.batch_114(); }
|
||||
if test_batch==115 { InventoryChecks.batch_115(); }
|
||||
if test_batch==116 { InventoryChecks.batch_116(); }
|
||||
if test_batch==117 { InventoryChecks.batch_117(); }
|
||||
if test_batch==118 { InventoryChecks.batch_118(); }
|
||||
if test_batch==119 { InventoryChecks.batch_119(); }
|
||||
if test_batch==120 { InventoryChecks.batch_120(); }
|
||||
if test_batch==121 { InventoryChecks.batch_121(); }
|
||||
if test_batch==122 { InventoryChecks.batch_122(); }
|
||||
if test_batch==123 { InventoryChecks.batch_123(); }
|
||||
if test_batch==124 { InventoryChecks.batch_124(); }
|
||||
if test_batch==125 { InventoryChecks.batch_125(); }
|
||||
if test_batch==126 { InventoryChecks.batch_126(); }
|
||||
if test_batch==127 { InventoryChecks.batch_127(); }
|
||||
if test_batch==128 { InventoryChecks.batch_128(); }
|
||||
if test_batch==129 { InventoryChecks.batch_129(); }
|
||||
if test_batch==130 { InventoryChecks.batch_130(); }
|
||||
if test_batch==131 { InventoryChecks.batch_131(); }
|
||||
if test_batch==132 { InventoryChecks.batch_132(); }
|
||||
if test_batch==133 { InventoryChecks.batch_133(); }
|
||||
if test_batch==134 { InventoryChecks.batch_134(); }
|
||||
if test_batch==135 { InventoryChecks.batch_135(); }
|
||||
if test_batch==136 { InventoryChecks.batch_136(); }
|
||||
if test_batch==137 { InventoryChecks.batch_137(); }
|
||||
if test_batch==138 { InventoryChecks.batch_138(); }
|
||||
if test_batch==139 { InventoryChecks.batch_139(); }
|
||||
if test_batch==140 { let assertion_14=LinkInventoryChecks.run(); InventoryChecks.check(assertion_14); }
|
||||
if test_batch==141 { let assertion_15=GameInventoryChecks.run(); InventoryChecks.check(assertion_15); }
|
||||
if test_batch==142 { let extra_result=InventoryChecks.extra(); test_extra=extra_result; InventoryChecks.check(extra_result==0); }
|
||||
if test_batch<143 { test_batch+=1; }
|
||||
Gfx.clear(Color.rgb(0,0,0)); Gfx.fill_rect(470,260,3,3,Color.rgb(test_extra as long,0,0));
|
||||
for i: int from 0 until test_count { let v=test_results[i] else 0; Gfx.fill_rect(i%160*3,i/160*3,2,2,if v==1 { Color.rgb(0,255,0) } else { Color.rgb(255,0,0) }); }
|
||||
Gfx.fill_rect(477,267,3,3,if test_batch<143 { Color.rgb(0,0,255) } else if test_failed==0 { Color.rgb(0,255,0) } else { Color.rgb(255,0,0) });
|
||||
}
|
||||
fn visual() -> void {
|
||||
Inventory.reset(); for i: int from 0 until 40 { inventory_slots[i]=1; } inventory_slots[24]=34; inventory_slots[25]=255; inventory_slots[26]=255; inventory_slots[37]=8;
|
||||
Stage.reset(); Link.start_game(); InventoryScreen.reset(); InventoryScreen.open(); for i: int from 0 until 65 { let c=InventoryScreen.advance(false,0); }
|
||||
}
|
||||
fn draw() -> void { InventoryScreen.draw(); }
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { Inventory } from @zelda1:inventory;
|
||||
declare service LinkInventoryChecks {
|
||||
fn run() -> bool {
|
||||
Inventory.reset(); Stage.reset(); Link.start_game();
|
||||
let taken=Inventory.take_drop(0); Inventory.ensure_selection(); Link.use_b(true);
|
||||
if Inventory.read_slot(1)!=3 || bomb0.phase!=1 || bomb0.y!=125 { return false; }
|
||||
bomb0.advance(); if bomb0.phase!=2 || bomb0.timer!=48 { return false; }
|
||||
for i: int from 0 until 47 { bomb0.advance(); }
|
||||
if bomb0.phase!=2 || bomb0.timer!=1 { return false; }
|
||||
bomb0.advance(); if bomb0.phase!=3 || bomb0.timer!=24 { return false; }
|
||||
if !bomb0.hits(143,148) || bomb0.hits(144,125) || bomb0.hits(120,149) { return false; }
|
||||
for i: int from 0 until 24 { bomb0.advance(); }
|
||||
if bomb0.phase!=4 || bomb0.timer!=12 || bomb0.hits(120,125) { return false; }
|
||||
for i: int from 0 until 12 { bomb0.advance(); }
|
||||
if bomb0.phase!=0 { return false; }
|
||||
// Two active weapons, but never a second ticking fuse.
|
||||
Link.start_game(); Link.use_b(true); state.action=0; Link.use_b(true);
|
||||
if Inventory.read_slot(1)!=2 || bomb1.phase!=0 { return false; }
|
||||
bomb0.phase=3; Link.use_b(true);
|
||||
if Inventory.read_slot(1)!=1 || bomb1.phase!=1 { return false; }
|
||||
state.action=0; Link.use_b(true); if Inventory.read_slot(1)!=1 { return false; }
|
||||
Link.start_game(); return bomb0.phase==0 && bomb1.phase==0;
|
||||
}
|
||||
fn paused_signature() -> int { return bomb0.phase*10000+bomb0.timer*100+bomb1.phase; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { InventoryChecks } from @zelda1:inventory;
|
||||
import { Pad, Button } from @sdk:input;
|
||||
declare global visual: bool=false;
|
||||
[Init] fn init() -> void {}
|
||||
[Frame] fn frame() -> void {
|
||||
if Pad.pressed(Button.Select) { visual=!visual; if visual { InventoryChecks.visual(); } }
|
||||
if visual { InventoryChecks.draw(); } else { InventoryChecks.frame(); }
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
# Save guest qualification
|
||||
|
||||
Generate with `python3 tools/generate_save_fixture.py --action N`. It never
|
||||
installs itself. Use disposable images under `.tmp`, never the user's card.
|
||||
|
||||
Append inventory/store/menu/game helpers to their respective module main.pbs,
|
||||
export the helper services temporarily, and use the generated root entry.
|
||||
Keep Init and MemcardBoot. Back up and restore all modified production files.
|
||||
|
||||
Actions: 0 saves a seeded profile when empty, or verifies reload when present;
|
||||
1 also attempts Save after loading an existing profile (read-only test);
|
||||
2 writes bad magic; 3 writes an unsupported schema; 4 commits only 12 bytes.
|
||||
Actions 2..4 intentionally publish invalid game data in a valid disposable
|
||||
container. A later boot must reject it, keep live game defaults, and preserve
|
||||
its payload. Host metadata may change on admission; compare slot bytes rather
|
||||
than equating a whole-container hash with payload preservation.
|
||||
|
||||
Markers after game rendering: pixel (0,0) is green on pass; pixel (3,0) encodes
|
||||
phase and role; (6,0) is the SaveStore outcome. The 180 raw slot bytes can be
|
||||
read from red values at (400,20+i); (401,0) contains the used length. Those
|
||||
markers/columns are fixture-only and never belong in production.
|
||||
|
||||
A durable test must end the runtime process and reopen the same image. Check
|
||||
00/7f/80/ff, native inventory/world flags, life normalization, clock clearing,
|
||||
and a project-version change with stable app_id. Memory-only commits must
|
||||
show NOT SAVED TO CARD. Explicitly discard only disposable memory-test RAM
|
||||
when shutdown refuses dirty data. `tools/validate_save.py` verifies captures
|
||||
against independent Python bytes, Adler-32 and native CHR pixel composition.
|
||||
@@ -0,0 +1,75 @@
|
||||
import { WorldFlags } from @zelda1:world;
|
||||
import { SaveMenuChecks } from @zelda1:screens/continue_menu;
|
||||
import { Inventory } from @zelda1:inventory;
|
||||
import { Link } from @zelda1:link;
|
||||
import { SaveStore, SaveStoreChecks } from @zelda1:save;
|
||||
import { SaveInventoryChecks } from @zelda1:inventory;
|
||||
import { Gfx } from @sdk:gfx;
|
||||
import { Color } from @core:color;
|
||||
declare const SAVE_TEST_ACTION: int=0;
|
||||
declare global save_test_phase: int=0;
|
||||
declare global save_test_failed: int=0;
|
||||
declare global save_test_role: int=0;
|
||||
declare global save_test_wait: int=0;
|
||||
declare service SaveGameChecks {
|
||||
fn frame() -> void {
|
||||
if save_test_phase==0 {
|
||||
let menu=SaveMenuChecks.verify(); if !menu { save_test_failed=7; }
|
||||
let available=SaveStore.available(); save_test_role=if available { 1 } else { 0 };
|
||||
game.update(false,false,false,false,false,false,true,false); save_test_phase=1;
|
||||
let issue=SaveStore.load_issue();
|
||||
if !available && issue!=0 {
|
||||
save_test_role=2; save_test_phase=9; let loaded=SaveStore.load();
|
||||
let sword=Inventory.sword_level(); let taken=WorldFlags.room_item_taken(119);
|
||||
if loaded || sword!=0 || taken { save_test_failed=9; }
|
||||
}
|
||||
} else if save_test_phase==1 {
|
||||
game.update(false,false,false,false,false,false,true,false);
|
||||
for i: int from 0 until 76 { game.update(false,false,false,false,false,false,false,false); }
|
||||
if save_test_role==1 {
|
||||
let inventory=SaveInventoryChecks.verify(); let world=SaveStoreChecks.verify_world();
|
||||
if !inventory || !world || game.mode!=5 { save_test_failed=1; }
|
||||
save_test_phase=if SAVE_TEST_ACTION==1 { 2 } else { 8 };
|
||||
} else {
|
||||
SaveInventoryChecks.seed(); SaveStoreChecks.seed_world();
|
||||
let codec=SaveStoreChecks.codec_checks(); if codec!=0 { save_test_failed=10+codec; }
|
||||
save_test_phase=2;
|
||||
}
|
||||
} else if save_test_phase==2 {
|
||||
game.update(false,false,false,false,false,false,false,true);
|
||||
if game.mode!=12 { save_test_failed=2; }
|
||||
let old_x=Link.x(); let old_y=Link.y(); let old_life=Inventory.read_slot(24); let old_partial=Inventory.read_slot(25);
|
||||
game.update(false,false,false,false,false,false,true,false);
|
||||
for i: int from 0 until 64 { game.update(false,false,false,false,false,false,false,false); }
|
||||
let x=Link.x(); let y=Link.y(); let life=Inventory.read_slot(24); let partial=Inventory.read_slot(25);
|
||||
if game.mode!=5 || x!=old_x || y!=old_y || life!=old_life || partial!=old_partial { save_test_failed=8; }
|
||||
game.update(false,false,false,false,false,false,false,true); save_test_phase=3;
|
||||
} else if save_test_phase==3 {
|
||||
if SAVE_TEST_ACTION>=2 {
|
||||
let injected=SaveStoreChecks.publish_bad(SAVE_TEST_ACTION); if !injected { save_test_failed=9; }
|
||||
game.mode=13; save_test_phase=4;
|
||||
} else {
|
||||
game.update(false,false,false,false,false,false,false,true);
|
||||
game.update(false,false,false,false,false,false,true,false);
|
||||
for i: int from 0 until 64 { game.update(false,false,false,false,false,false,false,false); }
|
||||
if game.mode!=13 { save_test_failed=3; } save_test_phase=4;
|
||||
}
|
||||
} else if save_test_phase==4 {
|
||||
game.update(false,false,false,false,false,false,false,false);
|
||||
let state=SaveStore.last_state(); let pending=SaveStore.busy(); save_test_wait+=1;
|
||||
if state!=1 && !pending {
|
||||
if state!=2 && state!=3 && state!=4 && state!=6 { save_test_failed=4; }
|
||||
if state==2 { let durable=SaveStoreChecks.durable_valid(if SAVE_TEST_ACTION==4 { 12 } else { 180 }); if !durable { save_test_failed=6; } }
|
||||
save_test_phase=5;
|
||||
}
|
||||
if save_test_wait>500 { save_test_failed=5; }
|
||||
} else if save_test_phase==5 {
|
||||
// Retain the result screen for capture; test driver ends this process.
|
||||
SaveStore.poll();
|
||||
}
|
||||
game.draw(); SaveStoreChecks.draw_raw();
|
||||
Gfx.fill_rect(0,0,3,3,if save_test_failed==0 { Color.rgb(0,255,0) } else { Color.rgb(save_test_failed as long,0,0) });
|
||||
Gfx.fill_rect(3,0,3,3,Color.rgb(save_test_phase as long,save_test_role as long,0));
|
||||
let state=SaveStore.last_state(); Gfx.fill_rect(6,0,3,3,Color.rgb(state as long,0,0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
declare service SaveInventoryChecks {
|
||||
fn seed() -> void {
|
||||
Inventory.reset(); let sword=Inventory.take_sword(1); let bombs=Inventory.take_drop(0);
|
||||
let heart=Inventory.take_life_item(26); let damage=Inventory.damage_life(128);
|
||||
inventory_slots[20]=1; inventory_slots[21]=1; inventory_slots[22]=5;
|
||||
inventory_slots[33]=127; inventory_slots[34]=128; inventory_slots[35]=255; inventory_slots[36]=0;
|
||||
}
|
||||
fn verify() -> bool {
|
||||
let sword=Inventory.sword_level(); let bombs=Inventory.read_slot(1); let life=Inventory.read_slot(24); let fraction=Inventory.read_slot(25);
|
||||
if sword!=1 || bombs!=4 || life!=50 || fraction!=255 { return false; }
|
||||
let clock=Inventory.read_slot(21); let fairy=Inventory.read_slot(20); let rupees=Inventory.read_slot(22); if clock!=0 || fairy!=1 || rupees!=5 { return false; }
|
||||
let b0=Inventory.read_slot(36); let b1=Inventory.read_slot(33); let b2=Inventory.read_slot(34); let b3=Inventory.read_slot(35);
|
||||
return b0==0 && b1==127 && b2==128 && b3==255;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
declare service SaveMenuChecks {
|
||||
fn verify() -> bool {
|
||||
let test=new ContinueState(new ContinueData(),0,0,false);
|
||||
let choice=test.advance(true,false); if test.selection!=1 { return false; }
|
||||
choice=test.advance(true,false); if test.selection!=2 { return false; }
|
||||
choice=test.advance(true,false); if test.selection!=0 { return false; }
|
||||
choice=test.advance(true,true); if test.selection!=0 || !test.confirming { return false; }
|
||||
for i: int from 0 until 63 { let pending_choice=test.advance(true,true); if pending_choice!= -1 { return false; } }
|
||||
let final_choice=test.advance(false,false); return final_choice==0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import { Gfx } from @sdk:gfx;
|
||||
import { Color } from @core:color;
|
||||
import { Inventory } from @zelda1:inventory;
|
||||
import { WorldFlags } from @zelda1:world;
|
||||
declare service SaveStoreChecks {
|
||||
fn codec_checks() -> int {
|
||||
let bytes=new MemcardBuffer(180); save_codec.snapshot(bytes);
|
||||
let good=save_codec.validate(bytes); if good!=0 { return 1; }
|
||||
if bytes.read(8)!=142 || bytes.read(9)!=6 || bytes.read(10)!=246 || bytes.read(11)!=217 { return 8; }
|
||||
bytes.write(0,0); let bad_magic=save_codec.validate(bytes); if bad_magic!=1 { return 2; }
|
||||
bytes.write(0,90); bytes.write(4,2); let unknown=save_codec.validate(bytes); if unknown!=2 { return 3; }
|
||||
bytes.write(4,1); let old=bytes.read(13); bytes.write(13,old+1); let corrupt=save_codec.validate(bytes); if corrupt!=1 { return 4; }
|
||||
bytes.write(13,old); bytes.write(49,0); save_codec.checksum(bytes); let bad_bombs=save_codec.validate(bytes); if bad_bombs!=1 { return 5; }
|
||||
save_codec.snapshot(bytes); bytes.write(36,255); save_codec.checksum(bytes); let full=save_codec.validate(bytes); if full!=0 { return 6; }
|
||||
bytes.write(36,15); save_codec.checksum(bytes); let bad_life=save_codec.validate(bytes); if bad_life!=1 { return 7; }
|
||||
return 0;
|
||||
}
|
||||
fn seed_world() -> void {
|
||||
WorldFlags.reset(); let values=new array<int>(128);
|
||||
values[119]=16; values[100]=128; values[103]=146;
|
||||
values[20]=0; values[21]=127; values[22]=128; values[23]=255;
|
||||
WorldFlags.restore_slots(values);
|
||||
}
|
||||
fn verify_world() -> bool {
|
||||
let sword=WorldFlags.room_item_taken(119); let secret=WorldFlags.secret_found(100); let partial=WorldFlags.kill_count(103);
|
||||
if !sword || !secret || partial!=2 { return false; }
|
||||
let b0=WorldFlags.read_slot(20); let b1=WorldFlags.read_slot(21); let b2=WorldFlags.read_slot(22); let b3=WorldFlags.read_slot(23);
|
||||
if b0!=0 || b1!=127 || b2!=128 || b3!=255 { return false; }
|
||||
// History is absent after reload: native $07 resets on the next visit.
|
||||
let count=WorldFlags.enter_room(23,4); let flags=WorldFlags.read_slot(23);
|
||||
return count==4 && flags==248;
|
||||
}
|
||||
fn durable_valid(expected_size: int) -> bool {
|
||||
let stat=Mem.slot_stat(save_context,0); if stat.status!=0 as long { return false; }
|
||||
return stat.has_payload==1 as long && stat.used_bytes==expected_size as long && !stat.dirty;
|
||||
}
|
||||
fn publish_bad(kind: int) -> bool {
|
||||
let bytes=new MemcardBuffer(180); save_codec.snapshot(bytes);
|
||||
if kind==2 { bytes.write(0,0); } else if kind==3 { bytes.write(4,2); }
|
||||
let count=if kind==4 { 12 } else { 180 };
|
||||
for i: int from 0 until 180 { save_staging[i]=bytes.read(i); }
|
||||
let write=Mem.slot_write(save_context,0,0,bytes,0,count); if write.status!=0 as long { return false; }
|
||||
let commit=Mem.slot_commit(save_context,0); if commit.status!=0 as long { return false; }
|
||||
save_request=commit.request; save_result=1; return true;
|
||||
}
|
||||
fn draw_raw() -> void {
|
||||
let stat=Mem.slot_stat(save_context,0); if stat.status!=0 as long { return; }
|
||||
let count=stat.used_bytes as int; if count<=0 || count>180 { return; }
|
||||
let bytes=new MemcardBuffer(180); let read=Mem.slot_read(save_context,0,0,bytes,0,count); if read.status!=0 as long { return; }
|
||||
Gfx.fill_rect(401,0,1,1,Color.rgb(count as long,0,0));
|
||||
for i: int from 0 until count { let value=bytes.read(i); Gfx.fill_rect(400,i+20,1,1,Color.rgb(value as long,0,0)); }
|
||||
}
|
||||
fn cache_signature() -> int {
|
||||
let sum=0; for i: int from 0 until 180 { let value=save_cache[i] else 0; sum=(sum*31+value)%65521; } return sum;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { Inventory } from @zelda1:inventory;
|
||||
import { Stage } from @zelda1:stage;
|
||||
import { Gfx } from @sdk:gfx;
|
||||
import { Color } from @core:color;
|
||||
declare global check_phase: int=0;
|
||||
declare global check_error: int=0;
|
||||
declare service TemporaryBombChecks {
|
||||
fn tick() -> void {
|
||||
if check_phase==0 {
|
||||
game.boot(); game.new_game(); for i: int from 0 until 76 { game.update(false,false,false,false,false,false,false,false); }
|
||||
let count=Inventory.read_slot(1); if count!=0 { check_error=1; }
|
||||
} else if check_phase==1 {
|
||||
for i: int from 0 until 22 { game.update(true,false,false,false,false,false,false,false); }
|
||||
let count=Inventory.read_slot(1); if count!=4 { check_error=2; }
|
||||
} else if check_phase==2 {
|
||||
game.update(false,false,false,false,false,true,false,false);
|
||||
let count=Inventory.read_slot(1); if count!=3 { check_error=3; }
|
||||
} else if check_phase==3 {
|
||||
game.update(false,false,false,false,false,false,true,false);
|
||||
for i: int from 0 until 66 { game.update(false,false,false,false,false,false,false,false); }
|
||||
let count=Inventory.read_slot(1); if count!=3 { check_error=4; }
|
||||
} else if check_phase==4 {
|
||||
game.update(false,false,false,false,false,false,true,false);
|
||||
for i: int from 0 until 59 { game.update(false,false,false,false,false,false,false,false); }
|
||||
Stage.return_to_start(); Stage.update_test_pickups(152,138,true);
|
||||
let count=Inventory.read_slot(1); if count!=3 { check_error=5; }
|
||||
} else if check_phase==5 {
|
||||
game.new_game(); for i: int from 0 until 76 { game.update(false,false,false,false,false,false,false,false); }
|
||||
for i: int from 0 until 22 { game.update(true,false,false,false,false,false,false,false); }
|
||||
let count=Inventory.read_slot(1); if count!=4 { check_error=6; }
|
||||
}
|
||||
if check_phase<6 { check_phase+=1; }
|
||||
game.draw(); Gfx.fill_rect(0,0,3,3,if check_error==0 { Color.rgb(0,255,0) } else { Color.rgb(check_error as long,0,0) });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user