; Copyright (C) 2014-2022 Joonas Javanainen ; ; Permission is hereby granted, free of charge, to any person obtaining a copy ; of this software and associated documentation files (the "Software"), to deal ; in the Software without restriction, including without limitation the rights ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ; copies of the Software, and to permit persons to whom the Software is ; furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ; SOFTWARE. ; Tests how long does it take to get from STAT=mode2 interrupt to mode0 ; Includes sprites in various configurations ; Verified results: ; pass: DMG, MGB, SGB, SGB2, CGB, AGB, AGS ; fail: - .include "common.s" .macro clear_interrupts xor a ldh ( sprite count affects cycles ; 10 sprites at X=N testcase 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 testcase 15, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 testcase 15, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 testcase 15, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 testcase 15, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 testcase 15, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 testcase 15, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 testcase 16, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 testcase 16, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 testcase 15, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 testcase 15, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 testcase 15, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 testcase 15, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13 testcase 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 testcase 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 testcase 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 testcase 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17 testcase 16, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 testcase 16, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 testcase 16, 160,160,160,160,160,160,160,160,160,160 testcase 16, 161,161,161,161,161,161,161,161,161,161 testcase 15, 162,162,162,162,162,162,162,162,162,162 testcase 15, 167,167,167,167,167,167,167,167,167,167 testcase 15, 167,167,167,167,167,167,167,167,167,167 testcase 0, 168,168,168,168,168,168,168,168,168,168 testcase 0, 169,169,169,169,169,169,169,169,169,169 ; ==> sprite location affects cycles ; 10 sprites split to two groups, X=N and X=M testcase 17, 0, 0, 0, 0, 0, 160,160,160,160,160 testcase 17, 1, 1, 1, 1, 1, 161,161,161,161,161 testcase 16, 2, 2, 2, 2, 2, 162,162,162,162,162 testcase 16, 3, 3, 3, 3, 3, 163,163,163,163,163 testcase 15, 4, 4, 4, 4, 4, 164,164,164,164,164 testcase 15, 5, 5, 5, 5, 5, 165,165,165,165,165 testcase 15, 6, 6, 6, 6, 6, 166,166,166,166,166 testcase 15, 7, 7, 7, 7, 7, 167,167,167,167,167 testcase 17, 64, 64, 64, 64, 64, 160,160,160,160,160 testcase 17, 65, 65, 65, 65, 65, 161,161,161,161,161 testcase 16, 66, 66, 66, 66, 66, 162,162,162,162,162 testcase 16, 67, 67, 67, 67, 67, 163,163,163,163,163 testcase 15, 68, 68, 68, 68, 68, 164,164,164,164,164 testcase 15, 69, 69, 69, 69, 69, 165,165,165,165,165 testcase 15, 70, 70, 70, 70, 70, 166,166,166,166,166 testcase 15, 71, 71, 71, 71, 71, 167,167,167,167,167 ; ==> non-overlapping locations affect cycles ; 1 sprite at X=N testcase 2, 0 testcase 2, 1 testcase 2, 2 testcase 2, 3 testcase 1, 4 testcase 1, 5 testcase 1, 6 testcase 1, 7 testcase 2, 8 testcase 2, 9 testcase 2, 10 testcase 2, 11 testcase 1, 12 testcase 1, 13 testcase 1, 14 testcase 1, 15 testcase 2, 16 testcase 2, 17 testcase 2, 160 testcase 2, 161 testcase 2, 162 testcase 2, 163 testcase 1, 164 testcase 1, 165 testcase 1, 166 testcase 1, 167 ; 2 sprites 8 bytes apart starting from X0=N testcase 5, 0, 8 testcase 5, 1, 9 testcase 4, 2, 10 testcase 4, 3, 11 testcase 3, 4, 12 testcase 3, 5, 13 testcase 3, 6, 14 testcase 3, 7, 15 testcase 5, 8, 16 testcase 5, 9, 17 testcase 4, 10, 18 testcase 4, 11, 19 testcase 3, 12, 20 testcase 3, 13, 21 testcase 3, 14, 22 testcase 3, 15, 23 testcase 5, 16, 24 ; 10 sprites 8 bytes apart starting from X0=N testcase 27, 0, 8, 16, 24, 32, 40, 48, 56, 64, 72 testcase 25, 1, 9, 17, 25, 33, 41, 49, 57, 65, 73 testcase 22, 2, 10, 18, 26, 34, 42, 50, 58, 66, 74 testcase 20, 3, 11, 19, 27, 35, 43, 51, 59, 67, 75 testcase 17, 4, 12, 20, 28, 36, 44, 52, 60, 68, 76 testcase 15, 5, 13, 21, 29, 37, 45, 53, 61, 69, 77 testcase 15, 6, 14, 22, 30, 38, 46, 54, 62, 70, 78 testcase 15, 7, 15, 23, 31, 39, 47, 55, 63, 71, 79 ; 10 sprites 8 bytes apart starting from X0=N, reverse testcase 27, 72, 64, 56, 48, 40, 32, 24, 16, 8, 0 testcase 25, 73, 65, 57, 49, 41, 33, 25, 17, 9, 1 ; ==> sprite order does not affect cycles quit_ok run_testcase: push de push hl call disable_ppu_safe call clear_oam pop de call prepare_sprites pop de ld c, d ld hl, nop_area_a call prepare_nop_area ld c, e ld hl, nop_area_b call prepare_nop_area enable_ppu ; Enable sprites ld hl, LCDC set 1, (HL) testcase_round_a: ld hl, testcase_round_a_ret push hl ld hl, nop_area_a push hl jp setup_and_wait_mode2 testcase_round_a_ret: ld b, $00 - inc b ldh a, (