2019-06-14 08:36:52 +00:00
|
|
|
INCLUDE "hardware.inc"
|
|
|
|
INCLUDE "game/game.asm"
|
|
|
|
INCLUDE "tools.asm"
|
|
|
|
|
2019-06-18 09:08:14 +00:00
|
|
|
SECTION "InterruptVblank", ROM0[$0040]
|
|
|
|
reti
|
|
|
|
SECTION "InterruptLCDC", ROM0[$0048]
|
|
|
|
reti
|
|
|
|
SECTION "InterruptTimer_Overflow", ROM0[$0050]
|
|
|
|
reti
|
|
|
|
SECTION "InterruptSerial", ROM0[$0058]
|
|
|
|
reti
|
|
|
|
SECTION "Interruptp1thru4", ROM0[$0060]
|
|
|
|
reti
|
|
|
|
|
2019-06-14 08:36:52 +00:00
|
|
|
SECTION "Header", ROM0[$100]
|
|
|
|
|
|
|
|
EntryPoint: ;
|
2019-06-18 09:08:14 +00:00
|
|
|
ei ; Simple nop ; di ; Disable interrupts for now
|
2019-06-14 08:36:52 +00:00
|
|
|
jp Start ; Leave this tiny space
|
|
|
|
|
|
|
|
REPT $150 - $104
|
|
|
|
db 0
|
|
|
|
ENDR
|
|
|
|
|
|
|
|
SECTION "Intro code", ROM0
|
|
|
|
|
|
|
|
Start:
|
|
|
|
; First step is to access the VRAM to insert our graphics data.
|
|
|
|
; To do so, we must wait until we are in VBLANK period.
|
|
|
|
; Loop until we find ourselves in VBLANK
|
|
|
|
|
|
|
|
; Turn off the LCD
|
|
|
|
.waitVBlank
|
2019-06-18 09:08:14 +00:00
|
|
|
ld a, $01
|
|
|
|
ld [$FFFF], a ; Force enable VBLANK Interrupt
|
|
|
|
halt
|
2019-06-14 08:36:52 +00:00
|
|
|
|
|
|
|
xor a ; ld a, 0 ; Reset the accumilator register
|
|
|
|
; Our target is to set bit 7 reset on the LDC to turn it off
|
|
|
|
ld [rLCDC], a ; We will have to write to LCDC again later, so it's not a bother, really.
|
|
|
|
|
|
|
|
; ----------- Font Begin copying to VRAM -----------
|
|
|
|
; Start copying our font to vram
|
2019-06-18 09:08:14 +00:00
|
|
|
ld de, Page1 ; The start of the font tiles
|
2019-06-14 08:36:52 +00:00
|
|
|
ld hl, $9000 ; Set registers hl to $9000 which is the beginning of vram
|
2019-06-18 09:08:14 +00:00
|
|
|
ld bc, Page1End - Page1 ; The total length of font tiles
|
2019-06-14 08:36:52 +00:00
|
|
|
call Memcpy
|
|
|
|
|
|
|
|
; ----------- Start the display -----------
|
|
|
|
; Init the display register
|
|
|
|
ld a, %11100100 ; Load the palette of white, light gray, dark gray, black
|
|
|
|
ld a, %00011011 ; Load the palette of white, light gray, dark gray, black
|
|
|
|
ld [rBGP], a ; Store the palette to display
|
|
|
|
|
|
|
|
xor a ; ld a, 0 ; Reset the accumilator
|
|
|
|
ld [rSCY], a ; Set our scroll Y position to 0
|
|
|
|
ld [rSCX], a ; Set our scroll X position to 0
|
|
|
|
|
|
|
|
ld [rNR52], a ; Turn off sound
|
|
|
|
|
|
|
|
; Turn the screen on, display background
|
2019-06-18 09:08:14 +00:00
|
|
|
ld a, LCDCF_ON|LCDCF_BGON
|
|
|
|
; ld a, %10000001 ; screen on = 8th bit, background display = 1st bit
|
2019-06-14 08:36:52 +00:00
|
|
|
ld [rLCDC], a ; Set the screen flags
|
2019-06-18 09:08:14 +00:00
|
|
|
ei ; Enable interrupts again?
|
2019-06-14 08:36:52 +00:00
|
|
|
jp GameLoop
|
|
|
|
|
|
|
|
SECTION "Font", ROM0
|
|
|
|
|
2019-06-18 09:08:14 +00:00
|
|
|
Page1:
|
|
|
|
INCBIN "assets/page1.chr"
|
|
|
|
Page1End:
|
2019-06-14 08:36:52 +00:00
|
|
|
|