; Made by Alessandro Lo-Presti (Agilo) on Januari 24, 2008. ; Fade in/out effect. .orgfill 0x1460 ; Start of General Purpose RAM. ; Variables could go here. .orgfill 0x2100 ; Start of ROM space. .db "MN" ; ROM ID (do not change or validation will fail). .include "irq.asm" ; Game cart IRQ vectors. ; Pokemon Mini game header. .orgfill 0x219E ; 0x219E - 0x21A3 must be empty. .orgfill 0x21A4 ; Start of "NINTENDO" string. .db "NINTENDO" ; Magic signature checked by the BIOS. .db "GFXR" ; Game code, 4 bytes. .db "GFX & Rumble" ; Name of ROM, 12 chars max. .orgfill 0x21BC ; Will contain the following string: .db "2P" ; At this time it's unknown what "2P" stands for. .orgfill 0x21D0 ; End of rom header, start of program code. .include "irqhandlers.asm" ; Game cart IRQ routine handlers. ; Code entry point. start: movw sp, 0x2000 ; Set SP to end of general purpose RAM (stack grows down). movw nn, 0x2000 ; NN register points to hardware registers. ; Enable primary interrupts on all keys. movb [nn+0x21], 0x0C ; Enable secondary interrupt for the power button (CPU will jump to 0x215C). movb [nn+0x25], (1<<7) ; Clear all flags. movb flags, 0 ; Enable LCD controller: 12x16, Global rendering, BG rendering, Non-inverted. movb [nn+0x80], 0b00001010 ; Set refresh rate (60Hz / 2 = 30Hz). movb [nn+0x81], 0b00001001 ; b = 95 (there are 95 blocks of 8x8 pixels on the screen). movb b, 95 ; Set HL to the end of the Tile Map data. movw HL, 0x1360+95 bglinear: ; Move a tileblock (e.g. 95) to the Tile Map (e.g. 1360+95). ; After that, move the next block (e.g. 94) to the Tile Map (e.g. 1360+94). ; Etc. movb [HL], b ; Keep decrementing. dec HL ; While b is not zero, go to the next block, otherwise end this loop. jdbnz bglinear ; Store the address of the image in the memory address register. movw x1, scrtest ; Write the address to a register of the LCD so the PM knows where to look. movw [0x2082], x1 ; Setup contrast. movw x2, 0x20FE movb [x2], 0x81 inc x2 movb [x2], 0x1F mov b, 0x1F ; Logics start here. PM_loop: ; Wait twelve vblanks. call wait call wait call wait call wait ; Fade out. _fadeout: movb [nn+0xFE], 0x81 movb [nn+0xFF], b call wait jdbnz _fadeout ; Fade back in. _fadein: movb [nn+0xFE], 0x81 movb [nn+0xFF], b call wait inc b test b, 0xE0 jz _fadein jmp PM_loop ; Wait a vblank. vblank: test [nn+0x8A], (1<<4) jz vblank vblank2: test [nn+0x8A], (1<<4) jnz vblank2 ret ; Wait three vblanks. wait: call vblank call vblank call vblank ret ; Blocks are 8x8 pixels (8 bytes large) .align 8 ; Include the image. scrtest: .incbin logo-agilo-96x64_bw.bin