; Made by Alessandro Lo-Presti (Agilo) on Januari 28, 2008. ; A text engine I wrote as a proof-of-concept kind of deal. .orgfill 0x1460 ; Start of General Purpose RAM. ; Just a note that I may be able to use later on in life: ; uhm you cant inizialize ram ; you'd have to read the values from the ROM and write the to RAM ; the only way you can read the values that you put at 0x1460 (in the ; ROM) is to read them from ROM using the memory wrap (never done that) .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 "TXTE" ; Game code, 4 bytes. .db "Text engine" ; 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: 12x16, Global rendering, BG rendering, Non-inverted. movb [nn+0x80], 0b00001010 ; Set refresh rate (60Hz / 2 = 30Hz). movb [nn+0x81], 0b00001001 ; Include the text engine. .include "textengine.asm" ; Logics start here. PM_loop: ; Write some text using the engine. :) writestr "Pokemon MiniText Engine Made by: Agilo www.agilo.nl" ; Move key status into a. movb a, [nn+0x52] ; Invert background on A. test a, 0x01 jnz _restore_screen orb [nn+0x80], 0x01 ; Set the invert bit of the LCD controller. jmp _no_restore_screen _restore_screen: andb [nn+0x80], 0xFE ; Clear the invert bit of the LCD controller. _no_restore_screen: ; Wait for vblank. call vblank jmp PM_loop ; Wait a vblank. vblank: mov [nn+0x27], 0x80 _sloop: test [nn+0x27], 0x80 jz _sloop ret ; Blocks are 8x8 pixels (8 bytes large). .align 8 ; Include the character map. charmap: .incbin charmap.bin