I haven't posted in a while... I've been really busy with this "online university" thing. In less than a month I will be able to work on this more regularly.
I left off with fonts and such, and not much has happened since then. I've written some screen subroutines, including one that scrolls the screen one character line up.
And that's when trouble begins. When scrolling (it does so upon pressing the enter key just for testing), some lines, dots and other creatures appear primarily (but not only) at the bottom of the screen and make their way up. It's not a software issue, I have made simplified subroutines, testing a line at a time etc, and it still happens. Should anyone be interested here is my scrolling subroutine:
Code:
;************************************************************
;* VGA SCROLL *
;************************************************************
; Scrolls the screen one character up (8 lines)
vgaScroll: pha ;push A
txa
pha ;push X
tya
pha ;push Y
;Set up two line indexes, one to read from and one to copy from.
ldy #(hi vRAMbase)
sty vRAMIdx +1
ldy #$0
sty vRAMIdx
sty vRAMIdx2
ldy #(hi vRAMbase) +1
sty vRAMIdx2 +1
vsNextLine: ldy #$0
vsLineLoop: dey
lda (vRAMIdx2), y ; Copy lower line
sta (vRAMIdx), y ; Save in upper line
cpy #$0
bne vsLineLoop
inc vRAMIdx +1 ;Increase line index
ldy vRAMIdx2 +1
iny
sty vRAMIdx2 +1
cpy #(hi vRAMbase) +$10 ;Check if we have reached the bottom
bcc vsNextLine
;jmp vsEnd
;Clear last line
lda #$0
tay
vsClrLoop: sta (vRAMIdx), y
dey
bne vsClrLoop
vsEnd pla ;Retrieve Y,X,A
tay
pla
tax
pla
rts
Just to recap, my video card just "listens" to the address and data buses and copies RAM writes on certain addresses to its own RAM.
So those must be errors when writing or reading from "system" RAM. Either the RAM, the CPU or something in between is to blame. I made a couple programs that wrote patterns to memory and checked back, but I wasn't able to get it to fail that way.
So I cleared the screen and modified the scroll subroutine to check if the bytes read were 0 or not. If it read a non-zero byte, it just does
Code:
ldx #$ff
ldx #$0
so I get a pulse on the X register that I can probe with the scope (that's the good thing about ttl CPUs).
I then noticed that when taking the video card out, pulses became more frequent. The video card should only have an effect on power consumption, effectively dropping the 5V rail (it's the hungriest card of all). So I left it plugged in and lowered the voltage on my power supply. Sure enough, pulses became less frequent and eventually disappeared.
But now at lower voltages, the video card stops working properly, as expected. There is a "sweet spot" when both work, but that's no acceptable solution.
I had set my power supply to just under 6V, the drop in the leads resulting in about 5 V on the computer cards. When lowering it about 5.5 V, voltage on the computer is 4.4 V or so. RAM's recommended supply voltage is 4.5-5.5V.
I think this means that the errors are occurring during reads, as data on the bottom line of the screen is only written once at the start, but upon reading, it sometimes reads fine, sometimes doesn't. I have checked timing requirements and I think those are met with plenty of margin. I have swapped out the RAM for another identical one, and it makes no difference.
Whatever the cause is, RAM errors would explain the far less frequent "random resets" that I'm experiencing as well.
Any ideas are welcome. I may have to take out the logic analyzer to try and rule out the CPU...
Juan