-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.asm
92 lines (74 loc) · 1.65 KB
/
main.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
INCLUDE "inc/hardware.inc"
INCLUDE "inc/gb8.inc"
INCLUDE "src/data.asm"
INCLUDE "src/roms.asm"
INCLUDE "src/ram.asm"
INCLUDE "src/functions.asm"
INCLUDE "src/emu.asm"
INCLUDE "src/init/gfxinit.asm"
INCLUDE "src/init/emuinit.asm"
INCLUDE "src/selection.asm"
SECTION "Vectors", ROM0[0]
ds $40 - @
VBlankVector::
reti
ds $100 - @
SECTION "Entry Point", ROM0[$100]
nop
jr Main
; Pad header fields
ds $150 - @
SECTION "Main", ROM0[$150]
Main::
; Store initial value of L in RAM
ld [wInitialRegA], a
Restart::
; Wait for VBlank, disable LCD
ldh a, [rLY]
cp SCRN_Y
jr c, Main
xor a
ld [rLCDC], a
; Disable Sound
ld a, AUDENA_OFF
ldh [rAUDENA], a
; Zero out VRAM tile data
ld hl, $8000
ld bc, $01A0
call Zerofill
; Initialize Graphics
call InitPalettes
call InitFont
; Check if running in CGB mode
ld a, [wInitialRegA]
cp BOOTUP_A_CGB
jp nz, ScreenNonCGB
; Jump to Selection Menu Initialization
jp StartSelectionMenu
ScreenNonCGB::
; Initialize DMG Palette
ld a, %11010100
ld [rBGP], a
; Print CGB-only text to screen
ld hl, (NonCGBPtrVRAM)
ld de, strNonCGB1
call PrintString
ld hl, (NonCGBPtrVRAM + $40)
ld de, strNonCGB2
call PrintString
ld hl, (NonCGBPtrVRAM + $80)
ld de, strNonCGB3
call PrintString
; Initialize LCD and clear IF/IE
xor a
ldh [rIF], a
ldh [rIE], a
ld a, LCDCF_ON | LCDCF_BGON | LCDCF_BG8000
ldh [rLCDC], a
ei
nop
; HALT infinitely
halt
strNonCGB1: db "THIS SOFTWARE IS", 0
strNonCGB2: db "INTENDED FOR USE", 0
strNonCGB3: db "ON GAMEBOY COLOR", 0