Jump to content
IGNORED

My first attempt at Programming


Atarius Maximus

Recommended Posts

Well, here's my first stab at writing a program for the 2600. It's a little program that lets you move a ship in all four directions around the screen. Weeeee! Ok, it's not much fun, but it's a start. :) I'm going to try and add a few things to it, maybe make the ship fire a missle, and add something to shoot at!

 

It's been a little while since I started working on this...I seem to remember piecing some of this info together from a tutorial on the internet, I can't exactly remember where it was though.

 

Anyway, the bin is attached at the bottom of this post.

 


processor 6502

include vcs.h

org $F000

YPosFromBottom = $80

VisibleShipLine = $81

ShipBuffer = $82 



Start  	

SEI

CLD  

LDX #$FF

TXS

LDA #0

ClearMem 

STA 0,X

DEX

BNE ClearMem

LDA #$00    

STA COLUBK

LDA #$1C    

STA COLUP0

LDA #80

STA YPosFromBottom

MainLoop

LDA #2

STA VSYNC

STA WSYNC

STA WSYNC 

STA WSYNC

LDA #43

STA TIM64T

LDA #0

STA VSYNC 

LDA #%00010000

BIT SWCHA 

BNE MoveDown

INC YPosFromBottom

MoveDown

LDA #%00100000

BIT SWCHA 

BNE MoveUp

DEC YPosFromBottom

MoveUp  

LDX #0

LDA #%01000000  

BIT SWCHA 

BNE MoveLeft

LDX #$10  

LDA #%00001000    

STA REFP0

MoveLeft

LDA #%10000000

BIT SWCHA 

BNE MoveRight

LDX #$F0  

LDA #%00000000

STA REFP0      

MoveRight

STX HMP0  

WaitForVblankEnd

LDA INTIM

BNE WaitForVblankEnd

LDY #191 

STA WSYNC

STA HMOVE 

STA VBLANK  



ScanLoop 

STA WSYNC 

LDA ShipBuffer  	

STA GRP0          	

CheckActivateShip

CPY YPosFromBottom

BNE ActivateShip

LDA #8

STA VisibleShipLine 

ActivateShip

LDA #0

STA ShipBuffer        

LDX VisibleShipLine  

BEQ FinishShip  

IsShipOn

LDA ShipGraphic-1,X  

STA ShipBuffer

DEC VisibleShipLine 

FinishShip

DEY

BNE ScanLoop

LDA #2

STA WSYNC  

STA VBLANK 

LDX #30

OverScanWait

STA WSYNC

DEX

BNE OverScanWait

JMP  MainLoop      

ShipGraphic

.byte #%10000000

.byte #%11100000

.byte #%01111000

.byte #%11111110

.byte #%11111110

.byte #%01111000

.byte #%11100000

.byte #%10000000

org $FFFC

.word Start

.word Start

movingship.zip

Link to comment
Share on other sites

Works Good.

That means alot coming from you! :D Thanks. I'll be working on it a little more this weekend, I'll update my results in a few days.

 

Just make sure to display one more scanline (currently 261) so that it will show some colors on PAL TVs too.

Heh, just shows I'm a complete newbie at this. I'll attempt to figure that out on my own, but tips are always welcome. :) ;)

 

AM

Link to comment
Share on other sites

Progress is slow. I've read through the Stella programming guide, but at my current level of skill, it doesn't explain things very well. I did figure out one thing though...Now when you press the joystick button, it places a vertical line on the screen that never disappears. At least I got it to do something! :D

 

movingship.jpg

 

processor 6502 

  include vcs.h 

  org $F000 

YPosFromBottom = $80 

VisibleShipLine = $81 

ShipBuffer = $82 



Start          

  SEI 

  CLD  

  LDX #$FF 

  TXS 

  LDA #0 

ClearMem 

  STA 0,X 

  DEX 

  BNE ClearMem 

  LDA #$00       

  STA COLUBK 

  LDA #$1C       

  STA COLUP0 

  LDA #80 

  STA YPosFromBottom 

MainLoop 

  LDA #2 

  STA VSYNC 

  STA WSYNC 

  STA WSYNC 

  STA WSYNC 

  LDA #43 

  STA TIM64T 

  LDA #0 

  STA VSYNC 

  LDA #%00010000 

  BIT SWCHA 

  BNE MoveDown 

  INC YPosFromBottom 

MoveDown 

  LDA #%00100000 

  BIT SWCHA 

  BNE MoveUp 

  DEC YPosFromBottom 

MoveUp       

  LDX #0 

  LDA #%01000000       

  BIT SWCHA 

  BNE MoveLeft 

  LDX #$10       

  LDA #%00001000       

  STA REFP0 

MoveLeft 

  LDA #%10000000 

  BIT SWCHA 

  BNE MoveRight 

  LDX #$F0       

  LDA #%00000000 

  STA REFP0           

MoveRight 

  STX HMP0 



  LDA INPT4  

  BMI ButtonNotPressed	

  LDA #2

  STA ENAM1	

  LDA #33

  STA COLUP1  

  LDA #$20

ButtonNotPressed

     

WaitForVblankEnd 

  LDA INTIM 

  BNE WaitForVblankEnd 

  LDY #191 

  STA WSYNC 

  STA HMOVE 

  STA VBLANK  



ScanLoop 

  STA WSYNC 

  LDA ShipBuffer        

  STA GRP0                

CheckActivateShip 

  CPY YPosFromBottom 

  BNE ActivateShip 

  LDA #8 

  STA VisibleShipLine 

ActivateShip 

  LDA #0 

  STA ShipBuffer                   

  LDX VisibleShipLine       

  BEQ FinishShip       

IsShipOn 

  LDA ShipGraphic-1,X       

  STA ShipBuffer 

  DEC VisibleShipLine 

FinishShip 

  DEY 

  BNE ScanLoop 

  LDA #2 

  STA WSYNC  

  STA VBLANK 

  LDX #30 

OverScanWait 

  STA WSYNC 

  DEX 

  BNE OverScanWait 

  JMP  MainLoop      

ShipGraphic 

  .byte #%10000000 

  .byte #%11100000 

  .byte #%01111000 

  .byte #%11111110 

  .byte #%11111110 

  .byte #%01111000 

  .byte #%11100000 

  .byte #%10000000 

  org $FFFC 

  .word Start 

  .word Start 

movingship2.zip

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