;from caker137
;BASED ON MY HACK OF THE UPR ROMS AVAILABLE ONLINE
;read that first if you are trying to learn to hack romsets

;Discs of Tron 2-player Environmental Hack
;This hack is designed to work on the latest UPRIGHT romset
;released for DOT dated 10/83.  They will work equally well
;in an Upright or Environmental cabinet.


;testing of ENV/UPR mode jumper is performed 
;at address 0x20 for almost all game operations.
;this routine is called often, whenever a cabinet
;specific function is performed during gameplay,
;such as stalling the game to allow speech to continue
;or panning the sound effects for the ENV cab, and 
;allowing a 2 player game in the UPR cab.
;the routine result is in Z flag, where Zero=False means that 
;the game is an Upright.  Here are some addresses
;that call the mode checking routine

;List of calls to Mode Jumper routine to HACK

;From Address		Function		Hack To
02EE		End of Player game check other 	Upright         
04F4		Display Start Options		Upright         
05CF		Start 1 or 2 player on press    Upright         


;Since most functions need to be told that the game is ENV, I
;will change the mode checking rouine to always report ENV.  
;Then I can specifically change the routines that conversely
;need to think the mode is upright.


;ADD ENVIROMENTAL 2 PLAYER START FEATURE !!!!!!!!!!!
;since the ENV cab will have no 2 player start button, I 
;will hack in a way to start 2 player games.  Just hold down
;the aiming knob while pressing 1P start to begin a 2 player
;game.  Of course 1P and 2P start still work as before.

;Pertinant Game Functions
;Address		Function		
0x5c8		Get start press 1 or 2 player
0x5d7		Start 1 player game
0x5eb 		Start 2 player game

;choosing 1 or 2 players
;UNMODIFIED CODE SNIPPET
05C8: DB 00       in   a,($00)		;read port
05CA: 2F          cpl
05CB: E6 0C       and  $0C		;was either 1 or 2p start pressed?
05CD: 47          ld   b,a		;make backup of pressed key in 'b'
05CE: C8          ret  z		;leave if none pressed
05CF: E7          rst  $20		;check for Enviromental cab
05D0: 28 05       jr   z,$05D7		;if environmental, start 1 player
05D2: 78          ld   a,b		;restore port reading to 'a'
05D3: E6 08       and  $08		;is it start 2?
05D5: 20 14       jr   nz,$05EB		;if so start 2 player game
...					;otherwise, 1 player game, here


;NEW CODE SNIPPET
05C8: DB 00       in   a,($00)		;read port
05CA: CB 5F       bit  3,a		;was 2 Player Pressed?
05CC: 28 1D       jr   z,$05F9		;if so, run 2 player game
05CE: CB 57       bit  2,a		;was 1 Player Pressed?
05D0: C0          ret  nz		;leave if none pressed
05D1: DB 02       in   a,($02)		;check for input on aim down
05D3: CB 67       bit  4,a		;was aim down held?
05D5: 28 14       jr   z,$05F9		;if so, run 2 player game
...					;otherwise, 1 player game, here

;Notice this also hacks out one of the mode jumper calls, so we don't have
;to hack that one otherwise


;COMPLETE LIST OF ROM CHANGES TO ADD ALL FUNCTIONALITY

;make jumper check routine always report ENV
;Address	ROM:RELATIVE		From		To	  	Checksum Change
*0x0023		loc-pg0.1c:0x0023	0xCB		0xE6		0x1B
*0x0024		loc-pg0.1c:0x0024	0x7F		0x00		0x81

;make 2 player routines think its always UPR
;Address	ROM:RELATIVE		From		To	  	Checksum Change
*0x02EF		loc-pg0.1c:0x02EF	0xC8		0xC0		0xF8
*0x04F5		loc-pg0.1c:0x04F5	0x28		0x20		0xF8

;add hack to allow aim-down plus 1p to start a 2p game (see code snippets above)
;Address	ROM:RELATIVE		From		To	  	Checksum Change
*0x05CA		loc-pg0.1c:0x05D8	0x2F		0xCB		0x9C			
*0x05CB		loc-pg0.1c:0x05D9	0xE6		0x5F		0x79			
*0x05CC		loc-pg0.1c:0x05DA	0x0C		0x28		0x1C			
*0x05CD		loc-pg0.1c:0x05DB	0x47		0x1D		0xD6			
*0x05CE		loc-pg0.1c:0x05DC	0xC8		0xCB		0x03			
*0X05CF		loc-pg0.1c:0x05DD	0xE7		0x57		0x70
*0x05D0		loc-pg0.1c:0x05DE	0x28		0xC0		0x98
*0x05D1		loc-pg0.1c:0x05DF	0x05		0xDB		0xD6
*0x05D2		loc-pg0.1c:0x05E0	0x78		0x02		0x8A
*0x05D3		loc-pg0.1c:0x05E1	0xE6		0xCB		0xE5
*0x05D4		loc-pg0.1c:0x05E2	0x08		0x67		0x5F
*0x05D5		loc-pg0.1c:0x05E3	0x20		0x28		0x08
									----
						Checksum Change	Total:  0x4A

;Adjust a junk 0xff byte to cancel out the checksum change we have caused.
;Checksum Fix	
;Address	ROM:RELATIVE		From		To								
*0x0005		loc-pg0.1c:0x0005	0xFF		0xB5	;(0xFF-0x4A = 0xB5)

;MAKE ALL "*" CHANGES TO "loc-pg0.1c" ROM to apply patch.