Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
aaaaaa123456789 committed Dec 2, 2020
2 parents e394c78 + 8f4c7ad commit 28fccd1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/basic.asm
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ TickTest:
check_timer .tick_loop, nz
ld hl, hTestResult
call PrintTime
cpw de, 9950
cpw de, 9990
ret c
cpw de, 10051
cpw de, 10011
ccf
ret

Expand Down
11 changes: 9 additions & 2 deletions src/header.asm
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,16 @@ CarryIfNonZero:

assert @ == $38 ;we're not going to call this, so the assert is necessary
CrashFF:
rst Crash
jr Crash

ds 7
ExitTimedWait:
; the three nops are here for timing reasons (see wait.asm)
nop
nop
nop
pop hl
pop bc
ret

assert @ == $40
VBlank:
Expand Down
12 changes: 6 additions & 6 deletions src/subsec.asm
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ LongSecondWrite:
.done
ld hl, hTestResult
call PrintTime
cpw de, 9920
cpw de, 9985
ret c
cpw de, 10081
cpw de, 10016
ccf
ret

Expand Down Expand Up @@ -135,9 +135,9 @@ ___test_sub_second_register_write: MACRO
check_timer .check, nz
ld hl, hTestResult
call PrintTime
cpw de, (\2) * 500 - 80
cpw de, (\2) * 500 - 15
ret c
cpw de, (\2) * 500 + 81
cpw de, (\2) * 500 + 16
ccf
ret
ENDM
Expand Down Expand Up @@ -194,8 +194,8 @@ RTCOffTimingTest:
check_timer .check, nz
ld hl, hTestResult
call PrintTime
cpw de, 3920
cpw de, 3985
ret c
cpw de, 4081
cpw de, 4016
ccf
ret
22 changes: 7 additions & 15 deletions src/wait.asm
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ WaitATimes50ms:
add hl, hl ;dummy instruction to make up for the two lost cycles for jumps not taken
.no_extra
; remaining: 166 - b cycles (b <= 51)
ld a, 138
ld a, 140
sub b
; remaining: 163 - b = a + 25 cycles
; remaining: 163 - b = a + 23 cycles
ld b, a
srl b
srl b
Expand All @@ -66,19 +66,11 @@ WaitATimes50ms:
; loop total: 4 cycles (times a & ~3 iterations)
cpl
and 3
; remaining: (a ^ 3) + 18 cycles
add a, LOW(.exit)
; remaining: (a ^ 3) + 16 cycles
assert ExitTimedWait < $100 ;this means the addition cannot overflow (because the header is at $100)
add a, ExitTimedWait
ld l, a
adc HIGH(.exit)
sub l
ld h, a
ld h, 0
jp hl
; remaining: (old a ^ 3) + 10 cycles - exactly enough for 0-3 nops, two pops and a ret

.exit
nop
nop
nop
pop hl
pop bc
ret
; note: ExitTimedWait is before the ROM header (see header.asm)
4 changes: 2 additions & 2 deletions tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Some behaviors are very common in tests, and thus they are given short attribute
## Basic tests

* **RTC on** (pass/fail): enables the RTC (by setting bit 6 of the control register) and waits for it to tick.
* **Tick** (conditional): evaluates the time taken between successive ticks. (expected: 1000ms, tolerance: 5ms)
* **Tick** (conditional): evaluates the time taken between successive ticks. (expected: 1000ms, tolerance: 1ms)
* **RTC off** (pass/fail): disables the RTC and waits approximately four seconds for it to tick. The test fails if the
RTC ticks.
* **Register writes** (register list): generates a random new RTC state (ensuring that all values are different from
Expand Down Expand Up @@ -86,7 +86,7 @@ These tests are named after the register that is written to and the time remaini
tick at the time of writing. For instance, the RTCS/900 test will write to the seconds register when the next tick is
900ms away (i.e., 100ms after a tick).

The tolerance is 8ms for all tests. The tests are:
The tolerance is 1.5ms for all tests. The tests are:

* **RTCS/500** (expected: 1000ms)
* **RTCS/900** (expected: 1000ms)
Expand Down

0 comments on commit 28fccd1

Please sign in to comment.