Jump to content

Photo

Introduction: 2600 Programming for Newbies


165 replies to this topic

#151 SpiceWare ONLINE  

SpiceWare

    Quadrunner

  • 10,960 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Thu Jun 16, 2016 7:57 AM

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?
IMG_7334.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.

#152 tschak909 OFFLINE  

tschak909

    Stargunner

  • 1,592 posts
  • Location:USA

Posted Thu Jun 16, 2016 9:16 AM

At the end of the day, you're producing a stream of binary numbers that the 6502 executes, how you get them assembled into memory, is your business. ;)

 

-Thom



#153 BNE Jeff ONLINE  

BNE Jeff

    Moonsweeper

  • 279 posts
  • Location:Virginia, USA

Posted Fri Jun 17, 2016 7:33 AM

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?



#154 SpiceWare ONLINE  

SpiceWare

    Quadrunner

  • 10,960 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Fri Jun 17, 2016 9:00 AM

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.



#155 BNE Jeff ONLINE  

BNE Jeff

    Moonsweeper

  • 279 posts
  • Location:Virginia, USA

Posted Sat Jun 18, 2016 5:14 AM

Ughh..  Of course..  I was still stuck on that "hard coded to zero" thing I think.

 

Thanks!



#156 BNE Jeff ONLINE  

BNE Jeff

    Moonsweeper

  • 279 posts
  • Location:Virginia, USA

Posted Wed Jun 29, 2016 6:40 AM

Hi! I'm looking for the instructions for DASM.  I'm pretty sure its called dasm.txt.  I'm pretty sure I used to have it.  I'm pretty sure it came in the zip file for DASM.  Yet I can't seem to locate it in or find it online.  Can anyone please point me to it?



#157 tschak909 OFFLINE  

tschak909

    Stargunner

  • 1,592 posts
  • Location:USA

Posted Wed Jun 29, 2016 6:52 AM

Go grab a copy of dasm, it's small enough... :)

 

http://dasm.sourceforge.net/

 

-Thom



#158 BNE Jeff ONLINE  

BNE Jeff

    Moonsweeper

  • 279 posts
  • Location:Virginia, USA

Posted Wed Jun 29, 2016 7:33 PM

Thanks- I got a copy and am reading now..



#159 tschak909 OFFLINE  

tschak909

    Stargunner

  • 1,592 posts
  • Location:USA

Posted Wed Jun 29, 2016 8:15 PM

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.
 


#160 BNE Jeff ONLINE  

BNE Jeff

    Moonsweeper

  • 279 posts
  • Location:Virginia, USA

Posted Thu Jun 30, 2016 9:13 PM

Thanks..  I get it now..



#161 BNE Jeff ONLINE  

BNE Jeff

    Moonsweeper

  • 279 posts
  • Location:Virginia, USA

Posted Sat Jul 9, 2016 7:29 PM

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, Mon Jul 11, 2016 6:56 AM.


#162 BNE Jeff ONLINE  

BNE Jeff

    Moonsweeper

  • 279 posts
  • Location:Virginia, USA

Posted Mon Jul 11, 2016 6:55 AM

Wait..  That's not 20 cycles- more like 15 with the branch.   Still- is this a waste of cycles or is it ok?



#163 Rhindle the Dragon OFFLINE  

Rhindle the Dragon

    Space Invader

  • 43 posts
  • Moving in Silent Desperation
  • Location:Idaho

Posted Sun Dec 25, 2016 5:46 PM

The link to DASM on this site is broken. Someone might want to fix that...

Can someone point me toward a download of vcs.h and the other include files?



#164 SpiceWare ONLINE  

SpiceWare

    Quadrunner

  • 10,960 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Mon Dec 26, 2016 10:23 AM

I link to the current version in my tutorial, Collect.  You can find DASM here.  For some reason the include files are not included with the binaries, instead you'll have to source for DASM to get the include files.



#165 Alejandro10000 OFFLINE  

Alejandro10000

    Combat Commando

  • 2 posts
  • Location:Chihuahua, Chih. Mexico

Posted Tue Apr 11, 2017 5:29 PM

Hello, Im new here



#166 SignGuy81 OFFLINE  

SignGuy81

    Moonsweeper

  • 267 posts

Posted Mon May 8, 2017 7:50 PM

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, Mon May 8, 2017 8:15 PM.





0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users