Screen 2 using only one pattern table

Door albs_br

Master (179)

afbeelding van albs_br

01-09-2020, 17:34

I did some research but not found the answer: how to make my 3 name tables on Screen 2 point to the same pattern table?
By doing this I would free 4kb of VRAM to be used by other data.

Some small basic/assembly code would be really aprecciated.

Thanks

Aangemeld of registreer om reacties te plaatsen

Van MsxKun

Paladin (954)

afbeelding van MsxKun

01-09-2020, 17:46

That's not an standard VDP mode and won't work on all the MSX1 machines.

Van Grauw

Ascended (9478)

afbeelding van Grauw

01-09-2020, 18:03

The pattern table base address contains bits that are normally required to be 1. Clear the two highest of those bits to mirror the four tables. Do the same for the color table address. They act as an AND on the VDP's VRAM address lookup, so setting them to 0 causes the mirroring effect.

However, note that there are two compatibility issues:

1. The Texas Intruments TMS9918 VDP has problems with sprites in this mode, only the first 8 sprites work and the remaining are cloned.

2. The Toshiba T6950 VDP does not support this at all.

So on pretty much all MSX1 machines this mode has problems. I think only the Yamaha V2220 supports it well (not 100% sure) but that VDP is only used by a handful of rare MSX1 machines. Therefore it is not recommended to attempt to use this mode on MSX1 machines.

The Yamaha V9938/58 VDP properly support this mode fully though. So you can use it on MSX2 and up. But then, might as well use screen 4 instead of screen 2 to gain access to sprite mode 2.

Van ARTRAG

Enlighted (6462)

afbeelding van ARTRAG

01-09-2020, 19:13

Grauw wrote:

1. The Texas Intruments TMS9918 VDP has problems with sprites in this mode, only the first 8 sprites work and the remaining are cloned.

2. The Toshiba T6950 VDP does not support this at all.

So on pretty much all MSX1 machines this mode has problems. I think only the Yamaha V2220 supports it well (not 100% sure) but that VDP is only used by a handful of rare MSX1 machines. Therefore it is not recommended to attempt to use this mode on MSX1 machines.

The Yamaha V9938/58 VDP properly support this mode fully though. So you can use it on MSX2 and up. But then, might as well use screen 4 instead of screen 2 to gain access to sprite mode 2.

More precisely, all Yamaha chips support the mirroring without side effects, while in the TMS9918 VDPs, the glitch on sprites appears if you mirror the pattern table, not when you mirror the color table.
Exploiting this latter fact, it is possible to allocate two pages of tiles without restrictions on the number of sprites. Here you have a demo
https://github.com/artrag/scroll_8_ways
and here a full game
https://github.com/artrag/Uridium-msx1
On machines with Toshiba clones the mirroring won't work. They are not very widespread, nevertheless Uridium has a compatibility mode that, cutting the number of tiles used in the scrolling, allows the game to work also on that chips.
You can look at the sources if you are interested in details

Van ~mk~

Champion (263)

afbeelding van ~mk~

16-12-2020, 01:29

I tried this myself the other day and achieved it in Basic by doing:

10 SCREEN1:WIDTH32
20 SCREEN2:POKE&HFCAF,1
30 VDP(3)=&H9F:VDP(4)=0

I am a bit uncomfortable with the hardcoded values in the vdp registers.
Does anyone understand this well enough to tell which bits should be cleared/set?

Van ARTRAG

Enlighted (6462)

afbeelding van ARTRAG

16-12-2020, 12:19

Do you need this ?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;		   defb 0x02 ; Reg# 0 000000[M3][EV]
;		   defb 0x62 ; Reg# 1 [4/16k][BLANK][IE][M1][M2]0[SIZE][MAG]
;		   defb 0x06 ; Reg# 2 0000[NAME TABLE BASE ADDRESS]			 = 1800h

;		   defb 0x9F ; Reg# 3 [COLOR BASE ADDRESS]					 = 2000h ; hybrid mode for colors
;		   defb 0xFF ; Reg# 3 [COLOR BASE ADDRESS]					 = 2000h ; regular mode for colors

;		   defb 0x1F ; Reg# 3 [COLOR BASE ADDRESS]					 = 0000h ; hybrid mode for colors
;		   defb 0x7F ; Reg# 3 [COLOR BASE ADDRESS]					 = 0000h ; regular mode for colors

;		   defb 0x00 ; Reg# 4 00000[PATTERN GENERATOR BASE ADDRESS]	 = 0000h ; hybrid mode for patterns
;		   defb 0x03 ; Reg# 4 00000[PATTERN GENERATOR BASE ADDRESS]	 = 0000h ; regular mode for patterns

;		   defb 0x04 ; Reg# 4 00000[PATTERN GENERATOR BASE ADDRESS]	 = 2000h ; hybrid mode for patterns
;		   defb 0x07 ; Reg# 4 00000[PATTERN GENERATOR BASE ADDRESS]	 = 2000h ; regular mode for patterns

;		   defb 0x36 ; Reg# 5 0[SPRITE ATTRIBUTE TABLE BASE ADDRESS] = 1b00h
;		   defb 0x07 ; Reg# 6 00000[SPRITE PTRN GNRTR BASE ADDRESS]	 = 3800h
;		   defb 0x01 ; Reg# 7 [TEXT COLOR 4bts][BACKDROP COLOR 4bts]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	code
disp_page1:			; page 1 active
	_setVdp 3,0x9F	;	colours at 0x2000	(hybrid)
	_setVdp 4,0x03	;	patterns at 0x0000	(regular: used 0x0800 0x1000)
	ret
	code
disp_page0:			; page 0 active
	_setVdp 3,0x1F	;	colours at 0x0000	(hybrid)
	_setVdp 4,0x07	;	patterns at 0x2000	(regular: used 0x2800 0x3000)
	ret

Van ~mk~

Champion (263)

afbeelding van ~mk~

17-12-2020, 04:43

Yes that was helpful, thanks ARTAG.
With your docs and the info in the wiki (https://www.msx.org/wiki/VDP_Table_Base_Address_Registers) I conclude it is correct to use hardcoded value &H9F for VDP(3) however for VDP(4) we should be doing VDP(4)AND&hF8 in order to clear the relevant bits and avoid changing the others.

Van Bengalack

Master (237)

afbeelding van Bengalack

17-12-2020, 19:12

albs_br wrote:

how to make my 3 name tables on Screen 2 point to the same pattern table?

uh? I wonder if this is what I have been looking for, for screen 4. When you say "3 name tables", are you talking about what is referenced to as "blocks" in Konamiman's docs? Always found it a hassle to always do things three times over every frame :)

    MSB   7    6    5    4    3    2    1    0    LSB
        ----------------------------------------- ---+
R#3     | A13| 1  | 1  | 1  | 1  | 1  | 1  | 1  |    |
        -----------------------------------------    |
                                                     |---+
        -----------------------------------------    |   |
R#10    | 0  | 0  | 0  | 0  | 0  | A16| A15| A14|    |   |
        ----------------------------------------- ---+   |
                                                         |
        +------------------------------------------------+
        |
        |                              MSB   7 6 5 4 3 2 1 0   LSB
        |      ---------------             -------------------    -+
        +--->  | Pattern 0   | 0           | Pattern|Pattern |  0  |
               |--------------             |   "0"  |  "1"   |  1  |
               | Pattern 1   | 1           | colour | colour |  2  |
               |--------------             |    (0 to 15)    |  3  | Pattern
               |      .      | .           |        |        |  4  |    0
Colour                .        .           |        |        |  5  |
table                 .        .           |        |        |  6  |
for block 1    |             |             |        |        |  7  |
               |--------------             |        |        |  8 -+
               | Pattern 254 |             |        |        |  9  |
               |-------------|             |        |        |  10 |
               | Pattern 255 | 255         |        |        |  11 | Pattern
               ---------------             |        |        |  12 |    1
                                           |        |        |  13 |
               ---------------             |        |        |  14 |
               | Pattern 0   | 256         |        |        |  15-+
               |-------------|                      .
               | Pattern 1   |                      .
               |-------------|                      .
               |      .      |             |        |        |  2040 -+
Colour                .                    |        |        |  2041  |
table                 .                    |        |        |  2042  |
for block 2    |             |             |        |        |  2043  | Pattern
               |-------------|             |        |        |  2044  |   255
               | Pattern 254 |             |        |        |  2045  |
               |-------------|             |        |        |  2046  |
               | Pattern 255 | 511         |        |        |  2047  |
               ---------------             -------------------       -+

               ---------------             ------------------------------
               | Pattern 0   | 512         |                            |
               |-------------|             |  ------------------------  |
               | Pattern 1   |             |  |                      |  |
               |-------------|             |  |        Block 1       |  |
               |      .      | .           |  |                      |  |
Colour                .        .           |  |----------------------|  |
table                 .        .           |  |                      |  |
for block 3    |             |             |  |        Block 2       |  |
               |-------------|             |  |                      |  |
               | Pattern 254 |             |  |----------------------|  |
               |-------------|             |  |                      |  |
               | Pattern 255 | 767 pattern |  |        Block 3       |  |
               ---------------             |  |                      |  |
                                           |  ------------------------  |
                 Colour table              |                            |
                                           ------------------------------

                                                        Screen

Van Bengalack

Master (237)

afbeelding van Bengalack

19-12-2020, 09:56

Bengalack wrote:

are you talking about what is referenced to as "blocks" in Konamiman's docs?

Going to answer myself here: Yes. This was probably obvious to everyone else. But anyway - thanks for bringing this up, I always wanted this, but could not find a trace of information anywhere (or, if there were, it was certainly not clear to me). This will save my a bunch of cycles. I'm on msx2 and screen 4, so I don't need to cater for vdps without the support. Happy days! :)

So, to get away with only ONE block instead of THREE

  • Colors: clear bit 6 and 5 in reg 3
  • Patterns: clear bit 1 and 0 in reg 4

Fantastic! Thanks again! :)