Jump to content
IGNORED

ClearMem and general gfx question


Grimasso

Recommended Posts

Hi!

 

So heres another lunatic trying to code on the VCS 2600 :) ... I tried out some samples and tutorials and stumbled across an often usen routine which is (seemingly) used to initialize/clear the RAM:

 

 ...
   LDX #$FF
   TXS
   LDA #0

ClearMem
   STA 0,X
   DEX
   BNE ClearMem

 

If I understand this correctly, this "X loop" is used to zero all memory from $FF to $00.

First question: What is TXS good for?

Second question: Why FF to 00? I read that "user RAM" starts at $80. Isn't it dangerous to clear everything down to $00 ? I guess theres lots of system stuff "down there" getting zeroed by this...

 

And finally a generell question about how to implement graphics on the 2600:

As I got it theres no such thing like a graphics buffer to put pixels in but rather I have to follow the television beam in a synchronized way and change background colors to create graphics line by line...(yikes!) Is that right?

Why did they implement those missile/player gfx stuff?! Whats the difference between/advantange in setting the background colors while following the beam and putting the "missile"/"playersprite" somewhere?

 

Greetings and happy coding...

Link to comment
Share on other sites

I believe running through the whole set while make sure no sounds are going sprites are empty, etc. There's not much you can do to mess up a 2600. So clearing everything is quick and easy, so practically everyone does it. Programming is very different on the 2600. It's not exactly true that there is no graphics buffer. It's just set up in an unusual way. Both players have a 1 byte buffer. This is displayed at a specific location on a line. However the system doesn't know what line it's on, so you must enable and disable the sprite on each line. If you wanted to create a pong game there is relatively little you must do. The system will tell you if there is a collision, you simply have to poll an address. If your player is a 1 by 8 picture, you don't have much work to do on the graphics either. The racing the beam comes in when you try to cheat the system. If you want to have more than two different sprites on one line you need to start using tricks. Or if you want to re position a sprite between different lines then you need to pay close attention to where you are on an individual line. But these things are only necessary if you want the system to do more than the original designers intended, which 95% of the games did. An excellent way to start is in the newbie section there are tutorials by andrew.

Link to comment
Share on other sites

First question: What is TXS good for?

That bit sets the stack pointer to the bottom of the VCS ram, #$ff, where it should start.

 

Second question: Why FF to 00? I read that "user RAM" starts at $80. Isn't it dangerous to clear everything down to $00 ? I guess theres lots of system stuff "down there" getting zeroed by this...

Ever turn on a VCS without a game in it and see random stripes? TIA doesn't have a guaranteed initial state, and setting the color registers to black, setting sound to silent, etc., is a good thing.

 

Why did they implement those missile/player gfx stuff?! Whats the difference between/advantange in setting the background colors while following the beam and putting the "missile"/"playersprite" somewhere?

 

The 6502 is much too slow to update the screen at a reasonable resolution with just color changes, so you use players and missiles for "high" resolution.

Link to comment
Share on other sites

That bit sets the stack pointer to the bottom of the VCS ram, #$ff, where it should start.

 

Hm, does that mean the stack grows "backwards" from $ff down to $80 ?!

 

Thanks for your very interesting comments. Its really exciting to dig into this stuff that was such an astonishing wonder of science back in those days :D

Link to comment
Share on other sites

Hm, does that mean the stack grows "backwards" from $ff down to $80 ?!

Yes.

In the 6502 processor the stack is on page 1 ($100-$1FF) and the stack pointer register contains the low byte of the first available stack memory address (the high byte is always 1). In the VCS, the address range $100-$1FF is a mirror of $00-$FF and only the upper 128 bytes are RAM, while the lower addresses are TIA registers. You have to keep count of the max amount of ram the stack uses in your game to avoid it from overwriting the one allocated for variables.

Link to comment
Share on other sites

That bit sets the stack pointer to the bottom of the VCS ram, #$ff, where it should start.

 

The pointer can have other uses as well. You could reset the pointer to a hardware register to have processor status automatically enable/disable the ball or a missile when pushed via PHP following a scanline count comparison. Or use the stack pointer itself as an additional byte of ram memory if you have none to spare.

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