Jump to content
IGNORED

Newbie struggling -> looking for some clarification on YPOS.


Recommended Posts

Hi,

 

I am a reasonably experienced developer but totally new to ASM and making games for Atari 2600.

 

I have decided to tackle this as a bit of a challenge. I specifically want to focus on ASM rather than bB.

 

I seem to be getting on "ok" with the complex stuff but I am really struggling to visualise how to handle Vertical Positioning. It should be simple enough. I have a hundred examples of working code I can make work but I am not sure I completely understand how the code works.

 

Can someone help clarify I am on the right track here.

 

Here is what I think is going on:

 

*Lets assume my sprite is 20 lines high.

*Lets assume my YPos0 is 80 (from the bottom of the screen)

 

-- I am looping down through my 192 visible scan lines.

-- On each scan line I am checking of see if we have reached the line where I would like to start to display my sprite.

-- i.e 80+20 being the top of my sprite and 80+1 being the last line.

-- On each of the lines where my sprite intersects the scan line I set the relevant value to GP0 and then when we reach line 79 I set it back to empty.

 

For some reason in the examples I am working from I can not ever see the calculation / test I am expecting.

 

in pseudo code I am expecting to see:

 

if the Current Scanline is equal to or less than YPos0 + Spright Height and Current Scanline is equal to or greater then YPos0 then DRAW THE SPRITE.

 

Here is one example I have found of code I have running and working but do not understand.

; Get next bitmap byte of sprite 0
        MAC DRAW_SPRITE0
	sec			; ensure carry set for subtraction
	lda #SpriteHeight
        INC YP0
        SBC YP0
        ;isb YP0                 ; INC yp0, then SBC yp0
        tay
        bcs .DoDraw             ; outside bounds?
	lda #0			; clear bitmap
	.byte $2c               ; (BIT aaaa, skips next 2 bytes)
.DoDraw
        lda (SpritePtr0),y	; lookup sprite bitmap
        sta GRP0		; A -> GRP0
        ENDM 

Any pointers hugely appreciated, sorry if I have made something simple really convoluted, but it is just not going in to my brain.

 

X position on the other hand, seems simple despite the need to position and then fine position.

 

Joe

 

 

 

Link to comment
Share on other sites

I put rather detailed comments in my Collect series, way more than I normally would due to it being a tutorial. The Y positioning happens in Step 4, though I would recommend you start from the beginning with Let's Make a Game! as it explains the goals.

 

Do note that the blog entries are listed newest first, so you'll have to go to the bottom of page 2 for the start.

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

 

I am a reasonably experienced developer but totally new to ASM and making games for Atari 2600.

 

I have decided to tackle this as a bit of a challenge. I specifically want to focus on ASM rather than bB.

 

I seem to be getting on "ok" with the complex stuff but I am really struggling to visualise how to handle Vertical Positioning. It should be simple enough. I have a hundred examples of working code I can make work but I am not sure I completely understand how the code works.

 

Can someone help clarify I am on the right track here.

 

Here is what I think is going on:

 

*Lets assume my sprite is 20 lines high.

*Lets assume my YPos0 is 80 (from the bottom of the screen)

 

-- I am looping down through my 192 visible scan lines.

-- On each scan line I am checking of see if we have reached the line where I would like to start to display my sprite.

-- i.e 80+20 being the top of my sprite and 80+1 being the last line.

-- On each of the lines where my sprite intersects the scan line I set the relevant value to GP0 and then when we reach line 79 I set it back to empty.

 

For some reason in the examples I am working from I can not ever see the calculation / test I am expecting.

 

in pseudo code I am expecting to see:

 

if the Current Scanline is equal to or less than YPos0 + Spright Height and Current Scanline is equal to or greater then YPos0 then DRAW THE SPRITE.

 

Here is one example I have found of code I have running and working but do not understand.

; Get next bitmap byte of sprite 0
        MAC DRAW_SPRITE0
	sec			; ensure carry set for subtraction
	lda #SpriteHeight
        INC YP0
        SBC YP0
        ;isb YP0                 ; INC yp0, then SBC yp0
        tay
        bcs .DoDraw             ; outside bounds?
	lda #0			; clear bitmap
	.byte $2c               ; (BIT aaaa, skips next 2 bytes)
.DoDraw
        lda (SpritePtr0),y	; lookup sprite bitmap
        sta GRP0		; A -> GRP0
        ENDM 

Any pointers hugely appreciated, sorry if I have made something simple really convoluted, but it is just not going in to my brain.

 

X position on the other hand, seems simple despite the need to position and then fine position.

 

Joe

 

 

 

 

If you are looking to dive into Assembly, I also suggest Assembly In One Step http://atariage.com/2600/programming/2600_101/docs/onestep.html . You can get a basic grasp of assembly in a weekend.

 

bcs is the test you are looking for above. Are you familiar with the processor status register? When a math result (from your sbc) causes the carry flag to be set in that register, the program takes the branch and loads your graphics. If your carry flag is not set, the program proceeds to that strange .byte $2c. That's a trick that makes your program skip over the following lda. Therefore, the previously loaded zero stays in your accumulator and that's what gets stored in the graphics register instead.

 

Also, this is a good reference to bookmark http://www.6502.org/tutorials/6502opcodes.html#WRAP

Edited by BNE Jeff
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...