Technical Reference
-------------------

based on a technical reference by Paul Robson


Universal Video Interface (S2637) based consoles

Produced in several different variants from a lot of firms


4 known main variants:
arcadia style: small cartridge connector, 12 button controller, digital sticks
vcg style: mid sized cartridge connector, 16 button controller, analog sticks (later autocentering)
mpt03 style: big sized cartridge connector, 14(12!) button controller, analog? sticks
intervision style: same controller as mpt03, different cartridge pinout than mpt03


cpu s2650 clocked at 8.86/2.5 MHz
sense input 1 is vertical blank
flag output inverts all 3 color lines (vcg schematic)
uvi s2637 (irq output (address 3) not connected to cpu)
(uvi performs read and write dma and stops cpu)
usg s2621 (PAL) or s2622 (NTSC)
4 2102
or 2 2114 (1 address line grounded!) in newer consoles


Memory layout
-------------
0000-0fff cartridge (rom)
1800-18ff uvi SRAM low
1900-197f keypad (uvi cs for extension)
1980-19ff uvi register (1980-19fb writeonly, 19fc-19ff readonly)
1a00-1aff uvi SRAM high
2000-2fff cartridge (rom)
4000-4fff cartridge (golf, video lexikon rom)


uvi cs for extension/keys
-------------------------
1900 keypad player 1/left (active high key pressed)
     bit 0 enter
     bit 1 7
     bit 2 4
     bit 3 1
1901 keypad player 1
     bit 0 0
     bit 1 8
     bit 2 5
     bit 3 2
1902 keypad player 1
     bit 0 clear
     bit 1 9
     bit 2 6
     bit 3 3
1903 keypad player 1 (only vcg)
     bit 0 x1
     bit 1 x2
     bit 2 x3
     bit 3 x4
1904 keypad player 2(right)
1905 keypad player 2
1906 keypad player 2
1907 keypad player 2 (only vcg)
1908 console buttons
     bit 0 start
     bit 1 option (vcg selector a)
     bit 2 difficulty (vcg selector b)
     power on switch hardwired
     load/reset key not software readable

uvi
---
4 8x8 mono sprites
tilemap 13 or 26 character lines of 16 characters
character size 8x8
doublescanning possible
2 tilemap modes
 color2x2 
 color4x1 (4 character colors, 1 background)
56 predefined characters in rom (8 can be defined), 64 rectangle chars

Sprites are used around the playfield a lot
(space vultures, grand slam tennis, space attack, ...)
some cartridges think the left 16? pixels are not displayed
so I display a 32 pixel frame left and right,
a 8 pixel frame at the top and a bottom frame of 24 pixel

overlapped sprites are oring their color values!


Palette:
 Colour Code    Name    Colour Elements
 ------ ----    ----    ---------------
  7     111     Black   (GRB = 000)
  6     110     Blue    (GRB = 001)
  5     101     Red     (GRB = 010)
  4     100     Magenta (GRB = 011)
  3     011     Green   (GRB = 100)
  2     010     Cyan    (GRB = 101)
  1     001     Yellow  (GRB = 110)
  0     000     White   (GRB = 111)


character set
-------------
{ 0,0,0,0,0,0,0,0 },                        // 00 (space)
{ 1,2,4,8,16,32,64,128 }, //                 ; 01 (/)
{ 128,64,32,16,8,4,2,1 }, //                 ; 02 (\)
{ 255,255,255,255,255,255,255,255 }, //      ; 03 (solid block)
{ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00 },// 04 (?)
{ 3,3,3,3,3,3,3,3 }, //                      ; 05 (half square right on)
{ 0,0,0,0,0,0,255,255 }, //                  ; 06 (horz lower line)
{ 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0 },// 07 (half square left on)
{ 0xff,0xff,3,3,3,3,3,3 },                  // 08 (?)
{ 0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0 },// 09 (?)
{ 192,192,192,192,192,192,255,255 }, //      ; 0A (!_)
{ 3,3,3,3,3,3,255,255 }, //                  ; 0B (_!)
{ 1,3,7,15,31,63,127,255 }, //               ; 0C (diagonal block)
{ 128,192,224,240,248,252,254,255 }, //      ; 0D (diagonal block)
{ 255,254,252,248,240,224,192,128 }, //      ; 0E (diagonal block)
{ 255,127,63,31,15,7,3,1 }, //	             ; 0F (diagonal block)
{ 0x00,0x1c,0x22,0x26,0x2a,0x32,0x22,0x1c },// 10 0
{ 0x00,0x08,0x18,0x08,0x08,0x08,0x08,0x1c },// 11 1
{ 0x00,0x1c,0x22,0x02,0x0c,0x10,0x20,0x3e },// 12 2
{ 0x00,0x3e,0x02,0x04,0x0c,0x02,0x22,0x1c },// 13 3
{ 0x00,0x04,0x0c,0x14,0x24,0x3e,0x04,0x04 },// 14 4
{ 0x00,0x3e,0x20,0x3c,0x02,0x02,0x22,0x1c },// 15 5
{ 0x00,0x0c,0x10,0x20,0x3c,0x22,0x22,0x1c },// 16 6
{ 0x00,0x7c,0x02,0x04,0x08,0x10,0x10,0x10 },// 17 7
{ 0x00,0x1c,0x22,0x22,0x1c,0x22,0x22,0x1c },// 18 8
{ 0x00,0x1c,0x22,0x22,0x3e,0x02,0x04,0x18 },// 19 9
{ 0x00,0x08,0x14,0x22,0x22,0x3e,0x22,0x22 },// 1a A
{ 0x00,0x3c,0x22,0x22,0x3c,0x22,0x22,0x3c },// 1b B
{ 0x00,0x1c,0x22,0x20,0x20,0x20,0x22,0x1c },// 1c C
{ 0x00,0x3c,0x22,0x22,0x22,0x22,0x22,0x3c },// 1d D
{ 0x00,0x3e,0x20,0x20,0x3c,0x20,0x20,0x3e },// 1e E
{ 0x00,0x3e,0x20,0x20,0x3c,0x20,0x20,0x20 },// 1f F
{ 0x00,0x1e,0x20,0x20,0x20,0x26,0x22,0x1e },// 20 G
{ 0x00,0x22,0x22,0x22,0x3e,0x22,0x22,0x22 },// 21 H
{ 0x00,0x1c,0x08,0x08,0x08,0x08,0x08,0x1c },// 22 I
{ 0x00,0x02,0x02,0x02,0x02,0x02,0x22,0x1c },// 23 J
{ 0x00,0x22,0x24,0x28,0x30,0x28,0x24,0x22 },// 24 K
{ 0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x3e },// 25 L
{ 0x00,0x22,0x36,0x2a,0x2a,0x22,0x22,0x22 },// 26 M
{ 0x00,0x22,0x22,0x32,0x2a,0x26,0x22,0x22 },// 27 N
{ 0x00,0x1c,0x22,0x22,0x22,0x22,0x22,0x1c },// 28 O
{ 0x00,0x3c,0x22,0x22,0x3c,0x20,0x20,0x20 },// 29 P
{ 0x00,0x1c,0x22,0x22,0x22,0x2a,0x24,0x1a },// 2a Q
{ 0x00,0x3c,0x22,0x22,0x3c,0x28,0x24,0x22 },// 2b R
{ 0x00,0x1c,0x22,0x20,0x1c,0x02,0x22,0x1c },// 2c S
{ 0x00,0x3e,0x08,0x08,0x08,0x08,0x08,0x08 },// 2d T
{ 0x00,0x22,0x22,0x22,0x22,0x22,0x22,0x1c },// 2e U
{ 0x00,0x22,0x22,0x22,0x22,0x22,0x14,0x08 },// 2f V
{ 0x00,0x22,0x22,0x22,0x2a,0x2a,0x36,0x22 },// 30 W
{ 0x00,0x22,0x22,0x14,0x08,0x14,0x22,0x22 },// 31 X
{ 0x00,0x22,0x22,0x14,0x08,0x08,0x08,0x08 },// 32 Y
{ 0x00,0x3e,0x02,0x04,0x08,0x10,0x20,0x3e },// 33 Z
{ 0,0,0,0,0,0,0,8 },                        // 34 .
{ 0,0,0,0,0,8,8,0x10 },                     // 35 ,
{ 0,0,8,8,0x3e,8,8,0 },                     // 36 +
{ 0,8,0x1e,0x28,0x1c,0xa,0x3c,8 },          // 37 $
$1980 sprite 0
$1988 sprite 1
$1990 sprite 2
$1998 sprite 3
$19a0
$19a8
$19b0
$19b8


uvi io area in console
----------------------
1800-18cf first 13 character lines
18f0 sprite 0 y; same as tilemap vertical position register, but 1 line later
18f1 sprite 0 x
18f2 sprite 1 y
18f3 sprite 1 x
18f4 sprite 2 y
18f5 sprite 2 x
18f6 sprite 3 y
18f7 sprite 3 x
18fc tilemap vertical position
 PAL: $ff 256+6 visible, 0 7 lines visible (vcg)
18fd
 bit 7 1 color2x2 mode; 0 color4x1 mode
 bit 0..6 frequency = 15625/(2*(data+1))

18fe
 bit 0..2 volume
 bit 3 tone generator on
 bit 4 noise on
 bit 5..7 tilemap horicontal position/scrolling (43+data)
18ff
 bit 0..3 readonly? current character line
	0xd during vertical blank
	0xf during vertical retrace
 bit 4..7 1111
1980-19bf write only user defined characters
19f8
 0..2 2nd background color
 3..5 2nd tilemap color
 6 1 26 lines, 0 13 lines
 7 graphics mode on
19f9
 0..2 background color
 3..5 tilemap color 
 6 select analog channels (1 horicontal, 0 vertical
   hobo: seams to be taken at an early rasterline and then set late in the frame?
   (must not affect ad converter immediately)
 7 1 tilemap doublescan off
19fa
 0..2 sprite 3 color
 3..5 sprite 2 color
 6 sprite 3 vertical enlarge ( 1 sprite is displayed twice) off
 7 sprite 2 enlarge off
19fb
 0..2 sprite 1 color
 3..5 sprite 0 color
 6 sprite 1 enlarge off
 7 sprite 0 enlarge off
19fc readonly collision sprite background (0 collided) set at vertical retrace, read
 0 sprite 0
 1 sprite 1
 2 sprite 2
 3 sprite 3
 4..7 const 1111
19fd readonly sprite sprite collision (0 collided), set at vertical retrace, read
 0 0+1
 1 0+2
 2 0+3
 3 1+2
 4 1+3
 5 2+3
 6,7 const 11
19fe readonly ad converter player 2, counter started at vertical retrace, finished at screen bottom
     low left,up (paddle counterclockwise?)
19ff readonly ad converter player 1
1a00-1acf next 13 character lines


tilemap remarks
---------------

character color:
in color4x1 mode ((ch&0xc0)>>5) | ((mem[0x19f9]&8)>>3)
in color2x2
 character bit 7 -> background select 
  0 19f8 bits 2..0
  1 19f9 bits 2..0
 character bit 6 -> foreground select
  0 19f8 bits 5..3
  1 19f9 bits 5..3

graphics mode:
lower 6 bits describe rectangles
0xc0 in line switches to graphics mode in this line
0x40 in line switches to char mode in this line
 22111000
 22111000
 22111000
 22111000
 55444333
 55444333
 55444333
 55444333



Cartridges
----------
known cartridge types
* 2kbyte cartridge rom at $0000
* 4kbyte cartridge rom at $0000
* 6kbyte cartridge: 4kbyte rom at $0000, 2kbyte at $2000 ( 2 rom chips)
* 6kbyte golf: 4kbyte rom at $0000, 2kbyte at $4000 ( 2 rom chips)
* 8kbyte cartridge: 4kbyte rom at $0000, 4kbyte at $4000
** 2 variants 2 4kbyte rom chips, 1 8kbyte rom chip
* 12kbyte video lexikon: 4kbyte rom at $0000, 4kbyte at $2000, 4kbyte at $4000 (3 rom chips)
* ward arcadia multicartridge 64 8kbyte slots (a12 on chip connected to a13 on connector)--> no golf a14 or video lexikon
* pet multicartridge (vcg,arcadia versions): supports dil32 romchip
  rom a13,a14 can be routed to connector a13,a14 or dipswitches
  


usg2621 PAL remarks
-------------------
up to 256+6 lines useable in tilemap (vcg)
on my tv 2lines above background (crazy_climber visible)
no background under tilemap in crazy_climber (25*16)
sprites from imaginary point 3 to 255+7

about 8 lines rasen
:tilemap position 0
up to 16*16+6 tilemap
(tilemap start can be delayed)
about 8 lines rasen

some blanked lines,
vertical sync
some blanked lines
(should give 312? lines)



usg2622 NTSC remarks
--------------------
tone frequency the same as PAL
(uvi tone frequency based on line frequency, but
usg2622 same line frequency as usg2621/PAL)



arcadia style consoles special notes
------------------------------------
golf: needs a14 address which doesn't seam to be wired to all arcadia style cartridge connectors
circus: needs plugged in optional paddles (analog stick)
digital joy switches paddles ad resistors

keypad layout:
        1       2       3
        4       5       6
        7       8       9
      Enter     0     Clear
( 2 firebuttons on the side (key 2))


vcg style consoles special notes
--------------------------------
video lexikon: uses all 16 buttons on the controllers

keypad layout
   2/fire
x1   x2   x3
 1   x4    3
 4    5    6
 7    8    9
Del   0  Enter


mpt03 style console special notes
---------------------------------
effectiv only 12 button (2 firebutton copies)
keypad layout:
        2?		2?
        1       2       3
        4       5       6
        7       8       9
      Enter     0     Clear



s2650 unspecified behaviour
---------------------------
prooved on palladium vcg console:
*adda,r1 
 ovf only set when both operands same signs and result different sign
*suba,r1 (carry inversed like 6502)
 effectiv if !wc a+b^$ff+1 else a+b^$ff+c
*coma,r1
 carry cleared, idc + ovf ignored
 80 70 !com neg; com pos
 70 80 com neg; !com pos
*rrl !wc idc + pvf ignored
      wc ovf source bit 6, idc source bit 4
*rrr !wc idc + pvf ignored
      wc idc source bit 6, ovf source carry & source pos
*dar idc, ovf not changed
     cc1,cc0 to normal meaning
     ovf ignored?
     idc used     




private appendix for pet
------------------------
19f8, 19f9 readback alway 0xff
1900 readback 0x5y
17bf readback 0x54
1b00 holds value for a moment, gets 0x50

nibblemen 
ntsc pal test? at 0ad8
1ad4..1ad7 
02 02 03 02 60hz?
17 02 03 03 50hz?

cat trax
03 02 02 03 60hz?
17 02 03 03 50hz?


Old NTSC Frame Description
--------------------------

This describes the frame rendition (for NTSC). The description Starts at
the end of a display frame, e.g. scanline 216 on the diagram. For a PAL
machine these will be slightly different - however I don't think that
this would affect anything because of the way timing is usually done on
games, and the fact that scanline level operations are virtually
impossible.

1.   Set the VBLANK (SENSE) line to logic 1, indicating entry of vblank
2.   Set the current character address to $FD (off screen)
3.   Wait for 46+8 Scanlines. (see frame diagram)
4.   Set the VBLANK (SENSE) line to logic 0.
5.   Reset the Collision Bytes to $FF
6.   For 1800..18C0, then for 1A00..1AC0 (if not low resolution)
6a.    Set the current character address to $Fx
6b.    wait for 8 (standard) or 16 (low resolution) Scanlines
6c.    Render the line using the current character & vertical scroll data
6d.    Draw all sprites which terminate in the area just drawn.
7.   Restart the frame (from Stage 1).

Stage 5 can be replaced by execute 208 Scanlines if this is not a 'redraw'
frame.

0       ---------------------------
        ! Initial Vertical Blank  !
8       ---------------------------
        ! Display (208 scanlines) !
216     ---------------------------
        !     Frame Retrace       !
262     ---------------------------

errors in this:
vertical position register (not 0xff, but 0xee?)
frame retrace itself occurs only for a few lines
rest is "rasen"

