Advertisement
mattcurrie

Register Logger

Aug 6th, 2020
947
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. INCLUDE "src/includes/common.s"
  2.  
  3. SECTION "init", ROM0
  4.  
  5.  
  6. test: MACRO
  7.     ; select the ram bank
  8.     ld a, \1
  9.     ld [$4000], a
  10.  
  11.     ld a, 0
  12.     ld hl, $a000
  13.     ld bc, $2000
  14.     call memset
  15.  
  16.     call WaitVBlank
  17.  
  18.     ; turn screen off
  19.     xor a
  20.     ldh [rLCDC], a
  21.  
  22.     ld a, $10
  23.     ld [rLYC], a
  24.  
  25.     ld c, low(rSTAT)
  26.     ld hl, $a000
  27.  
  28.     ; turn screen on
  29.     ld a, LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8000 | LCDCF_BG9800 | LCDCF_OBJ8 | LCDCF_OBJON | LCDCF_BGON
  30.     ldh [rLCDC], a
  31.  
  32.     ; wait for some nops
  33.     nops \1
  34.  
  35.     call RunTest
  36.  
  37.     ENDM
  38.  
  39.  
  40. Init::
  41.  
  42.     call TurnLcdOn
  43.  
  44.     ; enable sram
  45.     ld a, $0a
  46.     ld [$0000], a
  47.  
  48.     ; set ram bank select mode
  49.     ld a, $01
  50.     ld [$6000], a
  51.  
  52.  
  53.     test 0
  54.     test 1
  55.     test 2
  56.     test 3
  57.  
  58.  
  59.     ; disable sram
  60.     xor a
  61.     ld [$0000], a
  62.  
  63.     ld hl, $9800
  64.     print_string_literal "done!"
  65.     jp Terminate
  66.  
  67.  
  68. RunTest::
  69.     ; (456/4) * (154 + 2 extra lines) / 4 cycles = 4446
  70. REPT 4446
  71.     ld a, [c]     ; 2 cycles
  72.     ld [hl+], a   ; 2 cycles
  73. ENDR
  74.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement