forked from lancekindle/DMGreport
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01_minimal_template.asm
More file actions
58 lines (46 loc) · 2.02 KB
/
01_minimal_template.asm
File metadata and controls
58 lines (46 loc) · 2.02 KB
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
include "gbhw.inc" ; wealth of gameboy hardware & addresses info
;-------------- INTERRUPT VECTORS ------------------------
; specific memory addresses are called when a hardware interrupt triggers
; Vertical-blank triggers each time the screen finishes drawing. Draw-To-Screen
; routines happen here because Video-RAM is only available during vblank*
SECTION "Vblank", ROM0[$0040]
reti
; LCDC interrupts are LCD-specific interrupts (not including vblank) such as
; interrupting when the gameboy draws a specific horizontal line on-screen
SECTION "LCDC", ROM0[$0048]
reti
; Timer interrupt is triggered when the timer, rTIMA, ($FF05) overflows.
; rDIV, rTIMA, rTMA, rTAC all control the timer.
SECTION "Timer", ROM0[$0050]
reti
; Serial interrupt occurs after the gameboy transfers a byte through the
; gameboy link cable.
SECTION "Serial", ROM0[$0058]
reti
; Joypad interrupt occurs after a button has been pressed. Usually we don't
; enable this, and instead poll the joypad state each vblank
SECTION "Joypad", ROM0[$0060]
reti
;----------- END INTERRUPT VECTORS -------------------
; QUESTION TO STUDENT -- How many bytes separate each interrupt vector?
SECTION "ROM_entry_point", ROM0[$0100] ; ROM is given control from boot here
nop
jp code_begins
;------------- BEGIN ROM HEADER ----------------
; The gameboy reads this info (before handing control over to ROM)
;* macro calls (such as NINTENDO_LOGO) MUST be indented to run
SECTION "rom header", ROM0[$0104]
NINTENDO_LOGO ; add nintendo logo. Required to run on real hardware
ROM_HEADER "0123456789ABCDE"
; safe to include other files here. INCLUDE'd files often immediately add more
; code to the compiled ROM. It's critical that your code does not step over
; the first $0000 - $014E bytes
code_begins:
di ; disable interrupts
ld SP, $FFFF ; set stack to top of HRAM
.loop
halt ; halts cpu until interrupt triggers
nop
jp .loop
; QUESTION TO STUDENT: when run, this example displays Nintendo's logo. How?
; (hint) when run on a CGB it shows nothing; on a DMG, the logo appears.