Coding

 Reply to this postStart new topic

Live TV Screens

Deji
post Jul 17 2011, 01:58 AM
Post #1


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



'Live TV Screens'


This is the line found in cull.ipl that was found to have control over the 8-Track screen:
CODE
-1399.83, -208.103, 1039.34, 0, 120.187, 1039.34, 173.006, 0, 1157.71, 2, 0, 0, 0, 0

CODE
Center X, Center Y, Center Z, Unknown, X Radius, Bottom Z, Y Radius, Unknown, Top Z, Flags, MirrorParam1, MirrorParam2, MirrorParam3, MirrorParam4

Flags (binary)

CODE
1  - Mirror
10 - Screen


This line actually just controls where the camera has to be in order to see the TV Screen (or for any other culling to take effect, actually).

The camera positions are indeed hardcoded. They can be found, changed, etc. in this function: 0x7266B0

Some math is used to switch the camera positions (modular operations on the current time) and transverse it. The process (which I learned from NTA is 'multirendering') involves setting the camera position, 'capturing' what it sees and writing it to a RenderWare structure. The image is then drawn in the game. This is a similar method to how pictures can be taken with the camera in SA.

The TV camera position matrix is saved in the CCamera structure (CCamera+ADC). By writing the main camera position matrix to it, we can make the TV Screen show what the main camera shows:
SANNY
0A8C: write_memory 0x50B538 size 1 value 0xEB virtual_protect 1   // stops the game from updating the matrix
0A8E: 0@ = 0xB6F028 + 0x14
0A8D: 1@ = read_memory 0@ size 4 virtual_protect 0
0A8E: 0@ = 0xB6F028 + 0xADC
0AA6: call_method 0x59BBC0 struct 0@ num_params 1 pop 0 1@   // CMatrix__Copy(&CCamera.TvCamMatrix, CCamera.placeable.pMatrix)




Now onto moving the actual screen... Here are the coordinate locations for the two screens in the stadium, as well as their default values:
CODE
East Screen-TopRightX - 0x8D5DD8 (-1333.453)
East Screen-TopRightY - 0x8D5DDC (-221.89799)
East Screen-TopRightZ - 0x8D5DE0 (1079.141)
East Screen-TopLeftX - 0x8D5DE4 (-1333.453)
East Screen-TopLeftY - 0x8D5DE8 (-189.89799)
East Screen-TopLeftZ - 0x8D5DEC (1079.141)
East Screen-BottomLeftX - 0x8D5DF0 (-1333.453)
East Screen-BottomLeftY - 0x8D5DF4 (-189.89799)
East Screen-BottomLeftZ - 0x8D5DF8 (1067.141)
East Screen-BottomRightX - 0x8D5DFC (-1333.453)
East Screen-BottomRightY - 0x8D5E00 (-221.89799)
East Screen-BottomRightZ - 0x8D5E04 (1067.141)

West Screen-TopRightX - 0x8D5E08 (-1477.845)
West Screen-TopRightY - 0x8D5E0C (-189.96899)
West Screen-TopRightZ - 0x8D5E10 (1079.141)
West Screen-TopLeftX - 0x8D5E14 (-1477.845)
West Screen-TopLeftY - 0x8D5E18 (-221.96899)
West Screen-TopLeftZ - 0x8D5E1C (1079.141)
West Screen-BottomLeftX - 0x8D5E20 (-1477.845)
West Screen-BottomLeftY - 0x8D5E24 (-221.96899)
West Screen-BottomLeftZ - 0x8D5E28 (1067.141)
West Screen-BottomRightX - 0x8D5E2C (-1477.845)
West Screen-BottomRightY - 0x8D5E30 (-189.96899)
West Screen-BottomRightZ - 0x8D5E34 (1067.141)


I moved the West Screen to Grove Street, cause Westside is da best:


Here's a function so you can do the same:
SANNY
//0AB1: call_scm_func @SetupLiveScreen 7 ScreenID 0 Position 2512.1816 -1669.3521 21.0431 Width 20.0 Height 10.0 Angle 90.0

:SetupLiveScreen
0012: 0@ *= 0x30
000A: 0@ += 0x8D5DD8
0017: 4@ /= 2.0
0017: 5@ /= 2.0
02F6: 8@ = sine 6@
02F7: 7@ = cosine 6@
0013: 7@ *= 4@
0013: 8@ *= 4@
0087: 9@ = 1@
0087: 10@ = 2@
005B: 9@ += 7@
005B: 10@ += 8@
0087: 11@ = 3@
005B: 11@ += 5@
0087: 12@ = 1@
0087: 13@ = 2@
0063: 12@ -= 7@
0063: 13@ -= 8@
0087: 17@ = 3@
0063: 17@ -= 5@
0A8C: write_memory 0@ size 4 value 9@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 10@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 11@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 12@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 13@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 11@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 12@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 13@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 17@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 9@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 10@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 17@ virtual_protect 0
0AB2: ret 0


You should only use 0 or 1 for the ScreenID (unless you were smart enough to add another).


I should mention that while the TV was showing in Grove Street, my FPS dropped a bit (by about 10 fps). In interiors, the FPS decrease isn't noticable because not that much has to be rendered. So take that into account when adding screens to places. Still, the FPS difference won't be as much with lower graphics settings.


--------------------
Go to the top of the page
 
+Quote Post
Adler
post Jul 17 2011, 04:35 AM
Post #2


Devil's Advocate

Group Icon

Posts: 413
From: CA US
Joined: 26-July 09



TOO COOL!!! I recommended you for a medal by the way lol. blush.gif

Still can't believe you did this in a day!!


--------------------
Go to the top of the page
 
+Quote Post
Spider-Vice
post Jul 17 2011, 02:47 PM
Post #3


In motus...

Group Icon

Posts: 361
From: Portugal
Joined: 28-May 09



I must say I'm amazed, superb job!
Go to the top of the page
 
+Quote Post
Deji
post Jul 17 2011, 03:03 PM
Post #4


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Another issue arises with this, which unfortunately can't be bypassed in CLEO (unless you use a great deal of ASM).

Reflections will also use the position you have overwritten the TV camera position with. This includes mirrors and shiny floors in interiors.


--------------------
Go to the top of the page
 
+Quote Post
Adler
post Jul 17 2011, 06:36 PM
Post #5


Devil's Advocate

Group Icon

Posts: 413
From: CA US
Joined: 26-July 09



QUOTE (Deji @ Jul 17 2011, 08:03 AM) *
Another issue arises with this, which unfortunately can't be bypassed in CLEO (unless you use a great deal of ASM).

Reflections will also use the position you have overwritten the TV camera position with. This includes mirrors and shiny floors in interiors.

Errmmm that is to say that reflections will be replaced by live TV?


--------------------
Go to the top of the page
 
+Quote Post
Deji
post Jul 19 2011, 11:48 AM
Post #6


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Yes. Basically, they interfere with cull zones. Even just culling the screen itself prevents other cull zones from being used properly.

For example, if you change the data in CCamera+0xADC, it will show on the shiny floor of CJ's house.
If you add a cull zone in CJ's house (above the line that adds the reflection on the floor), the floor will be ugly and have a blue tint (the floor is semi-transparent, which is how it shows the copy of the interior, which is underneath).

I've tried to add a TV screen in CJ's house while preserving the shiny floor. No luck yet but I'll keep trying.


--------------------
Go to the top of the page
 
+Quote Post
Adler
post Jul 19 2011, 08:46 PM
Post #7


Devil's Advocate

Group Icon

Posts: 413
From: CA US
Joined: 26-July 09



QUOTE (Adler @ Jul 16 2011, 09:35 PM) *
TOO COOL!!! I recommended you for a medal by the way lol. blush.gif

Urp... turns out they only gave you a Verbal Commendation lol.

Weird things - these CULLs.


--------------------
Go to the top of the page
 
+Quote Post
Spider-Vice
post Jul 23 2011, 06:16 PM
Post #8


In motus...

Group Icon

Posts: 361
From: Portugal
Joined: 28-May 09



QUOTE (Adler @ Jul 19 2011, 09:46 PM) *
Urp... turns out they only gave you a Verbal Commendation lol.

Mhmm...
Go to the top of the page
 
+Quote Post
Yoda2604
post Oct 15 2011, 07:36 AM
Post #9


The New Guy!

Posts: 5
From: Moscow, Russia
Joined: 15-October 11



Hi all. I've registered here specifically to ask after reading this topic...
1) Is there a way to make a rear view mirror while CJ driving a car using this or similar (example: Ryosuke has made some mods which divided the screen) technic ?
2) Is there a way to play external video file on an in game screen like that liveTV?

p.s.: Sorry for bad english
p.s.2: Deji, please fix links on the Opcode database page to an updated SASCM.ini and opcodes.txt files...

This post has been edited by Yoda2604: Oct 15 2011, 07:40 AM


--------------------
QUOTE
Try not. Do or do not, there is no try.
Go to the top of the page
 
+Quote Post
Deji
post Oct 15 2011, 05:04 PM
Post #10


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Trust me, we all want to do both of those things. But at the moment it's still a pretty distant dream. tongue.gif


--------------------
Go to the top of the page
 
+Quote Post
Huckleberry Pie
post Dec 2 2011, 11:39 PM
Post #11


Ameteur Member

Posts: 49
Joined: 5-August 09



Could this also be a variant of off-screen rendering in RW?
Go to the top of the page
 
+Quote Post
Deji
post Dec 3 2011, 01:34 AM
Post #12


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Off screen rendering?


--------------------
Go to the top of the page
 
+Quote Post
LINK/2012
post Dec 3 2011, 03:50 PM
Post #13


I will kill you

Posts: 126
Joined: 13-May 11



I think that he mean render that "video display" out of this screen.
Go to the top of the page
 
+Quote Post
Huckleberry Pie
post Dec 10 2011, 10:58 AM
Post #14


Ameteur Member

Posts: 49
Joined: 5-August 09



QUOTE (Deji @ Dec 3 2011, 09:34 AM) *
Off screen rendering?


I'm actually referring to this: http://en.wikipedia.org/wiki/Render_Target

AFAIK it allows the hardware to draw stuff to a texture, and then apply it to some surface like a TV or some other ingame display. Or a mirror, perhaps:
http://www.youtube.com/watch?v=6Co5vySMOaU
http://www.youtube.com/watch?v=DPmvq_biMFM...feature=related

This post has been edited by Huckleberry Pie: Dec 10 2011, 11:08 AM
Go to the top of the page
 
+Quote Post
Deji
post Dec 10 2011, 02:42 PM
Post #15


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Yeah, I guess... NTA called it Multirendering (probably the RenderWare name for it). It's just rendering the game, with less stuff and quality, but storing it to a separate buffer and drawing the output on the billboard instead of on the screen.


--------------------
Go to the top of the page
 
+Quote Post
Albreht
post Feb 19 2012, 08:23 AM
Post #16


Trained Newbie

Posts: 21
Joined: 19-February 12



how to use this code?
i tried my self but i'm n00b i couldn't use this.
so please help!

i'm using US 2nd version with no-dvd patch and cleo4
sorry for my bad english

CODE
{$CLEO .cs}

thread 'SCREEN'

:main
wait 0
0AB1: call_scm_func @SetupLiveScreen 7 ScreenID 0 Position 2512.1816 -1669.3521 21.0431 Width 20.0 Height 10.0 Angle 90.0
0A93: end_custom_thread

:SetupLiveScreen
0012: 0@ *= 0x30
000A: 0@ += 0x8D5DD8
0017: 4@ /= 2.0
0017: 5@ /= 2.0
02F6: 8@ = sine 6@
02F7: 7@ = cosine 6@
0013: 7@ *= 4@
0013: 8@ *= 4@
0087: 9@ = 1@
0087: 10@ = 2@
005B: 9@ += 7@
005B: 10@ += 8@
0087: 11@ = 3@
005B: 11@ += 5@
0087: 12@ = 1@
0087: 13@ = 2@
0063: 12@ -= 7@
0063: 13@ -= 8@
0087: 17@ = 3@
0063: 17@ -= 5@
0A8C: write_memory 0@ size 4 value 9@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 10@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 11@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 12@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 13@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 11@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 12@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 13@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 17@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 9@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 10@ virtual_protect 0
000A: 0@ += 4
0A8C: write_memory 0@ size 4 value 17@ virtual_protect 0
0AB2: ret 0
Go to the top of the page
 
+Quote Post
Deji
post Feb 19 2012, 02:18 PM
Post #17


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



QUOTE
i'm using US 2nd version with no-dvd patch




This function only supports 1.0 US exe's.


--------------------
Go to the top of the page
 
+Quote Post
Albreht
post Feb 19 2012, 03:50 PM
Post #18


Trained Newbie

Posts: 21
Joined: 19-February 12



i'm using us 1.0 exe
and does my script has problems?

This post has been edited by Albreht: Feb 19 2012, 03:50 PM
Go to the top of the page
 
+Quote Post
Deji
post Feb 19 2012, 04:09 PM
Post #19


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Well, the best way to know that is to test it... but nah, there don't appear to be any problems.


--------------------
Go to the top of the page
 
+Quote Post
Albreht
post Feb 23 2012, 09:19 AM
Post #20


Trained Newbie

Posts: 21
Joined: 19-February 12



i downloaded gta_sa.exe us1.0(link removed) and tried again.
but it doesn't work either :/

which CLEO version do u using?
Reason for edit: No links to warez, please.
Go to the top of the page
 
+Quote Post
Reply to this postStart new topic

6 User(s) are reading this topic (6 Guests and 0 Anonymous Users)
0 Members: