processor 6502 include vcs.h include sleep.h include macro.h ;Checks whether * and {1} reside on the same page MAC CHECK_ALIGN IF >{1} - >* ;I can't figure out how to print the actual label, so have DASM fail here and print it ECHO {1} not aligned ERR ENDIF ENDM ;FPS = 50 or 60 ;PAL = 0 or 1 #if FPS==50 ;PAL VBLNK equ 48 LINES equ 228 OVERSCN equ 36 #else ;NTSC VBLNK equ 40 LINES equ 192 OVERSCN equ 30 #endif BPM equ 140 TEMPO equ (128*8*BPM)/(60*FPS) SONGDBG equ 0 FADEOUT equ 0 ;RAM SEG.U VARS org $80 frame ds 1 temp ds 4 temp16L equ temp+1 temp16H equ temp+2 atten equ temp+3 ;song player vars beat ds 1 tempoCount ds 1 measure ds 1 huffptr ds 2 bits ds 1 nbits ds 1 charptr ds 24 ;only putting this here because there's space left over and it saves ROM not having to reinit them to zero looping ds 1 ;nonzero if we're inside the music loop wipe ds 1 VARSTART equ * harryfrm ds 1 harryptr ds 2 harryyvel ds 2 harryxpos ds 1 harryypos ds 2 drawexcl ds 1 ;0 = don't draw, 16 = draw bk ds 1 bknz ds 1 signclr ds 1 textand ds 1 textor ds 1 burntop ds 1 burnbottom ds 1 logoystart ds 1 shakelines ds 1 skipharry ds 1 org VARSTART textypos ds 1 huffsym equ temp+1 huffnsym equ temp+2 huffofs equ temp+3 slant ds 1 EORKERNELSZ equ (LINES-64)/4+1 ytab ds EORKERNELSZ ramkernel ds KERNELSIZE echo "RAM:", ($100 - *)d, "bytes left" include twelvechar.asm include build/font.asm include harry.asm include eorplasma.asm ;ROM SEG CODE org $1000 FONT FONTSZ equ *-Glyph0 echo "Font:",(FONTSZ)d,"bytes" include build/svlogo.asm include build/sintab.asm LOGO_PF0PF1 include utils.asm include harrygfx.asm HARRY_KERNEL EOR_KERNEL TWELVECHAR_KERNEL HUFFTAB LOGO_PF2 LOGO_PF1 TEXT echo "Text:",(*-Text)d,"bytes" TWELVECHAR_LOGIC EOR_LOGIC HARRY_LOGIC Player include songplay.h echo "Player:",(*-Player)d Start CLEAN_START lda #2*SVLOGOLINES sta burnbottom lda #SIGNCLR sta signclr lda #$07 sta textand lda #$50 sta textor ;lda #EORMEASURE ;sta measure MainLoop lda #(OVERSCN-1)*19/16 sta TIM64T lda #2 sta VBLANK inc frame ;TODO: size optimize? jsr songPlayer lda measure cmp #EORMEASURE bcs DoTextLogic lda looping beq WaitForOverscanEnd DoTextLogic jsr twelvecharLogic WaitForOverscanEnd sta WSYNC lda INTIM bpl WaitForOverscanEnd VERTICAL_SYNC lda #VBLNK*19/16-2 sta TIM64T lda measure cmp #EORMEASURE bcs GoEorLogic lda looping bne GoEorLogic jsr HarryLogic jmp WaitForVblankEnd GoEorLogic jsr EorPlasmaLogic WaitForVblankEnd lda INTIM bpl WaitForVblankEnd lda #0 sta WSYNC sta HMOVE ;this saves WSYNC + HMOVE (4 B) in each kernel that positions stuff during VBLANK sta VBLANK ;NOTE: Don't set COLUBK before VBLANK has been turned off (above) ; Otherwise you get ugly colors for the first few lines lda measure cmp #EORMEASURE bcs GoEorKernel lda looping bne GoEorKernel jsr HarryKernel jmp MainLoop GoEorKernel ldy #0 jsr EorPlasmaKernel jsr WipeBurn ;two black lines sta WSYNC lda looping bne NotSlidingKernel lda measure cmp #SLIDEMEASURE+1 bcs NotSlidingKernel tsx ;SP = $FF lda beat sbc #23 ;C = 0 tay bmi PF1LOK ldx SlideTabPF1L,Y PF1LOK stx temp+0 tsx tya adc #8 tay bmi PF2LOK cpy #7 bcc PF2LYOK ldy #7 PF2LYOK ldx SlideTabPF2L,Y PF2LOK stx temp+1 tsx ldy beat cpy #7 bcc PF1RYOK ldy #7 PF1RYOK ldx SlideTabPF1R,Y stx temp+2 ldx #CHARH*4+4+TEXTYPOSMAX+1 SliderKernelLoop sta WSYNC ldy #0 lda measure cmp #SLIDEMEASURE bcc SetBackground ;black screen ldy #$50 SetBackground sty COLUBK ldy beat lda temp+0 sta PF1 lda temp+1 sta PF2 SLEEP 5 cpy #15 bcs PF2RYBad lda SlideTabPF2R,Y bne STAPF2 PF2RYBad lda #$00 SLEEP 4 STAPF2 sta PF2 lda temp+2 sta PF1 dex bne SliderKernelLoop sta WSYNC stx COLUBK sta WSYNC beq DoWipeBurn NotSlidingKernel sta WSYNC jsr twelvecharKernel DoWipeBurn jsr WipeBurn ldy #1 jsr EorPlasmaKernel jmp MainLoop WipeBurn lda #EORKERNELSZ sec sbc wipe asl tax jmp Burn ;slightly wasteful, but better than using two 96 bytes of tables SlideTabPF2R byte %11111111 byte %11111111 byte %11111111 byte %11111111 byte %11111111 byte %11111111 byte %11111111 byte %11111111 SlideTabPF1L byte %11111110 byte %11111100 byte %11111000 byte %11110000 byte %11100000 byte %11000000 byte %10000000 byte %00000000 SlideTabPF2L SlideTabPF1R byte %01111111 byte %00111111 byte %00011111 byte %00001111 byte %00000111 byte %00000011 byte %00000001 byte %00000000 Music include song.h echo "Music:",(*-Music)d echo "ROM:", ($1FFC - *)d, "bytes left" org $1FFC .word Start .word $200D