My understanding of RESBL was that I chould set it one time only at the color clock where I wanted the ball to be positioned. What I didn't understand was the I need to set WSYNC after RESBL to get the ball to appear. I misunderstood what was meant by "strobe" register in this case. Writting to RESBL doesn't take affect until the next scanline. Then when I reach the correct scanline I set ENABLE and presto! the ball appears at the color clock where I had positioned it. After another WSYNC I disable the ball so I get the ball for just one scaneline.
These are some of the things that confused me in the Stella Programming Guide.
1) RESBL and ENABL can not both be set at the same time for the same scanline. There needs to be at least one WSYNC after RESBL before setting ENABL
2) Page 6 of the Stella's Programming Guide states I need to set a "1" to ENABL. But I think they meant to say write a "1" to bit 1, which is a "2" in decimal (#%00000010)
3) Page 8 of the Stella's Programming Guide states that setting RESBL during Horizontal Blank will position the ball at color clock zero. When I tried this, it positioned the ball around color clock 69 or so (give or take a clock)
4) I am still experimenting with HMBL and HMOVE.
processor 6502 include vcs.h include macro.h ;set origin to the start RAM ;this is where variables are declared SEG.U vars;this declares Uninitialized space. i.e. RAM ; "vars" is the label. YOU NEED THIS!! ORG $80 ;$80 is the beginning of RAM ; vet up variables YPos ds 1 XPos ds 1 ;set origin to the start of the 4k rom SEG;this ends the unitialized space and begins Initialized space ; i.e. ROM ORG $F000 ;$F000 is the beginning of ROM Reset ;Clear RAM and all TIA registers ldx #0 lda #0 Clear sta 0,x inx bne Clear ;total 9 bytes! ;////////////////////////////////////// ; InitializeVariables ;////////////////////////////////////// lda #$D6 ; light green sta COLUPF;set the playfield and Ball color ;EndInitializeVariables ;//////////////////////////////////////// StartOfFrame; Beginning of the game ;//////////////////////////////////////// ;///////////////////////////////////// ; VerticalSync ;top 3 scanlines ;using macro. this also stops vsync VERTICAL_SYNC ;///////////////////////////////////// ;///////////////////////////////////// ;VerticalBlank ;37 scanlines ldx #37 ; 37 scanlines of vertical blank... vblankloop sta WSYNC dex ;2 bne vblankloop ;3 SLEEP 17 ;end of hblank SLEEP 20 ;about the center of the visible scanline sta RESBL; enable the ball for color clock 60 (give or take) LDX #0 STX VBLANK sta WSYNC ;EndVerticalBlank ;//////////////////////////////////////// ;//////////////////////////////////////// ;DrawScreen ;192 scanlines ldx #192;set the counter for 192 scanlines scrloop ;I have 192 scanlines of picture ;remember, that's 228 clocks / 3 = 76 cpu cycles per line ;HBLANK 68 CLOCKS/ about 22 cycles ;VISIBLE 160 CLOCKS / about 53 cycles CPX #40 BEQ PLAYBALL; if scanline 40 from bottom jump to PLAYBALL JMP NOBALL ; else jump to NOBALL PLAYBALL lda #2 ;Stella's Programming Guide ;page 6 says to write a "1" ;but doesn't seem to work. sta ENABL ; enable the ball! STA WSYNC ;ball does not display if I don't set WSYNC here DEX ; decrament the counter after setting WSYNC NOBALL lda #00 ;zero disables the ball sta ENABL ;disable the ball sta WSYNC ;end of scanline DEX BNE scrloop ;EndDrawScreen ;//////////////////////////////// ;//////////////////////////////// OverScan ;now you have 30 scanlines of overscan LDA $%0001 STA HMBL STA WSYNC STA HMOVE LDX #29 O1 STA WSYNC DEX BNE O1 ;EndOverScan ;////////////////////////////////// ;/////////////////////////////////////// ;go back to the beginning: ;inifinate loop JMP StartOfFrame ;////////////////////////////////////// ;***************************** ;Graphics ;***************************** ;//place graphics here ;this is the end. change origin to the end of the 4k rom org $FFFA TheEnd .word Reset ;NMI;used in 7800? .word Reset ;RESET .word Reset ;IRQ;used in 7800? ;end of file END














