Author Topic: MachineSpeed syntax on real hardware  (Read 3758 times)

0 Members and 2 Guests are viewing this topic.

Offline robbo007

MachineSpeed syntax on real hardware
« on: August 17, 2023, 01:01:49 PM »
Hi guys,

I'm trying to get the "MachineSpeed" synatx working when I test my game on real hardware, IBM XT, IBM AT and a 486.

From the LSL3 code in room 250 (Casino exterior) they used it to init the fountain view if the machine was faster than a IBM XT.

Code: [Select]
(if (> machineSpeed pc8088)
(aFountain init)
)
In the 000.sc (Main.sc) the only reference I can see is this. I cant seem to find pc8088 defined anywhere else?

Code: [Select]
(if (> scoreDisplayed score)
(if (> machineSpeed pcAT)
(-- scoreDisplayed)
else
(= scoreDisplayed score)
)
(StatusLine doit:)
)

(if (< scoreDisplayed score)
(if (> machineSpeed pcAT)
(++ scoreDisplayed)
else
(= scoreDisplayed score)
)
(StatusLine doit:)
)


So I've defined gMachineSpeed in my main.sc under the local section and in my script I'm using it. It does not seem to work properly. It does not load the view on both IBM XT and 486. It should load the view on the 486 as its a faster machine. How does it know the the machine speed is greater than 16? What is it using to know this? Am I missing something? Do I need to define this in another script?

Code: [Select]
; Machine speed used for real hardware
gMachineSpeed


Code: [Select]
(if (> gMachineSpeed 16)
(aFountain init:)
)



Offline Kawa

Re: MachineSpeed syntax on real hardware
« Reply #1 on: August 17, 2023, 01:14:47 PM »
There is indeed another script that sets the machine speed. It seems to be determined in script 290. Defined Al Lowe speed ratings are 16 - 8088, AT - 39, 386 - 69, and 25Mhz 386 - 90.

Offline robbo007

Re: MachineSpeed syntax on real hardware
« Reply #2 on: August 17, 2023, 05:08:57 PM »
Thanks :)

So I see this is the relevant code? Could I add that to main.sc to apply it globally? Or would I need to call it from another script? What I can't find is how its calling script 290.  hmmm Where did you find the Al Lowe defined speeds?

Code: [Select]
(method (doit)
(super doit:)
(if (== (++ gMachineSpeed) 1)
(= doneTime (+ 60 (GetTime)))
)
(if (< doneTime (GetTime))
(if gDebugging
(gGame setSpeed: 2)
else
(gGame setSpeed: 6)
)

I just saw this:
Code: [Select]
(cond
((GameIsRestarting)
(= testRoom 290)
)

Regards,
« Last Edit: August 17, 2023, 05:10:32 PM by robbo007 »

Offline Kawa

Re: MachineSpeed syntax on real hardware
« Reply #3 on: August 17, 2023, 05:30:09 PM »
I found them in the LSL3 source code. The original, not the decompile. You don't want to put that in Main, trust me. 290 is a speed test room, much like the one in so many other SCI games. The room tries to walk an all-black view around an all-black screen and figures out how long it takes for 60 game ticks to to pass while wasting CPU cycles drawing a black square on black. The black square walks up to an X of 3000 just so there's enough time for the speed test to run.

Code: [Select]
(method (init)
(HandsOff)
(StatusLine disable:)
(TheMenuBar hide:)

(super init)
(ego
view: scriptNumber
posn: 20 100
setStep: 1 1
setMotion: MoveTo 3000 100
setCycle: Walk ;even though view.290 has only one frame, the overhead of a Cycler makes the simulation more realistic.
init:
)
(theGame setSpeed: 0)
)
(method (doit)
(super doit:)

;EO: The reason for the speed bugs is that
; the speed tester didn't account for newer machines.
; Later games fixed this by using the howFast global,
; with only a few possible values and an upper limit.

(++ machineSpeed)
(if (== machineSpeed 1)
(= doneTime (+ 60 (GetTime)))
)
(if ( < doneTime (GetTime))
; 60 ticks have elapsed; set up the game
(theGame setSpeed 6) ;do you really need the debug alternative?
(TheMenuBar draw:)
(StatusLine enable:)
(curRoom newRoom: 200) ;first real room
)
)

Offline robbo007

Re: MachineSpeed syntax on real hardware
« Reply #4 on: August 18, 2023, 08:36:01 PM »
ok thanks. I've added it to my InitRooms.sc and it works perfectly. Where did you see the Al Lowe ratings? "Defined Al Lowe speed ratings are 16 - 8088, AT - 39, 386 - 69, and 25Mhz 386 - 90. ?" I've not found where they are yet.

I've now got to go over all my code and adapt for machine speed. I'm thinking instead of removing the view for the slow IBM XT possibly having it static, no animation view. Not sure if it will work. I need to test it.

Offline lskovlun

Re: MachineSpeed syntax on real hardware
« Reply #5 on: August 18, 2023, 09:41:45 PM »
ok thanks. I've added it to my InitRooms.sc and it works perfectly. Where did you see the Al Lowe ratings? "Defined Al Lowe speed ratings are 16 - 8088, AT - 39, 386 - 69, and 25Mhz 386 - 90. ?" I've not found where they are yet.
They are in game.sh.
I've now got to go over all my code and adapt for machine speed. I'm thinking instead of removing the view for the slow IBM XT possibly having it static, no animation view. Not sure if it will work. I need to test it.
This is what the stopUpd method is for. It relieves the graphics engine of the work associated with an actually animating view.

Offline Kawa

Re: MachineSpeed syntax on real hardware
« Reply #6 on: August 19, 2023, 02:57:59 AM »
This is what the stopUpd method is for. It relieves the graphics engine of the work associated with an actually animating view.
Can confirm! For example in my game, the surf on the beach spans across the whole screen and comes in at random intervals. The "idle" surf is still a part of the view, though. So when it's in its idle state, I stopUpd it! This way my cursor only flickers when it overlaps the surf when it comes in.

In many Sierra games, they'd have these animated background elements and stopUpd-ed them for slower computers/low detail settings.

Offline robbo007

Re: MachineSpeed syntax on real hardware
« Reply #7 on: August 19, 2023, 05:33:12 PM »
ok, thanks. So from what I've seen in the LSL3 source code they just stopped the init of the view if the speed is like an IBM XT.
How would you use the stopUpd on a view to not animate if the PC is an XT and to animate if using a faster CPU? Would you define something in the method of the instance of the prop?
Thanks,

Offline Kawa

Re: MachineSpeed syntax on real hardware
« Reply #8 on: August 20, 2023, 01:52:15 AM »
If you want it to not appear, have the room check for slow systems and not init the view at all. If you want it to be there but not animate, init the view but then stopupd or maybe even addtopic it.

Fun related fact, the amount of can-can dancers in LSL1 VGA depends entirely on your detail level, whose initial value is determined by a speed test not unlike this one.

Offline robbo007

Re: MachineSpeed syntax on real hardware
« Reply #9 on: August 21, 2023, 12:08:10 PM »
Nice. I got it working :)

Code: [Select]
(if (> gMachineSpeed pc8088) (aSign init: startUpd:)
else
(aSign init: cel: 3 stopUpd:)
)

Now I just need to add it to your wave script. That script is a speed killer for an IBM XT haha...:)

Offline robbo007

Re: MachineSpeed syntax on real hardware
« Reply #10 on: August 21, 2023, 04:51:44 PM »
Right, and I think this is the Kawa wavescript tweaked to only run on a machine faster than a XT. Seems to stop the script from loading on an XT. Works on everything else.

Code: [Select]
(instance aWave of Prop
(properties
view vRoom
loop lWave
x 106
y 167
cycleSpeed 15
)

(method (init)
(super init:)
(self
setPri: 1
setScript:(if (> gMachineSpeed pc8088)aWaveScript)
stopUpd:
)
)
)


Offline robbo007

Re: MachineSpeed syntax on real hardware
« Reply #11 on: May 01, 2024, 11:26:23 AM »
So I've advanced a little more since this original posting. The machine speed code work perfectly throughout my rooms. I've now setup the following scripts to start my game in order.

1. Title script 800 holds the title sequence which has some animations I need to speed check. It stops at a menu to start the game.
2. Then start is pressed it loads script 799 which is my age check and trivia script. Once complete.
3. Loads Initrooms_script which does my speed check for slower systems then starts the game with room 029.

I need to also be able to apply the gMachineSpeed to the Titlescript animations as on slower systems its too slow. As I'm running the speed check after the titlescript its obliviously not working. What other scripts are loaded before the titlescript? Should I add the speed check code to the start of the titlescript so it runs that first before anything else? Or is there a better way to do this?

Regards,


Offline Kawa

Re: MachineSpeed syntax on real hardware
« Reply #12 on: May 01, 2024, 11:45:55 AM »
You would do that, yeah. It'd only make sense.

Offline robbo007

Re: MachineSpeed syntax on real hardware
« Reply #13 on: May 02, 2024, 05:30:42 PM »
ok, getting some weird stuff happening now. It seems it does not end the speed checker correctly before starting my normal title script code.
I've added the speed checker code (method (init) to the start of my Instance of TitleSCreen of Rm and my normal titlescreen Method is after it. 

Is that the correct way to do it? Have multiple methods ?


Code: [Select]
(instance TitleScreen of Rm
(properties
picture 800;scriptNumber 800
)

(method (init)
(ProgramControl)
(= gProgramControl FALSE)
(SL disable:)
(TheMenuBar hide:)
(super init:)
(gEgo
view: 290
posn: 20 100
setStep: 1 1
setMotion: MoveTo 3000 100
setCycle: Walk ;even though view.290 has only one frame, the overhead of a Cycler makes the simulation more realistic.
init:
)
(gGame setSpeed: 0)
)

(method (doit)
(super doit:)
;EO: The reason for the speed bugs is that
; the speed tester didn't account for newer machines.
; Later games fixed this by using the howFast global,
; with only a few possible values and an upper limit.
(if (== (++ gMachineSpeed) 1)
(= doneTime (+ 60 (GetTime))) ; 60 ticks have elapsed; set up the game
)
(if (< doneTime (GetTime))
(gGame setSpeed: 6) ;do you really need the debug alternative?
(= gTimeSeconds 0)
(= gTimeMinutes 0)
(= gTimeHours 0)
(= gEgoView 0)
;(TheMenuBar draw:)
;(PlayerControl)
;(SL enable:)
;;; (if (!= -1 gDebugStartRoom)
;;; (DebugRoomInit gDebugStartRoom)
;;; ; The debug start room
;;; (gRoom newRoom: gDebugStartRoom)
;;; else
; The normal start room
;(gRoom newRoom: 29) ;Start ego at Vivir Sin Dormir

;;; )
;;; )
;;;
)

)
(method (init)
; Set up the title screen
(= gDefaultPalette 0)
(ProgramControl)
(= gProgramControl TRUE)
(gGame setSpeed: 4)
(SL disable:)
(SetCursor gLoadingCursor (HaveMouse))
(TheMenuBar hide:)
(super init:)
(self setScript: RoomScript)
(gEgo init: hide:)
;(theTitle init: hide:) ;taken out not needed
;(theTitle2 init: hide:) ;taken out not needed
(if (> gMachineSpeed pc386)) ;this stops wave script if PC is a IBM AT
(theSpark1 init: setCycle: End)
(if (> gMachineSpeed pc386)) ;this stops wave script if PC is a IBM AT
(theSpark2 init: setCycle: Fwd)
(theSpark3 init:)
)
)

EDIT: I've also tried creating a new instance called TitleScreen2 and changing the order in the public syntax. I'm not sure how to stop and instance statement and make it goto the second instance statement? As it loads the speed checker code but does not then continue to the next instance.

Code: [Select]
(public
TitleScreen 1
TitleScreen2 0
)
« Last Edit: May 02, 2024, 06:31:55 PM by robbo007 »

Offline doomlazer

Re: MachineSpeed syntax on real hardware
« Reply #14 on: May 02, 2024, 07:16:53 PM »
I might be misunderstanding you, but it sounds like you're expecting the public exports of TitleScreen and TitleScreen2 to be executed sequentially, which doesn't happen. You've commented out the "newRoom: 29" command, so the TitleScreen Doit has nothing to trigger when 60 ticks have passed.

You might be able to call (TitleScreen2 init:) in place of newRoom: 29 to get this working, but I'd suggest separating the speed test into its own room, like in LSL3.

You want to go from the game init in Main directly to the speed check room, then go to your titleScreen room.


« Last Edit: May 02, 2024, 08:00:43 PM by doomlazer »


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.038 seconds with 23 queries.