.DB $01, $02, $04, $08, $10, $20, $40, $80 .PADTO 0x0040 VBlank: JP =VBLANK_Entrypoint .PADTO 0x0048 STAT: JP =STAT_Entrypoint .PADTO 0x0100 Start: JP =Initialize_RAM .PADTO 0x0104 Nintendo_Logo: ; The Nintendo logo must be stored in bytes 0x104-133 .DB $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$00,$0C,$00,$0D .DB $00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6,$DD,$DD,$D9,$99 .DB $BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$BB,$B9,$33,$3E .PADTO 0x0134 Checksum: ; The bytes 0x134-0x14d need to add up to 0xe7 (= 0xff - 0x19) .DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$e7 Initialize_RAM: ; Disable Interrupts LD A, $00 LD $reg_interrupt_enable, A Empty_WRAM: LD HL, $C000 Empty_WRAM.loop: XOR A LD (HL+), A LD A, $D0 CP H JR NZ, =Empty_WRAM.loop CALL =VBlank_Wait ; LCDC XOR A LD $reg_lcd_controller, A Empty_VRAM: ; (Clear screen) LD HL, $VRAM_start ; We set the HL register to the start of VRAM Empty_VRAM.loop: XOR A LD (HL+), A ; We set the memory pointed to by HL to 0 and increase HL LD A, $a0 CP H ; Until h has reached $a0 ($a0000 is the end of VRAM) JR NZ, =Empty_VRAM.loop ; BG Palette LD A, $e4 LD $reg_bg_palette, A ; OBJ0 Palette LD A, $d3 ; $e4 LD $reg_obj0_palette, A Initialize_Window_GUI: LD HL, $9c20 Initialize_Window_GUI.top_bar_loop: LD A, $10 LD (HL+), A LD A, L CP $40 LD $reg_lcd_status, A JR NZ, =Initialize_Window_GUI.top_bar_loop LD HL, $9da0 LD BC, $00a0 LD DE, =Dialogue_Box_Tilemap_data CALL =memcpy Copy_OAM_DMA_Transfer_Routine_To_HRAM: LD HL, $OAM_DMA_Transfer_routine LD DE, =OAM_DMA_Transfer_routine_src LD BC, $000a CALL =memcpy JP =Entrypoint OAM_DMA_Transfer_routine_src: LD A, $mem_oam_buffer_high LD ($46), A LD A, $28 ; delay for a total of 4×40 = 160 M-cycles OAM_DMA_Transfer_routine_src.wait: DEC A ; 1 M-cycle JR NZ, =OAM_DMA_Transfer_routine_src.wait ; 3 M-cycles RET OAM_DMA_Transfer_routine_src.end: