6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 2:51 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Fri Jul 01, 2016 1:23 pm 
Offline
User avatar

Joined: Wed Aug 17, 2005 12:07 am
Posts: 1250
Location: Soddy-Daisy, TN USA
Maybe this is a crazy idea...but I was thinking.

I want to use a TMS9918 in a SBC that I'm working on. But I will try to implement SRAM instead of DRAM (using latches). I would use a 512K SRAM (55ns).

The TMS9918 only addresses 16K of RAM. So I thought, what if I used a 65C22 to bank switch multiple 16K blocks?

The TMS9918 would only know about 16K but during vertical blanking, I could use the VIA to swap out the banks.

I was thinking the TMS9918 (VDP) would connect to the first 16K using A0:A13.

The VIA would then connect through PORT A from A14:A18. My ROM would set the DDRA to out for the pins. Then, it would be a matter of poking $00 for the first 16K of RAM, $01 for the second 16K, etc. All the way up to 32 banks.

I know there would be a few issues with this already. One, the programmer would need to make sure to only change the bank during vertical blanks or there would be shearing on screen.

Also, I'm not sure yet what would happen if the VDP was reading/writing a bunch of addresses and then I suddenly changed the banks. Perhaps I would have to put some glue logic in to only change banks at a certain time.

What are your thoughts?

The idea of page flipping 32 different ROM banks for a TMS is exciting. This would literally allow you to have smooth scrolling because you could copy the font set in all 8 directions and just toggle between them.

_________________
Cat; the other white meat.


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 01, 2016 2:39 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
I'm no TMS9918 expert, but your idea for swapping memory banks sounds workable. As noted, you'd have to be careful about when the swaps occur, and it seems you're on top of things there. But I don't see the smooth scrolling idea as being so easy. Isn't it true that you'd need fonts that contained every possible combination of the incoming and outgoing character?

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 01, 2016 3:35 pm 
Offline
User avatar

Joined: Wed Aug 17, 2005 12:07 am
Posts: 1250
Location: Soddy-Daisy, TN USA
Dr Jefyll wrote:
Isn't it true that you'd need fonts that contained every possible combination of the incoming and outgoing character?


You would need X number of copies of the entire font. For example, if you want to scroll horizontally only, then you would need four copies of the font. That would give you 2 pixel movements.

This is a common practice on other computers too like the C64. But having 512K allows a lot of copies. 32 of them. :-)

So you can afford to be a little wasteful.

_________________
Cat; the other white meat.


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 01, 2016 5:34 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
I'm not a C64 expert either, but I think I follow you now. I found a site that talks about C64 smooth scrolling, and learned that "the VIC-II chip has two hardware scroll registers, one horizontal, one vertical."

I gather there are various ways to use the registers. The technique described on the site
uses hardware scrolling to manage 7 out of 8 shifts, then for the 8th a block-move is needed. To meet timing constraints, the block move happens in pieces and in advance. "we need to implement double buffering. We’ll reserve another 1000 byte block in RAM to be our back buffer. This allows us to shift screen data at any time, because we are writing to the back buffer, not the visible screen." Interesting! :) Is this the technique you're referring to?

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Last edited by Dr Jefyll on Fri Jul 01, 2016 5:47 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 01, 2016 5:43 pm 
Offline
User avatar

Joined: Wed Aug 17, 2005 12:07 am
Posts: 1250
Location: Soddy-Daisy, TN USA
Yes, that's essentially it.

However, the TMS9918 doesn't support any hardware scrolling. So it's faked by storing multiple copies of the same characters but each is shifted in a certain direction.

If you have the ability to instantly point to a different copy, you give the illusion of scrolling. But in reality, nothing is moving.

For example, if you had a character like so (only one line for brevity):

Code:
ZZOOOOXX


You then store the extra copies like:

Code:
ZOOOOXXZ
...
OOOOXXZZ
...
OOOXXZZO
...


Anyway, this is all theory because I don't know how the TMS would respond to changing its memory like that. I don't know of any system that has ever done this with a TMS.

_________________
Cat; the other white meat.


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 01, 2016 6:08 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
Say you have an "H" and an "I" side by side, and each is 8 pixels wide. It seems to me the scan line passing through the middle, for example, needs to show:
Code:
01111110 00001000, then...
11111100 0001000?, then...
11111000 001000??, then...
11110000 01000???, then...
... and so on. (The question-mark is for bits arriving from even further over, to the right of the "I".

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 01, 2016 9:01 pm 
Offline
User avatar

Joined: Wed Aug 17, 2005 12:07 am
Posts: 1250
Location: Soddy-Daisy, TN USA
Yeah, I think you got it.

A classic example of this is a bullet sprite, for example.

Code:
0 0 0 0 0 0 0 0
0 0 0 1 1 0 0 0
0 0 1 1 1 1 0 0
0 0 0 1 1 0 0 0
0 0 0 0 0 0 0 0


If you draw this at any given position, you will see it as:

Code:
. . . • . . .


Then, you can shift the pixels for that character. But, this takes CPU time. If you pre-shift it and just change the pointer to it, then it takes almost no CPU. But it costs you RAM.

So the bullet sprite shifted could look like:

Code:
0 0 0 0 0 0 0 0
0 0 0 0 0 1 1 0
0 0 0 0 1 1 1 1
0 0 0 0 0 1 1 0
0 0 0 0 0 0 0 0


Which, when drawn in the SAME spot, appears to have moved over 2 pixels to the right.

Of course, there are other trade-offs. Like the pixels behind the bullet. On some games you can see this effect because it looks like the bullet has a black box around it. But it moves so fast it's no problem.

This technique is better used for background graphics. You draw a large area once. Then, swap the font out for the pre-shifted fonts. So it appears the background is moving. But your FOREGROUND chars stay the same in each copy. So they are not pre-shifted. This effect gives the illusion of a parallax scroll. C64 games do this all the time.

Anyway, didn't mean to turn this into a game design discussion. LOL

_________________
Cat; the other white meat.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 55 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: