I fixed the issue I had with aligning the bits of the X/Y video pixel counters with the cpu accessing the videoRAM. The vertical scrolling works correctly, but there is a problem with the horizontal scrolling. I suspect it has something to do with me using the O and N accum ulator values which are not in sync with the video timing. I'll try to use programmable counters next attempt. This video shows what is currently happening, and I will explain:
VIDEO1) Page 0 (1024x1024) of video (1024x768) is filled with black pixels. The remaining 'uncleared' pixels (1024x256) can be seen underneath.
2) Then a circle with diameter 239 (1/2 vertical = largest circle) pixels is plotted with green pixels.
3) Page 1 of video is filled with blue pixels. Again the remaining uncleared pixels can be seen underneath.
4) Then a circle with diameter 119 pixels is plotted with yellow pixels.
5) Page 0 is displayed first and vertically scrolled (1024x) upwards into Page 1, then back into Page 0
6) Then Page 0 is horizontally scrolled (eventually) into Page 1 (1024x), but this is where it is not working properly. I suspect the software delays have something to do with the improper timing.
7) Then Page 0 is 'flipped' back to the display, and the radar sweep using LineGen is seen.
8) Repeat to step 1
The software is not too terribly long, so I will post so any interested can see what's going on:
Code:
;-------------------------------------------------------------------------------
;CB0 : PAGE FLIP CONTROL
;CB1 : 1 = SCROLL, 0 = PAGE FLIP
;CB2 : 1 = SCROLL HORIZONTAL, 0 = VERTICAL
;CB3 : TBD - to be determined
;CF0 : 1 = LINE GENERATOR READY, 0 = NOT READY
;CF1 : 1 = VSYNC IS IN RETRACE, 0 = ACTIVE DISPLAY
;CF2 : 1 = HBLANK, 0 = ACTIVE DISPLAY
;CF3 : TBD
;Processor Status P = { 16'b0, CF3, CF2, CF1, CF0, CB3, CB2, CB1, CB0, N, V, 3'b110, I, Z, C };
START: LDA #$1000
TAZP ;SET ZEROPAGE @$1000_0000
LDA #$1001
TASP ;SET STACKPAGE @$1001_0000
;
CCB0 ;0 = VIDEO PAGE 0, 1 = VIDEO PAGE 1
CCB1 ;0 = PAGE FLIPPING, 1 = SCROLLING
CCB2 ;0 = VERTICAL, 1 = HORIZONTAL
LDX #0 ;SET BLACK SCREEN ACCORDING TO COLOR LUT
LDQax CLUT,X ;-LDQ CLUT,X. USE Q ACCUMULATOR FOR PIXEL COLOR
JSR CLRSCR
;LDA #%1000011100000000 ;C64 FONT, YELLOW
;STA ATTBUT ;FOR CHARACTERS ONLY
LDX #5
LDQax CLUT,X ;-LDQ CLUT,X. SET PIXEL COLOR GREEN
LDWi $017F ;MAX RADIUS = 239
LDGi $01FF ;G ACC IS XCENTER
LDHi $017F ;H ACC IS YCENTER
STWzp RA
JSR CIRCLE
SCB0 ;VIDEO PAGE 1
LDX #6 ;SET BLUE SCREEN ACCORDING TO COLOR LUT
LDQax CLUT,X ;-LDQ CLUT,X. USE Q ACCUMULATOR FOR PIXEL COLOR
JSR CLRSCR
LDX #7
LDQax CLUT,X ;-LDQ CLUT,X. SET PIXEL COLOR YELLOW
LDWi $00BF ;RADIUS = 119
LDGi $01FF ;G ACC IS XCENTER
LDHi $017F ;H ACC IS YCENTER
STWzp RA
JSR CIRCLE
CCB0 ;VIDEO PAGE 0
SCB1 ;SET SCROLL
CCB2 ;VERTICAL SCROLL
LDOi $0000 ;Y SCROLL OFFSET
LDNi $0000 ;X SCROLL OFFSET
VSCRL JSR DELAY
JSR DELAY
JSR DELAY
INCO ; SCROLL UPWARDS
CMPOi $0400
BNE VSCRL
LDOi $0000
CCB0 ;VIDEO PAGE 0
SCB1 ;SCROLL MODE
SCB2 ;HORIZONTAL SCROLL
HSCRL JSR DELAY ;SCROLL LEFT
JSR DELAY
JSR DELAY
INCN
CMPNi $0400
BNE HSCRL
CCB0 ;VIDEO PAGE 0
CCB1 ;PAGE FLIP MODE
CCB2 ;VERTICAL SCROLL - DOESN'T MATTER
;line plotting begins here
;LineGen module auto plots after it receives a value in 'ly1'
LDX #3 ;CYAN
LDQax CLUT
LDY #0
QUADRANT1 LDA #512
STA lx0
LDA #384
STA ly0
STY lx1
LDA #0
STA ly1
BCF0C $FFFE ;CF0 = LineGen Ready. 1 = ready.
JSR DELAY
INY
CPY #1023
BNE QUADRANT1
LDY #0
QUADRANT2 LDA #512
STA lx0
LDA #384
STA ly0
LDA #1023
STA lx1
STY ly1
BCF0C $FFFE ;CF0 = LineGen Ready. 1 = ready
JSR DELAY
INY
CPY #767
BNE QUADRANT2
LDY #1023
QUADRANT3 LDA #512
STA lx0
LDA #384
STA ly0
STY lx1
LDA #767
STA ly1
BCF0C $FFFE ;CF0 = LineGen Ready. 1 = ready
JSR DELAY
DEY
BNE QUADRANT3
LDY #767
QUADRANT4 LDA #512
STA lx0
LDA #384
STA ly0
LDA #0
STA lx1
STY ly1
BCF0C $FFFE ;CF0 = LineGen Ready. 1 = ready
JSR DELAY
DEY
BNE QUADRANT4
ENDALL JMP START
DELAY LDWi $3FFF
GHI DEW
BNE GHI
RTS
This is what I've been wrestling with in the Verilog HVSync module:
Code:
//pixel counters & video address
reg [10:0] X = 0;
reg [10:0] Y = 0;
always @(posedge clk) begin
if ( hstart )
countflag <= 1;
if ( hblank )
countflag <= 0;
end
always @(posedge clk)
if ( vstart | (X == 1023 + NACCout && Y == 767 + OACCout)) begin
X <= NACCout;
Y <= OACCout;
end
else if ( X == 1023 + NACCout ) begin
Y <= Y + 1;
X <= NACCout;
end
else if ( countflag )
X <= X + 1;
always @*
if (CB1) begin //CB1 = 1 when scrolling, 0 when bank switch
if (CB2) Vaddr [20:0] <= { X[10] + NACCout[10], Y[9:0], X[9:0] + NACCout[9:0] }; //scrolling horizontal
else Vaddr [20:0] <= { Y + OACCout, X[9:0] }; //scrolling vertical
end
else Vaddr [20:0] <= { CB0, Y[9:0], X[9:0] }; //bank switching
I will upload the new video shortly. Thanks for watching!