arkleyjoe Posted April 4, 2017 Share Posted April 4, 2017 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 Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted April 4, 2017 Share Posted April 4, 2017 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. Quote Link to comment Share on other sites More sharing options...
Just Jeff Posted April 20, 2017 Share Posted April 20, 2017 (edited) 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 April 20, 2017 by BNE Jeff Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.