Jump to content



0

Need my code scrutinized >.>


28 replies to this topic

#26 SeaGtGruff OFFLINE  

SeaGtGruff

    River Patroller

  • 4,544 posts
  • Location:Georgia, USA

Posted Wed Apr 7, 2010 8:30 PM

View Postjohnon, on Wed Apr 7, 2010 8:28 PM, said:

Wow, this got a bit off-topic, lol. :D

EDIT: Very informative post, though, I must say. ^^
LOOK OUT, EVERYBODY... D E R A I L E D !!!

Michael

#27 johnon OFFLINE  

johnon

    Chopper Commander

  • 241 posts
  • Aspiring 2600 Developer
  • Location:South Carolina, US

Posted Wed Apr 7, 2010 9:09 PM

Okay...

Really, though. Can no one tell me what I'm doing wrong? I understand it can be re-written at will to work by most of you. Rewriting it without explaining doesn't teach me anything. I still will make the same mistakes because I didn't realize that they were mistakes. I need to know what I'm doing wrong, specifically, so I can learn from it.

#28 Omegamatrix OFFLINE  

Omegamatrix

    River Patroller

  • 4,795 posts
  • Location:Oh, Canada

Posted Wed Apr 7, 2010 11:07 PM

One thing I noticed was your pointers weren't being loaded correctly. Specifically, you had it right that the address need 2 bytes of ram. However the high byte was not being loaded correctly into ram. Look at yours and Chris's on top of each other:


debugger.PNG


Okay I did a list file on Chris's to show you the address that should be loaded. I'm not going to show the whole thing as it's too long!

    278  f122				   WhalemanDeadWater
    279  f122
    280  f122		       60 66		      .byte.b	#<WhalemanDeadWater1,#<WhalemanDeadWater2
    281  f124
    282  f200		       00 00 00 00*	      ALIGN	256
    283  f200
    284  f200				   Sprites
    285  f200
    286  f200				   WhalemanLeftWater1
    287  f200
    288  f200		       70		      .byte.b	%01110000
    289  f201		       f8		      .byte.b	%11111000
    290  f202		       7c		      .byte.b	%01111100
    291  f203		       3e		      .byte.b	111110
    292  f204		       55		      .byte.b	%01010101
    293  f205		       aa		      .byte.b	%10101010

....

    304  f20c				   WhalemanRightWater1
    305  f20c
    306  f20c		       0e		      .byte.b	001110
    307  f20d		       1f		      .byte.b	011111
    308  f20e		       3e		      .byte.b	111110
    309  f20f		       7c		      .byte.b	%01111100
    310  f210		       aa		      .byte.b	%10101010
    311  f211		       55		      .byte.b	%01010101

So Chris used "ALIGN 256" to start the graphics on a new page. Now you can see that "WhalemanLeftWater1" starts at $F200 and "WhalemanRightWater1" starts at $F20C.


The thing you got to know is how these addresses are stored in ram. It's low byte, high byte. So $F20C would look like $0C $F2 instead of $F2 $0C. If you want to use a "LDA (someGfxPtr),Y" it expects the pointer to be low byte then high byte. That link I gave you on addressing modes should talk about this more.


To tell the compiler which byte is which do this:

LDA #<WhalemanLeftWater1 ; low byte, #$00 in this case
STA someGfxPtr
LDA #>WhalemanLeftWater1 ; high byte, #$F2 in this case
STA someGfxPtr+1

Now Chris just loaded the high byte once and stored them into ram for all the pointers. That's the beauty of having all the gfx on the same page. The high pointer is the same for all of them. Your gfx was all in the same page too, but without an ALIGN or ORG statement they will shift around as you write new code. You don't want that as you could potentially cross a page boundary, for one thing.


Anyhow I would start with Chris's code and really try to understand it. Also try adding a little bit of code at a time and test it as you go instead of trying the whole thing at once.

#29 cd-w OFFLINE  

cd-w

    Stargunner

  • 1,195 posts
  • Juno First!
  • Location:Glasgow, UK

Posted Thu Apr 8, 2010 1:06 AM

View Postjohnon, on Wed Apr 7, 2010 9:09 PM, said:

Okay...
Really, though. Can no one tell me what I'm doing wrong? I understand it can be re-written at will to work by most of you. Rewriting it without explaining doesn't teach me anything. I still will make the same mistakes because I didn't realize that they were mistakes. I need to know what I'm doing wrong, specifically, so I can learn from it.

Problems that I found:
  • The code segment was not set (SEG CODE) so the binary size was zero
  • The frame timings were incorrect (for the vertical blank and overscan areas) - I added macros to take care of these
  • The high byte of the graphics pointers was not set - pointers are 2 bytes long
  • The animation counter was a constant and not a variable
  • The sprite data needs to be updated on every line of the screen where you want to display it (search the forums for "skipdraw" for more details)
  • You can't update the playfield after the sprites - everything must be updated on the correct scanline and you have 76 cycles per scanline to do everything
  • The sprite repositioning code must not cross a page boundary (I added an ALIGN 256)
I think it would be a good idea to start with a single sprite and update the code a little bit at a time until it does what you want.

Chris




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users