DEV Community

Draculinio
Draculinio

Posted on

Writing a NES game, day 14, newbie mistakes

One thing that I noticed in the game was that everything was running BUT in a separate way. So, everytime an event was launched you could see the other events freezing. So, you can see for a moment in the shooting stage that monsters freezed (for a short ammount of time). Not to talk about holding left or right buttons and everything was waiting me to release the button.

It was ALL caused because I had a NEWBIE **error. I was using JMP to move to subrutines. There is an especific instruction for that JSR (Jump to subrutine, the name is clear). JMP is just an unconditional jump, but the way to do this in the correct way is to use the correct jump instruction.
I noticed all this while spending **HOURS
breaking my code to see why all the freezing errors happened (also sometimes randomly the program itself was freezed), looking at the obvious place: the instructions table

It was like 1 am when the solution appeared and I could fix all (yes, this is making me go to bed really late).

Now the code is better with things like this:

engineplaying:
;read button
    LDA button

right: 
    CMP #%00000001
    BNE rightDone
    JSR moveRight
rightDone:

left: 
    CMP #%00000010
    BNE leftDone
    JSR moveLeft
leftDone:
Enter fullscreen mode Exit fullscreen mode

Tomorrow we have to talk about how the scrolling will happen in the near future.

Top comments (0)