Jump to content
IGNORED

Introduction: 2600 Programming for Newbies


Recommended Posts

OK.. I see that .byte is not the command... Now it seems like it is a way to trick DASM, not the 6502. I'd think that DASM could just allow the command but I'm sure there is a reason it doesn't.

It would lead to hard to find bugs if you accidentally put in an instruction without the operand and the compiler didn't complain. A warning would work, but over time you'd learn to ignore those warnings. By doing it via .byte you're basically saying "yes, I know what I'm doing isn't normal, but I'm doing it anyway".

 

So indirect addressing means the operand is the location where the location of the data is stored? I hope that's right because I've been having a hard time with that stuff. I have immediate addressing down pretty good though!

Correct, it's the location of the location.

 

I am still thrown off by the sbc #0. This looks like "subtract zero" to me, and not "make it zero".

That's exactly what it is, subtract zero. Remember learning subtraction back in grade school?

post-3056-0-55579400-1466084666_thumb.jpg

 

You had to manually keep track of the "1" you needed to borrow when doing the ones column subtraction so that when you did the tens column the 2-0 became 2-1-0.

 

The 6507 is doing the same thing, but at a byte level instead of a ones or hundreds position. If the SBC needed to do a borrow it denotes it via the carry flag. The status of the carry flag tells the next SBC if it needs to do an extra "-1" to make up for a borrow.

Link to comment
Share on other sites

OK, I do see now that you said that you hard coded zero as the MSB for object Y , not Player0Ptr+1. That threw me off a bit.

 

Sorry about this. I know I'm not asking clearly enough, or I'm missing the answer. But could I ask the remaining part of the question using your example, if you still have the patience? Thanks for the help with this- I really appreciate it.

 

Instead of:

 

20

- 03

-------

17

 

We are doing (in the code- SBC #0) for the MSB:

 

20

- 0

------

20

 

As far as I can tell, this always keeps the MSB of Player0Ptr+1 the same. Also, I don't think it would affect the carry flag; that subtracting 0 would never affect the carry flag.

 

More concisely- I looks to me like SBC #0 is doing nothing and could be removed from the program and have no effect. What is it doing?

Link to comment
Share on other sites

To translate my example of 20-3 to 16 bit math you need to consider the 0 (from the 20) and the 3 as the LSB values and the 2 and the 0 (implied with the 3) as the MSB values. The LSB subtraction of 0-3 is done first and triggers a carry, which causes the MSB subtraction of 2-0 to do an extra -1 as part of its calculation.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

you use ds in byte, word, or double word increments (1, 2, 4 bytes a piece), if you need a set of variables, define them:

 

 

 
        SEG.U VARS
        ORG $80
 
 
Frame:          ds 1            ; Frame counter.
ScanLine:       ds 1            ; scanline counter
PlayerY0:       ds 1            ; Player Y0
PlayerY1:       ds 1            ; Player Y1
BallY0:         ds 1            ; ball y0
BallY1:         ds 1            ; missile y0
BallY2:         ds 1            ; missile y1
Score:          ds 1            ; Score
Timer:          ds 1            ; Timer
DigitOnes:      ds 2            ; Player 0 and 1 digit graphics
DigitTens:      ds 2            ; Player 0 and 1 digit graphics
ScoreGfx:       ds 1            ; pointers
TimerGfx:       ds 1            ; pointers
Temp:           ds 1            ; Temp
TempStackPtr:   ds 1            ; Temporary Stack Pointer
GameState:      ds 1            ; store game state (BIT tested)
Temp2:          ds 1            ; another temp value
ColorCycle:     ds 1            ; Color cycling temp value (attract mode)
JoystickStates: ds 1            ; Joystick states.
P0XVelocity:    ds 1            ; P0 X Velocity
P1XVelocity:    ds 1            ; P0 Y Velocity
P0YVelocity:    ds 1            ; P1 X Velocity
P1YVelocity:    ds 1            ; P1 Y Velocity
P0XIsWaiting:   ds 1            ; P0 X is Waiting (BIT 7)
P1XIsWaiting:   ds 1            ; P1 X is Waiting (Bit 7)
P0YIsWaiting:   ds 1            ; P0 Y is Waiting (BIT 7)
P1YIsWaiting:   ds 1            ; P1 Y is Waiting (BIT 7)
VelocityTemp:   ds 1            ; used for velocity unpacking.
VelocityFlip:   ds 1            ; used to flip velocity values.
WaitingTemp:    ds 1            ; Waiting index temp between frames.
 
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Hello..

 

I stuck this routine in my kernal to draw the ball. Is it efficient enough (20 cycles) or should I do something else? Same question for missiles:

 

 

Ball:
lda #BALL_HEIGHT-1 ; 2 2
dcp BallDraw ; 5 7
bcs DoDrawBall ; 2 9
lda #0 ; 2 11
.byte $2C ; 4 15

DoDrawBall: ;
lda #2 ; 2 17
sta ENABL ; 3 20

Thanks!

Edited by BNE Jeff
Link to comment
Share on other sites

  • 5 months later...
  • 3 months later...
  • 4 weeks later...

I'm tempted to start an interactive course/dialog to help newcomers to '2600 programming get up and running. Just wondering how many people would follow such a happening.

 

* If you would be interested in participating, post a reply to this

* What particular areas of progamming would you like to see covered

* what level of knowledge should be assumed

* any comments?

 

My tentative title for the course would be "000001010 00101000 00000000 01100101" - 10 points to the first person who can tell me what on earth this means icon_smile.gif

 

Cheers

A

This is very old post but thought I'd take my stab at it. I came up with 6502 8A. I guess 8A for 8-bit architecture? The 101 kept throwing me off at the end I kept thinking it was going to be like every other course with 101 on the end of it so figured there must be significance in it but couldn't get anything else in front that made sense. I converted each set to decimal for 10 40 0 101, once I had the last set at 101 I figured I needed to convert the first 3 sets which I tried everything, and couldn't come up with nothing, so I then converted all to hex for A 28 0 65 and figured if I read from right to left to get 65028A which I'm assuming is for the 6502 processor and 8A being that it is 8 bit architecture. Am I even close?

 

EDIT:

I guess the A could also stand for "assembly"?

Edited by SignGuy81
Link to comment
Share on other sites

  • 1 month later...

This is very old post but thought I'd take my stab at it. I came up with 6502 8A. I guess 8A for 8-bit architecture? The 101 kept throwing me off at the end I kept thinking it was going to be like every other course with 101 on the end of it so figured there must be significance in it but couldn't get anything else in front that made sense. I converted each set to decimal for 10 40 0 101, once I had the last set at 101 I figured I needed to convert the first 3 sets which I tried everything, and couldn't come up with nothing, so I then converted all to hex for A 28 0 65 and figured if I read from right to left to get 65028A which I'm assuming is for the 6502 processor and 8A being that it is 8 bit architecture. Am I even close?

 

EDIT:

I guess the A could also stand for "assembly"?

 

 

I went back through and seen someone else put "2600 101" and was trying to figure out how to come to that conclusion. I didn't realize that 0000000 would stand for a space when I was originally trying to figure it out. So now I see where 2600 comes from by converting the 00001010 00101000 to binary you have 2600. At first I tried each set separate and all three together except the last which I new was 101 and for the life of me couldn't figure out where the 2600 came from, until earlier converting just the first two sets together, not understanding before that the 00000000 was supposed to be a space. Now that that is said and done though I think that was neat that I was able to come up with what I came up with above in the post I just quoted as well. Worked out kinda cool imo :)

Edited by SignGuy81
Link to comment
Share on other sites

  • 4 months later...
  • 1 month later...
  • 3 months later...

I'm tempted to start an interactive course/dialog to help newcomers to '2600 programming get up and running. Just wondering how many people would follow such a happening.

 

* If you would be interested in participating, post a reply to this

* What particular areas of progamming would you like to see covered

* what level of knowledge should be assumed

* any comments?

 

My tentative title for the course would be "000001010 00101000 00000000 01100101" - 10 points to the first person who can tell me what on earth this means icon_smile.gif

 

Cheers

A

 

I'm tempted to start an interactive course/dialog to help newcomers to '2600 programming get up and running. Just wondering how many people would follow such a happening.

 

* If you would be interested in participating, post a reply to this

* What particular areas of progamming would you like to see covered

* what level of knowledge should be assumed

* any comments?

 

My tentative title for the course would be "000001010 00101000 00000000 01100101" - 10 points to the first person who can tell me what on earth this means icon_smile.gif

 

Cheers

A

 

I'm tempted to start an interactive course/dialog to help newcomers to '2600 programming get up and running. Just wondering how many people would follow such a happening.

 

* If you would be interested in participating, post a reply to this

* What particular areas of progamming would you like to see covered

* what level of knowledge should be assumed

* any comments?

 

My tentative title for the course would be "000001010 00101000 00000000 01100101" - 10 points to the first person who can tell me what on earth this means icon_smile.gif

 

Cheers

A

Yeah I am interested.

Edited by Pixel Toad
Link to comment
Share on other sites

  • 1 year later...
On 7/9/2016 at 8:29 PM, BNE Jeff said:

I stuck this routine in my kernal to draw the ball...

That routine is not cycle-exact...taking 15 cycles when drawing, but 18 when not.

 

Try this:


Ball:
  lda #BALL_HEIGHT-1  ; 2 2
  dcp BallDraw       ; 5 7
  lda #1             ; 2 9
  bcs DoDraw Ball     ; 2 11
  .byte $24          ; 3 14 BIT.$zp
DoDrawBall: ;@12
  asl                ; 2 14 A=2
  sta ENABL          ; 3 17

17 cycles for both cases.

  • Like 1
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...