Telestrat / Second VIA detection

If you want to ask questions about how the machine works, peculiar details, the differences between models, here it is !
How to program the oric hardware (VIA, FDC, ...) is also welcome.
User avatar
Dbug
Site Admin
Posts: 4985
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Telestrat / Second VIA detection

Post by Dbug »

I was doing some tests for my Joystick implementation in Encounter/OSDK, and I realized that calling the Telestrat reading code on an Atmos was resulting in a non working keyboard.

That's the code I'm using:

Code: Select all

;
; The Telestrat (unlike all its predeccesors) had two joystick Ports positioned on either side of the machine. 
; Both were powered and both supported a second fire button. The Joystick (and second fire) was supported by Pulsoids. 
; Both joysticks were connected to Port B of the second VIA of the Telestrat whilst the second fire was connected to 
; Port A of the Second VIA (Location $032F)
;
; - B7 Select Right Joystick
; - B6 Select Left Joystick
; - B5 -
; - B4 Up (Inverted)
; - B3 Down (Inverted)
; - B2 Fire (Inverted)
; - B1 Left (Inverted)
; - B0 Right (Inverted)
;
; Note that the order is identical to what the IJK joystick interface returns
;
_joystick_read_telestrat
.(
	lda #%01000000         ; Select Left Joystick port
	sta VIA2_PORTB
	lda VIA2_PORTB         ; UDFLR     
	and #%00011111
	eor #%00011111
	sta _OsdkJoystick_0    ; store to variable

	lda #%10000000         ; Select Right Joystick port
	sta VIA2_PORTB
	lda VIA2_PORTB         ; UDFLR     
	and #%00011111
	eor #%00011111
	sta _OsdkJoystick_1    ; store to variable
	rts
.)
Basically I need to either have this code not break the keyboard inputs, or I need a way to detect that there is a second VIA with joystick support - I believe the Twilighte card supports that - so the selection menu does not ends up failing.

Any idea on how to do that efficiently and reliably?
User avatar
Sodiumlightbaby
Squad Leader
Posts: 712
Joined: Thu Feb 22, 2024 11:38 am

Re: Telestrat / Second VIA detection

Post by Sodiumlightbaby »

There migh be a different type of failsafe way of detecting what platform you are running on, like checking certain ROM bytes etc. This is more direct probing on page 3.

The challenge with unexpanded Oric-1/Atmos machines is the incomplete decode of Page 3, which means the normal VIA will have the registers shadow mapped at every 16 bytes aligned slot in this page, 16 times. So you can probably do a two stage check.

1. Keyboard hang avoidance - Once on setup, when writing a VIA read/write register (i.e. not the ports), read it back before and after from a shadow location. If it tracks your write, you have VIA replication going on.
2. Probe for the VIA2 joystick. This should now be safe(er).
User avatar
Chema
Game master
Posts: 3144
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Telestrat / Second VIA detection

Post by Chema »

Not sure if this is relevant to your problem, but Fabrice Frances added code to header.s to detect if pinforic was being run in a Telestrat. The code is here https://github.com/Oric-Software-Develo ... 6/header.s

Code: Select all

*=$500
        sta _machine_type
        and #$80
        bmi init_telestrat
        
    
I have no idea why reg A comes with bit 7 set to 1 in a Telestrat after boot, but might give a clue. Maybe it is due to STRATORIC initializing the second VIA or simply due to different boot code.

I am sure I once knew, but memory fails me :(
User avatar
Dbug
Site Admin
Posts: 4985
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Telestrat / Second VIA detection

Post by Dbug »

Mysterious :)


Maybe the simplest is indeed to detect the mirroring of addresses, like when I'm setting up the IRQ Timer:

Code: Select all

    ;  Set the VIA parameters to get a 200hz IRQ
    lda #<19966/4		; 4991
    sta $306
    lda #>19966/4		; 4991
    sta $307
Check if I have the sames values in $306+16 and $307+16, if yes then it's an standard Oric and disable the Telestrat detection.
User avatar
iss
Wing Commander
Posts: 1812
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: Telestrat / Second VIA detection

Post by iss »

Dbug wrote: Sun Mar 09, 2025 7:31 pm Check if I have the sames values in $306+16 and $307+16, if yes then it's an standard Oric and disable the Telestrat detection.
Indeed! I was thinking the same :), also to be sure you can check that at #324/325 is a decrementing timer too.
Post Reply