So it's time to start seriously looking at this coding business and trying to sort it out. The latest decompilation that has been made available has been SQ4, so I am starting there. And not only starting there, but actually starting at the beginning... with the intro script.
I have been doing some tinkering with the code layout and whatnot to actually get it as recognizable to me as possible. I figured I would start throwing out some rudimentary questions as I come across things I am not sure about as well as some clarification just to make sure what I think is happening is actually what is happening. So I guess to start with, I will post the code that I am actually staring at. I commented the hell out of it so it might actually be easier to read if you copy it and paste it into our current version of sciCompanion just for the syntax highlighting.
//******************************************************************************
// SQ4 - Space Quest Splash Screen and initial Intro bit
//******************************************************************************
(include "sci.sh")(include "game.sh") (script 1)
//*****************************************************************************
(use "Main") // Good old main script, we are used to this one...
(use "SQRoom") // Seems to mainly handle ego motion
(use "n958")// Seems to be a small load / dispose script...
(use "User")// We are used to User
(use "Obj")// We are used to Obj
//*****************************************************************************
(local
local0 // unused by this script so really could be omitted
local1
)
//*****************************************************************************
(instance public rm001 of SQRoom
(properties picture 106) // picture 106 is the sierra splash screen...
(method (init)
(super:init())
(self:setScript(RoomScript))
(self:setRegions(707)) // actually the intro.txt file... holds the handleEvent for the intro screens
Load(rsPIC 1)// Bah, who needs Load... no one ever uses it... anyway, loads pic 1 into memory
proc958_0(135 68 69) // found in script 958... the small load / dispose script
// So if I am halfway right, this will load param1 (resource type) and then
// loop through the remaining paramaters representing the resource numbers
// of that type... Loading each one in succession
// looking at this in viewer, 135 must represent RSFONT, and would therefore load
// fonts 68 and 69 (there aren't any other resource types which include 68 or 69)
// so 135 must mean Font... we are used to this (define rsFONT $87)
)// end Method init
)// end Instance
//******************************************************
(instance RoomScript of Script
(properties)
(method (doit)
(super:doit())
// So we know do it checks things every cycle...
// so we are looking every cycle to see if the changestate is at state (or case) 1
// and the music being played is throwing prevSignal 10... not sure what prevSignal 10
// means but anyway, when those two conditions are met, then the RoomScript is supposed
// to cue itself. Which I have never tried it but judging by this, it will bump the
// changestate method on to the next state (case) as I am not seeing anything else here
// that does do that.
(if ((== state 1) and (== (send gLongSong:prevSignal) 10))(self:cue()))
)// end Method Doit
(method (changeState newState)
(var temp0[3]) // unused by this method so really could be omitted
(switch (= state newState)
(case 0
(send gLongSong:loop(-1)playBed()) // Starts the song that doit is keeping an eye on
= cycles 2 // waits a couple of ticks then moves on to case 1
)
(case 1) // just hangs... This threw me until I noticed the cue() in the doit... thats what moves us on
(case 2
(send global2:drawPic(1))// Not sure what global2 is... gRoom maybe, we have always just used DrawPic(###) before
// anyway, this throws up the Space Quest Title Screen
= register 200 // I see register is used in SQRoom.txt but in the context of newRoom... not sure what we are registering here.
// But judging from the next case, it looks like this is going to be used as a quick and dirty timer variable
= cycles 2 // waits a couple of ticks then moves on to case 3
)
(case 3
Animate((send gCast:elements) 0) // I am not sure what this actually does... do we have a cast?
(while (--register and (== gTheGNumber gNumber))// so while register > 0 ?? I don't get what kicks us out of the while loop
(if (== register 150) // when the register variable is at 150... started in case 2 at 200
= local1 proc0_12(" 1991 Sierra On-Line, Inc." 67 1 177 70 316 28 proc0_18(global157 global156) 29 gColor 30 1 33 68)
// ok so not sure why this had to have a name, local1 is one of this scripts local variables defined at the top.
// local1 is set to proc0_12 which is pretty obvious is some sort of display command. as it throws the copyright
// line on to the screen... not sure why there are processes inside this display command though or what all of those parameters
// represent.
)
(User:doit()) // not sure why this is here....
Palette(6 160 191 -1) // or these
Palette(6 128 159 -1)
)// end while
(send global2:drawPic(803 30)) // Ok so this I can tell you, draws picture 803 on the screen. Again not sure about the send bit with DrawPic
(if (== gNumber gTheGNumber) // hmm... so apparently if these two match
(send global2:newRoom(6))// then it is time to take this intro on to room 6... also, this confirms global2 = gRoom as we knew it previously
// (send gRoom:newRoom(###))
)
)
)// end switch
)//end method
)// end instance
So what do you think, is this something we want to try and sort out together or no... I just figured we would take the game as it comes and look at the code and decipher what it is actually doing on screen.