deepak wrote:
Code:
.org $0300
Sprite1_Y: .db 20 ; rear
Sprite1_T: .db 1 ; part
Sprite1_S: .db 0 ; of
Sprite1_X: .db 20 ; car
Sprite2_Y: .db 20 ; front
Sprite2_T: .db 2 ; part
Sprite2_S: .db 0 ; of
Sprite2_X: .db 21 ; car
Hum... for a start, you can't .db stuff in RAM. whatever you want to put in $0000-$07FF (RAM) must be copied from ROM (wich starts at $8000) with code, it can't just be defined there. You could define this just as you're doing it now, but somewhere in ROM. Then you can just read this data and copy to RAM at $0300.
There are a couple of other things wrong with the code:
1. you are not waiting for VBlanks anywhere in the code. It is important, for example, to wait at least 2 VBlanks before doing any PPU operations, because it takes it some time to be ready for use.
2. you are doing all PPU operations with rendering on (bits 3 and 4 of $2001). You can't do most PPU operations while it's rendering. So you should either wait for VBlank before sending stuff to the PPU (if you know your writes will not go beyond VBlank time) or disable rendering altogether (clear bits 3 and 4 of $2001) so that you have all the time in the world to do whatever you want, and when you're done, then you enable rendering.
3. it is good practice to start you code with SEI (to disable interrupts) and CLD (disable decimal arithmetics), just to be safe. It is also good practice to initialize the stack with $FF right in the beginning of the program.
I guess this is it for now. Once you add a background to this program, don't forget to set $2005 correctly befeore enabling rendering (and preferably every frame after that), so that your picture stays steady.