Skip to content

Commit

Permalink
Merge pull request #23 from Timendus/test-FX65
Browse files Browse the repository at this point in the history
Test memory quirk for reading too (Fx65)
  • Loading branch information
Timendus authored Aug 22, 2024
2 parents 88c29ea + c2e3748 commit 8d67cd6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 15 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ cross).
- `Memory` - The save and load opcodes (`Fx55` and `Fx65`) increment the index
register. More information [here](https://laurencescotford.net/chip-8-on-the-cosmac-vip-loading-and-saving-variables/)
and [here](https://tobiasvl.github.io/blog/write-a-chip-8-emulator/#fx55-and-fx65-store-and-load-memory).
Test will show `ERR1` if reading and writing don't behave the same.
- `Display wait` - Drawing sprites to the display waits for the vertical blank
interrupt, limiting their speed to max 60 sprites per second. More information
[here](https://laurencescotford.net/chip-8-on-the-cosmac-vip-drawing-sprites/).
Expand Down
55 changes: 41 additions & 14 deletions src/tests/5-quirks.8o
Original file line number Diff line number Diff line change
Expand Up @@ -378,31 +378,58 @@
# memQuirk
# When reading or writing memory, i gets incremented
text 1 6 quirks-mem
v0 := 5
i := scratchpad-plus-16
save v0
v0 := 1
v1 := 2
v2 := 3
v3 := 4
v4 := 5
i := scratchpad-plus-3
save v4
v0 := 11
v1 := 12
v2 := 13
i := scratchpad-plus-3
save v2
load v0
v5 := v0
load v0
v6 := v0

i := scratchpad
load v0
i := flag-err
if v0 == CHIP8 begin
if v5 != 5 then i := flag-ok
end
if v0 == SCHIP_MODERN begin
if v5 == 5 then i := flag-ok
end
if v0 == SCHIP_LEGACY begin
if v5 == 5 then i := flag-ok
v1 := 0
if v0 == CHIP8 then jump expect-memquirk
if v0 == SCHIP_MODERN then jump expect-no-memquirk
if v0 == SCHIP_LEGACY then jump expect-no-memquirk
if v0 == XOCHIP then jump expect-memquirk

: expect-memquirk
if v5 == 4 begin
if v6 == 5 begin
i := flag-ok
else
v1 := 1
end
end
if v0 == XOCHIP begin
if v5 != 5 then i := flag-ok
jump memquirk-done

: expect-no-memquirk
if v5 == 11 begin
if v6 == 11 begin
i := flag-ok
else
v1 := 1
end
end

: memquirk-done
x := 59
y := 7
sprite x y 3
i := quirks-on
if v5 == 5 then i := quirks-off
if v5 == 11 then i := quirks-off
if v1 == 1 then i := quirks-inconsistent-1
vD := 42
vE := 6
drawText
Expand Down
4 changes: 3 additions & 1 deletion src/utils/helpers.8o
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
: scratchpad-plus-1
0
: scratchpad-plus-2
0
: scratchpad-plus-3
0 0 0 0 0
0 0 0 0 0
0 0 0 0
0 0 0 0
: scratchpad-plus-16
0

0 comments on commit 8d67cd6

Please sign in to comment.