;THIS IS WHERE OUR DEMO BEGINS ; WLA-DX banking setup .memorymap defaultslot 0 slotsize $8000 slot 0 $0000 .endme .rombankmap bankstotal 1 banksize $8000 banks 1 .endro ; SDSC tag and SMS rom header .sdsctag 1.10,"Background Color","SMS Color Tutorial","Stan" .bank 0 slot 0 .org $0000 ; Boot section di ; disable interrupts im 1 ; Interrupt mode 1 jp main ; jump to main program .org $0066 ; Pause button handler ; Do nothing retn ; Main program main: ld sp, $dff0 ; Set up VDP registers ld hl,VdpData ld b,VdpDataEnd-VdpData ld c,$bf otir ; Clear VRAM ; 1. Set VRAM write address to 0 by outputting $4000 ORed with $0000 ld a,$00 out ($bf),a ld a,$40 out ($bf),a ; 2. Output 16KB of zeroes ld bc, $4000 ; Counter for 16KB of VRAM ld a,$00 ; Value to write ClearVRAMLoop: out ($be),a ; Output to VRAM address, which is auto-incremented after each write dec c jp nz,ClearVRAMLoop dec b jp nz,ClearVRAMLoop ; Load palette ; 1. Set VRAM write address to CRAM (palette) address 0 (for palette index 0) ; by outputting $C000 ORed with $0000 ld a,$00 out ($bf),a ld a,$c0 out ($bf),a ; 2. Output color data ld hl,PaletteData ld b,(PaletteDataEnd-PaletteData) ld c,$be otir ; Background Color ; THIS IS OUR ACTUAL BACKGROUND COLOR PROGRAM Background: ld a,$00 out ($bf),a ld a,$00 out ($bf),a ld a,$c4 ; Turn on the screen out ($bf),a ld a,$81 out ($bf),a ; Data for our program to use PaletteData: .db $30 PaletteDataEnd: ; VDP initialisation data VdpData: .db $04,$80,$84,$81,$ff,$82,$ff,$85,$ff,$86,$ff,$87,$00,$88,$00,$89,$ff,$8a VdpDataEnd: ;This background color program was built using information found ;in Maxim of SMS Power fame's original programming tutorial. ;All information concerning the setting up of the VDP before the ;actual background code is his creation and the author owes him a ;great deal of gratitude for writing it. ;Background Color Demo Copyright Stan 2009 ;THIS IS THE ABSOLUTE END OF OUR PROGRAM DEMO