.include "library.inc" .include "macro.inc" .include "equ.inc" .nomlist .list ; variables scanline = $0 ; the line number for the scanline interrupt vsync = $2 ; synchro vbl ; wavy scroll wave_base = $3 ; base index for the wave table wave_idx = $4 ; index in the wave table ; scroll text st_flag = $5 ; event flag st_offset = $6 ; scroll offset st_ptr = $8 ; pointer in the text string st_pos = $A ; screen position for the next character st_width = $B ; width of a character st_char = $C ; current character ; sprites spr_idx = $D ; index for rotating stars spr_base = $E ; base for the circle spr_angle = $F ; circle rotation spr_frac = $10 ; for adjusting the angle spr_radius = $11 ; radius for the circle spr_dir = $12 ; direction for the zoom spr_ptr = $13 ; pointer in the sprite table spr_info = $2200 ; the eight sprites ; first, we initialize the interrupt vectors .bank 0 .org $FFF6 .dw null_int ;IRQ2, used by the BRK instruction .dw vdc_int ;IRQ1, interrupt from the VDC .dw null_int ;TIMER, not used in this demo .dw null_int ;NMI, never used (or may be by a HuCard!?) .dw reset_int ;RESET, the most important one :) .org $E000 null_int: rti ; reset_int: ; --------- ; it's here that everything starts! reset_int: sei ; disable interrupts csh ; select the 7.16 MHz clock cld ; clear the decimal flag ldx #$FF ; initialize the stack txs lda #$FF ; map the first page to the I/O bank tam #0 lda #$F8 ; and the second to the RAM bank tam #1 stz $2000 ; clear all the RAM tii $2000,$2001,$1FFF jsr init_vdc ; initialize the video controller jsr init_psg ; and the sound generator stz $C01 ; stop the timer stz $1402 ; unmask and enable interrupts cli ; now that all the hardware is initialized we can copy our ; sprite and character patterns into the VRAM. map spr_data ; map the sprite bank and the font map font_data ; bank into the memory ; copy all the data to the VRAM vload $1000,spr_data,64*4 vload $1800,water_data,16*4 vload $2000,font_data,16*256 ; initialize the palette setpal 16,spr_pal,3 setpal 0,water_pal,2 setpal 2,font_pal,1 ; fill the background stwi .scrtab,<_si ; address of the character table stwi $0,<_di ; set the VRAM address jsr set_write lda #32 ; size 32 lines of 32 blocks, each block .l1: ldx #32 ; is two 8x8 characters pha .l2: cly ; we fill each line with two words lda [_si],Y ; from the table iny sta $0002 lda [_si],Y iny sta $0003 lda [_si],Y iny sta $0002 lda [_si],Y iny sta $0003 dex ; next block bne .l2 addwi 4,<_si ; update the pointer in the table pla dec A ; next line bne .l1 ; initialize the variables and enable the display lda #32 ; initialize the scroll-text sta