Jump to content



1

Help debugging


8 replies to this topic

#1 DtY OFFLINE  

DtY

    Space Invader

  • 23 posts

Posted Thu Jan 1, 2009 12:43 PM

My program should start by clearing all the ram, then display a black screen, and every twenty frames increment the colour counter, the code was based on the 2600 for newbies tutorials, the one that changed the background colour every scanline, and the one that showed the play field and changed it every twenty frames.

What it does do:
I start the game up, and it goes to a blank screen, I go into stella's debugger, and it shows that none of the memory was cleared, and y is not counting the time until the next frame.

y is used to count how many frames have gone by since the last change, $80 in memory is used to store the current colour, a and x are used for various other tasks throughout the program.

Attached are the original assembler source code, and what I got when I compiled it (both were given a .txt extension as the forum would not let me upload them without)

Also, people seem to just include vcs.h and macro.h and not think anything about it? When I try that I get an error that the file doesn't exist and have to copy them into the same directory, is there a global include path for dasm somewhere I can put them? (I am on fedora core linux, btw)

Attached Files



#2 Wickeycolumbus OFFLINE  

Wickeycolumbus

    River Patroller

  • 4,063 posts
  • Location:Michigan

Posted Thu Jan 1, 2009 1:16 PM

You forgot to set your interrupt vectors at the end of the program like this:



	org $FFFA
	.word Reset
	.word Reset
	.word Reset

also you made a few simple mistakes in your code. For example:

VerticalBlank
	ldx #0
	inx
	cpx #37
	bne VerticalBlank

this is an infinate loop because the 'ldx #0' should be out of the VerticalBlank Loop

and at the top when you start the frame I changed

	lda #0
	sta VBLANK
	lda #2
	sta WSYNC
	sta WSYNC
	sta WSYNC
	lda #0
	sta VSYNC

to

	lda #2
	sta VBLANK
	sta VSYNC

	sta WSYNC
	sta WSYNC
	sta WSYNC

	lda #0
	sta VSYNC

Hope this helps! Here is a fixed source and binary. BTW, if you want to post source code, you should zip it so you dont have to change the extension.

Attached Files



#3 DtY OFFLINE  

DtY

    Space Invader

  • 23 posts

Posted Thu Jan 1, 2009 2:52 PM

Okay, great, thank you. Just, now there are black bars flickering all over, and when I replace that block with the code you gave me, it shows nothing, I checked, and the memory is changing properly, but the background is staying black. When I ran the example you sent me, it worked fine.

Also, what exactly do the interrupt vectors do? All I can gather is they insert $F000 three times at $FFFA, I'm guessing that's to insert nulls for the rest of the cartridge, but why three?

[edit] Forgot to upload what I had

Attached Files


Edited by DtY, Thu Jan 1, 2009 2:56 PM.


#4 Wickeycolumbus OFFLINE  

Wickeycolumbus

    River Patroller

  • 4,063 posts
  • Location:Michigan

Posted Thu Jan 1, 2009 3:09 PM

View PostDtY, on Thu Jan 1, 2009 3:52 PM, said:

Also, what exactly do the interrupt vectors do? All I can gather is they insert $F000 three times at $FFFA, I'm guessing that's to insert nulls for the rest of the cartridge, but why three?

They point to a certain ROM location that the processor will jump to if it gets interrupted. Also, the second vector points to where you want the processor to start the program (it does not have to be at $F000, many games start elsewhere).

Im not sure why your program has black bars on the top left, I will analyze your source further later on. Welcome to AA by the way!

#5 Wickeycolumbus OFFLINE  

Wickeycolumbus

    River Patroller

  • 4,063 posts
  • Location:Michigan

Posted Thu Jan 1, 2009 3:27 PM

I forgot to tell you, add this:

	ldx #0
	stx VBLANK   ;Add this line.  you must store a 0 to VBLANK to enable display
Picture

and to get rid of the black lines at the top left, do this:

	ldx #0
VerticalBlank
	sta WSYNC
	inx
	cpx #36	 ; change from 37 to 36
	bne VerticalBlank

then at label 'NotYet'

NotYet
	lda $80
	sta COLUBK
  
	sta WSYNC	 ;add this line

Hope it works for you!

Attached Files



#6 DtY OFFLINE  

DtY

    Space Invader

  • 23 posts

Posted Thu Jan 1, 2009 3:28 PM

Before I replaced the block of code you gave me, the one right after StartOfFrame, I had black bars that flickered all over horizontally, then I replaced the block with what you gave me, it showed nothing at all, however the one you gave me worked. (I'll go through line by line and see if I can find the problem though)

And thanks

[edit] I'll try that stuff you jsut posted :)

Edited by DtY, Thu Jan 1, 2009 3:28 PM.


#7 DtY OFFLINE  

DtY

    Space Invader

  • 23 posts

Posted Thu Jan 1, 2009 3:30 PM

Okay, it works, thank you very much

#8 Wickeycolumbus OFFLINE  

Wickeycolumbus

    River Patroller

  • 4,063 posts
  • Location:Michigan

Posted Thu Jan 1, 2009 3:32 PM

View PostDtY, on Thu Jan 1, 2009 4:30 PM, said:

Okay, it works, thank you very much

No problem :)

#9 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Thu Jan 1, 2009 3:33 PM

AFAIK, the NMI vector (at $xFFA-B) is not used by the 2600. You can use these 2 bytes for whatever you want (or keep them unused along with the previous 2 bytes to provide unmodded Supercharger-compatability). If BRK interrupts are not used by the program, the interrupt vector ($xFFE-F) can also be used for something else if you wish (or kept unused for the SC-compatability). All a general program needs is the cold start vector ($xFFC-D) to lead it to the ram clear routine. Common practice among early programs was to fill unused vectors with the cold start address, but there is no need to follow it. You can also save a good deal of space if you set an often-called subroutine as the interrupt (as described by Thomas at the top of The Dig's programming guide).




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users