; 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. ; This test checks that OAM DMA source memory areas work as expected, ; including the area past $DFFF. ; Verified results: ; pass: DMG, MGB, SGB, SGB2 ; fail: CGB, AGB, AGS .define CART_TYPE $1B ; MBC5, ram, battery .define CART_RAM_SIZE 2 .include "common.s" ld sp, $ffff call disable_ppu_safe call clear_oam call clear_vram call clear_wram prepare_part1: ld hl, hram.dma_proc ld de, dma_proc ld bc, _sizeof_dma_proc call memcpy test_0000: ld a, $00 call hram.dma_proc ld hl, $0000 call check_oam jp nc, test_3f00 quit_failure_string "Fail: $0000" test_3f00: ld a, $3f call hram.dma_proc ld hl, $3f00 call check_oam jp nc, test_4000 quit_failure_string "Fail: $3F00" test_4000: ld a, $40 call hram.dma_proc ld hl, $4000 call check_oam jp nc, test_7f00 quit_failure_string "Fail: $4000" test_7f00: ld a, $7f call hram.dma_proc ld hl, $7f00 call check_oam jp nc, prepare_part2 quit_failure_string "Fail: $7F00" prepare_part2: ld hl, $8000 call copy_ram_pattern_1 ld hl, $9f00 call copy_ram_pattern_2 test_8000: ld a, $80 call hram.dma_proc ld hl, ram_pattern_1 call check_oam jp nc, test_9f00 quit_failure_string "Fail: $8000" test_9f00: ld a, $9f call hram.dma_proc ld hl, ram_pattern_2 call check_oam jp nc, prepare_part3 quit_failure_string "Fail: $9F00" prepare_part3: call clear_vram ld a, $0a ld ($0000), a ld hl, $a000 ld bc, $2000 xor a call memset ld hl, $a000 call copy_ram_pattern_1 ld hl, $bf00 call copy_ram_pattern_2 test_a000: ld a, $a0 call hram.dma_proc ld hl, ram_pattern_1 call check_oam jp nc, test_bf00 quit_failure_string "Fail: $A000" test_bf00: ld a, $bf call hram.dma_proc ld hl, ram_pattern_2 call check_oam jp nc, prepare_part4 quit_failure_string "Fail: $BF00" prepare_part4: xor a ld ($0000), a ld hl, $c000 call copy_ram_pattern_1 ld hl, $de00 call copy_ram_pattern_1 ld hl, $df00 call copy_ram_pattern_2 test_c000: ld a, $c0 call hram.dma_proc ld hl, ram_pattern_1 call check_oam jp nc, test_df00 quit_failure_string "Fail: $C000" test_df00: ld a, $df call hram.dma_proc ld hl, ram_pattern_2 call check_oam jp nc, test_e000 quit_failure_string "Fail: $DF00" test_e000: ld a, $e0 call hram.dma_proc ld hl, ram_pattern_1 call check_oam jp nc, test_fe00 quit_failure_string "Fail: $E000" test_fe00: call clear_oam ld a, $fe call hram.dma_proc ld hl, ram_pattern_1 call check_oam jp nc, test_ff00 quit_failure_string "Fail: $FE00" test_ff00: ld a, $ff call hram.dma_proc ld hl, ram_pattern_2 call check_oam jp nc, test_finish quit_failure_string "Fail: $FF00" test_finish: quit_ok check_oam: ld de, OAM ld bc, OAM_LEN jp memcmp dma_proc: ldh (