; ; ; A Simple Asymmetrical Title Screen Playfield ; ; this is a simple kernal meant to be usable for a title screen. ; can be adapted to put playfield text at an arbitrary height on the screen ; ; ; it owes a great debt to Glenn Saunders Thu, 20 Sep 2001 Stella post ; " Asymmetrical Reflected Playfield" (who in turn took from Roger Williams, ; who in turn took from Nick Bensema--yeesh!) ; ; it's meant to be a tightish, welll-commented, flexible kernal, ; that displays a title (or other playfield graphic) once, ; instead of repeating it - also it's a steady 60 FPS, 262 scanlines, ; unlike some of its predecessors ; ; also, it's non-reflected, so you can easily use a tool like my ; online javascript tool at http://alienbill.com/vgames/playerpal/ ; to draw the playfield ; ; It uses no RAM, but all Registers when it's drawing the title processor 6502 include vcs.h org $F000 ;------------------------ ;begin 'boiler plate' startup code ;------------------------ Start SEI CLD LDX #$FF TXS LDA #0 ClearMem STA 0,X DEX BNE ClearMem ;------------------------ ;end 'boiler plate' startup code ;------------------------ LDA #00 STA COLUBK ;black background LDA #33 STA COLUPF ;colored playfield ;MainLoop starts with usual VBLANK code, ;and the usual timer seeding MainLoop LDA #2 STA VSYNC STA WSYNC STA WSYNC STA WSYNC LDA #43 STA TIM64T LDA #0 STA VSYNC ; ; lots of logic can go here, obviously, ; and then we'll get to the point where we're waiting ; for the timer to run out WaitForVblankEnd LDA INTIM BNE WaitForVblankEnd STA VBLANK ;so, scanlines. We have three loops; ;TitlePreLoop , TitleShowLoop, TitlePostLoop ; ; I found that if the 3 add up to 174 WSYNCS, ; you should get the desired 262 lines per frame ; ; The trick is, the middle loop is ; how many pixels are in the playfield, ; times how many scanlines you want per "big" letter pixel pixelHeightOfTitle = 6 scanlinesPerTitlePixel = 6 ;just burning scanlines....you could do something else LDY #20 TitlePreLoop STA WSYNC DEY BNE TitlePreLoop LDX #pixelHeightOfTitle ; X will hold what letter pixel we're on LDY #scanlinesPerTitlePixel ; Y will hold which scan line we're on for each pixel ; ;the next part is careful cycle counting from those ;who have gone before me.... TitleShowLoop STA WSYNC LDA PFData0Left-1,X ;[0]+4 STA PF0 ;[4]+3 = *7* < 23 ;PF0 visible LDA PFData1Left-1,X ;[7]+4 STA PF1 ;[11]+3 = *14* < 29 ;PF1 visible LDA PFData2Left-1,X ;[14]+4 STA PF2 ;[18]+3 = *21* < 40 ;PF2 visible NOP ;[21]+2 NOP ;[23]+2 NOP ;[25]+2 ;six cycles available Might be able to do something here LDA PFData0Right-1,X ;[27]+4 ;PF0 no longer visible, safe to rewrite STA PF0 ;[31]+3 = *34* LDA PFData1Right-1,X ;[34]+4 ;PF1 no longer visible, safe to rewrite STA PF1 ;[38]+3 = *41* LDA PFData2Right-1,X ;[41]+4 ;PF2 rewrite must begin at exactly cycle 45!!, no more, no less STA PF2 ;[45]+2 = *47* ; > DEY ;ok, we've drawn one more scaneline for this 'pixel' BNE NotChangingWhatTitlePixel ;go to not changing if we still have more to do for this pixel DEX ; we *are* changing what title pixel we're on... BEQ DoneWithTitle ; ...unless we're done, of course LDY #scanlinesPerTitlePixel ;...so load up Y with the count of how many scanlines for THIS pixel... NotChangingWhatTitlePixel JMP TitleShowLoop DoneWithTitle ;clear out the playfield registers for obvious reasons LDA #0 STA PF2 ;clear out PF2 first, I found out through experience STA PF0 STA PF1 ;just burning scanlines....you could do something else LDY #138 TitlePostLoop STA WSYNC DEY BNE TitlePostLoop ; usual vblank LDA #2 STA VBLANK LDX #30 OverScanWait STA WSYNC DEX BNE OverScanWait JMP MainLoop ; ; the graphics! ; I suggest my online javascript tool, ;PlayfieldPal at http://alienbill.com/vgames/playerpal/ ;to draw these things. Just rename 'em left and right PFData0Left .byte #%00000000 .byte #%00000000 .byte #%10000000 .byte #%01000000 .byte #%00000000 .byte #%00000000 PFData1Left .byte #%00000000 .byte #%00000000 .byte #%00010011 .byte #%10101010 .byte #%10010010 .byte #%10000000 PFData2Left .byte #%00000000 .byte #%00000000 .byte #%10001101 .byte #%10001001 .byte #%11011001 .byte #%10000000 PFData0Right .byte #%00000000 .byte #%00000000 .byte #%01000000 .byte #%11000000 .byte #%01010000 .byte #%11000000 PFData1Right .byte #%00000000 .byte #%00000000 .byte #%00010010 .byte #%00101010 .byte #%10010011 .byte #%00000000 PFData2Right .byte #%00001100 .byte #%00010000 .byte #%00011001 .byte #%00010101 .byte #%00011000 .byte #%00000000 org $FFFC .word Start .word Start