Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added climb_test.txt
Empty file.
30 changes: 30 additions & 0 deletions ct.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
local outPath = "C:/src/dotnes"
local f = io.open(outPath .. "/climb_test.txt", "w")

emu.addEventCallback(function()
local fc = emu.getState()["ppu.frameCount"]

-- Climb up aggressively: alternate UP and A to find ladders and jump
if fc > 120 then
if fc % 30 < 15 then
emu.setInput(0, {up = true})
else
emu.setInput(0, {a = true, right = true})
end
end

-- Log state every 300 frames
if fc % 300 == 0 and fc > 0 then
local sp_lo = emu.read(0x22, emu.memType.nesInternalRam)
local sp_hi = emu.read(0x23, emu.memType.nesInternalRam)
local floor = emu.read(0x03C9, emu.memType.nesInternalRam)
local state = emu.read(0x03D1, emu.memType.nesInternalRam)
local pc = emu.getState()["cpu.pc"]
f:write(string.format("Frame %5d: floor=%d state=%d sp=$%02X%02X pc=$%04X\n", fc, floor, state, sp_hi, sp_lo, pc))
end

if fc >= 18000 then
f:close()
emu.stop(0)
end
end, emu.eventType.endFrame)
Empty file added ct_err.txt
Empty file.
13 changes: 13 additions & 0 deletions ct_out.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
------------------------------------------------------
Loading rom: climber.nes
File CRC32: 0xEDEF0A85
------------------------------------------------------
[DB] Initialized - 10655 games in DB
PRG CRC32: 0xD4C12182
PRG+CHR CRC32: 0x13322F19
[iNes] Mapper: 0 Sub: 0
[iNes] PRG ROM: 32 KB
[iNes] CHR ROM: 8 KB
[iNes] Mirroring: Horizontal
[iNes] Battery: No
[DB] Game not found in database
27 changes: 23 additions & 4 deletions samples/climber/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,29 @@ static void setup_graphics()
byte rel_lo = (byte)(actor_yy_lo[ai] - scroll_yy_lo);
byte rel_hi = (byte)(actor_yy_hi[ai] - scroll_yy_hi);
if (actor_yy_lo[ai] < scroll_yy_lo) rel_hi = (byte)(rel_hi - 1);
if (rel_hi != 0) { actor_onscreen[ai] = 0; continue; }
byte screen_y = (byte)(SCREEN_Y_BOTTOM - rel_lo);
if (screen_y > 224) { actor_onscreen[ai] = 0; continue; }
// For player (ai==0): always compute screen_y and render — never cull.
// The original uses signed 16-bit screen_y which never overflows.
// For enemies: skip if off-screen.
byte screen_y;
if (ai == 0)
{
if (rel_hi == 0)
{
screen_y = (byte)(SCREEN_Y_BOTTOM - rel_lo);
}
else
{
// Player off-screen: clamp sprite to bottom edge
screen_y = 224;
}
player_screen_y = screen_y;
Comment thread
jonathanpeppers marked this conversation as resolved.
}
else
{
if (rel_hi != 0) { actor_onscreen[ai] = 0; continue; }
screen_y = (byte)(SCREEN_Y_BOTTOM - rel_lo);
if (screen_y > 224) { actor_onscreen[ai] = 0; continue; }
}

byte dir = actor_dir[ai];
byte st = actor_state[ai];
Expand Down Expand Up @@ -449,7 +469,6 @@ static void setup_graphics()
if (st == PACING)
oam_meta_spr_pal(actor_x[ai], screen_y, actor_pal[ai], personToSave);
actor_onscreen[ai] = 1;
if (ai == 0) player_screen_y = screen_y;
}
// Scoreboard
oam_off = oam_spr(24, 24, (byte)(0x30 + (score >> 4)), 2, oam_off);
Expand Down
Binary file modified src/dotnes.tests/Data/climber.debug.dll
Binary file not shown.
Binary file modified src/dotnes.tests/Data/climber.release.dll
Binary file not shown.
Binary file modified src/dotnes.tests/TranspilerTests.Write.climber.verified.bin
Binary file not shown.