You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
3.2 KiB
114 lines
3.2 KiB
INCLUDE "hardware.inc"
|
|
INCLUDE "game/game.asm"
|
|
INCLUDE "tools.asm"
|
|
|
|
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
|
|
|
|
SECTION "Header", ROM0[$100]
|
|
; Game code starts here
|
|
; $0100
|
|
ei ; Simple nop ; di ; Disable interrupts for now
|
|
jp Start ; Leave this tiny space
|
|
; $0104 - Nintendo logo
|
|
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
|
|
; $0134 - Game Title
|
|
db "GAMEBOYGAME", $00, $00, $00, $00, $00
|
|
; $0144 - New Licensee code
|
|
db $00, $00
|
|
; $0146 - SGB Flag
|
|
db $00
|
|
; $0147 - Cartridge Type (http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header#0147_-_Cartridge_Type)
|
|
db $00
|
|
; $0148 - ROM Size (http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header#0148_-_ROM_Size)
|
|
db $00 ; 32 KByte
|
|
; $0149 - RAM Size
|
|
db $00
|
|
; $014A - Destination Code
|
|
db $01
|
|
; $014B - Old Licensee code
|
|
db $33
|
|
; $014C - Mask ROM Version number
|
|
db $00
|
|
; $014D - $014F - Checksums
|
|
db $00, $00, $00
|
|
|
|
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
|
|
ld a, $01
|
|
ld [$FFFF], a ; Force enable VBLANK Interrupt
|
|
halt
|
|
|
|
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
|
|
ld de, Page1 ; The start of the font tiles
|
|
ld hl, $9000 ; Set registers hl to $9000 which is the beginning of vram
|
|
ld bc, Page1End - Page1 ; The total length of font tiles
|
|
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
|
|
|
|
ld a, 7
|
|
ld [rWX], a
|
|
ld a, SCRN_Y
|
|
ld [rWY], a
|
|
|
|
; Initialize other stuff
|
|
call InitTools
|
|
call InitController
|
|
call InitWindow
|
|
|
|
; Reset OAM memory with zeros
|
|
; First reset our shadow OAM
|
|
ld hl, shadow_oam ; Set position of OAM Ram to hl
|
|
ld a, 0 ; Fill that memory space with zero
|
|
ld b, shadow_oam_inuse - shadow_oam ; Get the full size of the fill
|
|
call Memfill
|
|
; Then call our OAM guy
|
|
call RunDMA
|
|
|
|
; Turn the screen on, display background
|
|
ld a, LCDCF_ON|LCDCF_BGON|LCDCF_WINON|LCDCF_WIN9C00
|
|
ld [rLCDC], a ; Set the screen flags
|
|
|
|
call WaitVBlank
|
|
|
|
jp GameLoop
|
|
|
|
SECTION "Font", ROM0
|
|
|
|
Page1:
|
|
INCBIN "assets/page1.chr"
|
|
Page1End:
|
|
|
|
|