Community

SCI Programming => SCI Development Tools => Topic started by: EricOakford on November 26, 2018, 10:21:07 PM

Title: SCI01 Template Game
Post by: EricOakford on November 26, 2018, 10:21:07 PM
After a bit of work, here is my SCI01 template game!
I based it off the QFG2 demo, and used the interpreter from the EGA 1990 Christmas Card.

The choice of the interpreter was an important one - it's the last pre-1991 interpreter, and still has its internal debugger on top of that!

11/27/2018 EDIT: I solved the problem with the game not recognizing new words -- SCI Companion thought the parser vocab was 000 instead of 900. To fix this, I went into the version detector and set the parser vocab to 900. Now it recognizes new words!

1/16/2019 UPDATE: The template (https://github.com/EricOakford/SCI01-Template) is now on Github! From now on, you can get it there and make updates to it.
TODO
Work on R44Q SCI01 remake (I can do the scripting, but I can't do the graphics all that well).
Title: Re: SCI01 Template Game
Post by: lskovlun on November 27, 2018, 02:47:20 AM
After a bit of work, here is my SCI01 template game!
I based it off the QFG2 demo, and used the interpreter from the EGA 1990 Christmas Card.

One problem I came across was the fact that when adding new words to the vocab file, the compiler works fine with the new words, but the game doesn't recognize them. A problem with the vocab editor?
Could be a problem with VOCAB.901 ... ScummVM refuses to load the demo at all, complaining about a problem with said resource. Perhaps the reading and subsequent writing by Companion silently exacerbates this somehow. Or more likely, SSCI lets this pass because the parser isn't really used in the demo. Of course if any of this is the case, taking the VOCAB files from a different (SCI01) game ought to work.
Title: Re: SCI01 Template Game
Post by: MusicallyInspired on November 27, 2018, 08:32:46 AM
Nice! Now I gotta migrate KQ2SCI to SCI01. ;)
Title: Re: SCI01 Template Game
Post by: OmerMor on November 27, 2018, 02:39:16 PM
Nice!
Would it be possible to also support the VGA SCI01 version of the 1990 Christmas Card?
That would allow for developing VGA parser based games.

See here for troflip's proof of concept: http://sciprogramming.com/community/index.php?topic=1553 (http://sciprogramming.com/community/index.php?topic=1553)
And some history: http://sciprogramming.com/community/index.php?topic=27.0 (http://sciprogramming.com/community/index.php?topic=27.0)
Title: Re: SCI01 Template Game
Post by: Collector on November 27, 2018, 07:12:41 PM
Then we would just need an SCI1.0 template.
Title: Re: SCI01 Template Game
Post by: Kawa on November 28, 2018, 05:32:05 AM
Then we would just need an SCI1.0 template.
On it.

Edit: aaaand the interpreter is convinced I want the invalid language code -10031.
Title: Re: SCI01 Template Game
Post by: lskovlun on November 28, 2018, 07:24:17 AM
Then we would just need an SCI1.0 template.
Nah, SCI32 is missing too.
Title: Re: SCI01 Template Game
Post by: MusicallyInspired on November 28, 2018, 08:21:20 AM
I wish I could translate assembly. I just cannot do it. I've made a lot of progress modifying KQ5floppy, but I can't alter the Main script for this reason.
Title: Re: SCI01 Template Game
Post by: Kawa on November 28, 2018, 10:05:02 AM
Redid the thing, up to the point where it broke last time. Made a backup, and a backup of the backup. So let's see what we can whittle off next, hmm?
Title: Re: SCI01 Template Game
Post by: Collector on November 28, 2018, 10:33:12 AM
Then we would just need an SCI1.0 template.
Nah, SCI32 is missing too.

Of course, but since Companion does not support anything higher than 1.1, so I was not considering anything higher. Not sure if its compiler would have any issues with 0.1 or 1.0 games, either. As fantastic as it would be to have Companion fully work with and create all SCI versions we cannot count on anything higher than what we have now.
Title: Re: SCI01 Template Game
Post by: Kawa on November 28, 2018, 03:44:32 PM
I give up. I try to remove all but one of the inventory items, game won't start -- get either an invalid language code (whaaat?) or Oops 4. I don't edit LLinvItem.sc at all and merely recompile it, I get error 4. Which is weird cos I've recompiled all of this several times before?

So I figure I'll go edit rm100.sc instead, turn the polygons into a .shp file so the editor and my &getpoly command can handle them. This after removing events like the cop, clap, cab, and cars. That worked fine.

Oops, error 4.

So fuggit, you figure it out.
Title: Re: SCI01 Template Game
Post by: EricOakford on November 28, 2018, 08:48:14 PM
Here's the new version of the SCI01 template! It fixes a few bugs (such as GetNumber not working properly) and I have gone through most of the system scripts! They now closely match that of the SCI16 scripts (taking into account the SCI01 differences, of course) Everything seems to compile and play fine now.
Title: Re: SCI01 Template Game
Post by: Kawa on November 28, 2018, 09:24:03 PM
...Maybe I'll try another game...
Title: Re: SCI01 Template Game
Post by: MusicallyInspired on November 29, 2018, 07:59:28 PM
I'm definitely going to look into migrating my KQ2SCI project over to this at some point if the kinks have all been worked out. It's been so long, I can afford to start from scratch on a few things. I really want those moving screen transitions.
Title: Re: SCI01 Template Game
Post by: OmerMor on November 30, 2018, 03:09:05 AM
Eric, I managed to easily convert your template to VGA SCI01.
I created a github repository for it here: https://github.com/OmerMor/SCI01-VGA-Template

Now we can start making parser-based VGA games!  8)
Title: Re: SCI01 Template Game
Post by: MusicallyInspired on November 30, 2018, 07:45:27 AM
:O
Title: Re: SCI01 Template Game
Post by: Kawa on December 03, 2018, 06:39:05 PM
Y'know what? I think the one thing better than a VGA SCI01 template to make parser-based VGA games in is one that's based on SCI11, considering the different levels of support in SCI Companion and certain runtime stability issues I've noticed when I first hacked The Seasoned Professional.

There's a folder in SCI16-master named NL. It is clearly parser code, but I have little to no clue how to integrate it into SCI11. I could study it a whole bunch and give it my best shot, of course.

The other option depends on the availability of SCI01 source code. After all, if it's already integrated into the one engine, it'd be almost trivial to get it in the other. Okay, maybe not that trivial, but certainly compared to figuring out the NL folder, I'd bet.

Title: Re: SCI01 Template Game
Post by: lskovlun on December 04, 2018, 05:44:44 AM
You're gonna have at least one problem: Where to place the said strings. Remember, the script format was redesigned in SCI1.1; you could place them with the strings and hope that nothing else breaks, but I'm not sure about that.
Title: Re: SCI01 Template Game
Post by: Kawa on December 04, 2018, 10:05:30 AM
You're gonna have at least one problem: Where to place the said strings. Remember, the script format was redesigned in SCI1.1; you could place them with the strings and hope that nothing else breaks, but I'm not sure about that.
... fffffffuuuu-


I ain't even mad.
Title: Re: SCI01 Template Game
Post by: OmerMor on December 04, 2018, 04:30:02 PM
The other option depends on the availability of SCI01 source code.

Unfortunately I have not managed to get SCI interpreter source earlier than SCI16.
Title: Re: SCI01 Template Game
Post by: EricOakford on December 17, 2018, 09:23:20 PM
I've completed the death handler! Here is the procedure. None of that "Order a Hintbook" nonsense, and all of the Sierra Script.

Code: [Select]
(procedure (Die message &tmp buttonPressed)
;This procedure handles when Ego dies. It closely matches that of QFG1EGA.
;To use it: "(Die {death message})". You can add a title and icon in the same way as a normal Print message.
(LockEgo)
(curRoom setScript: 0)
(Wait 100)
(SFX stop:)
(music number: deathSound play:)
(repeat
(= buttonPressed
(Print message
#button {Restore} 1
#button {Restart} 2
#button {__Quit__} 3
&rest
)
)
(switch buttonPressed
(1
(if (!= (theGame restore:) 0) (return))
)
(2 (theGame restart:) (return))
(3 (= quit TRUE) (return))
)
)
)
Title: Re: SCI01 Template Game
Post by: lskovlun on December 17, 2018, 10:20:10 PM
You'll probably want to change the code so it accepts far strings at least, or maybe both. Having to put death messages on the heap could become a memory drain if you plan on having as many deaths as usual in a Sierra game  :)
Title: Re: SCI01 Template Game
Post by: Kawa on December 18, 2018, 05:53:59 AM
It's that repeat statement that messes up so many functions, isn't it?
Title: Re: SCI01 Template Game
Post by: lskovlun on December 18, 2018, 06:23:28 AM
It was at one point. I'm not sure whether it still is.
Title: Re: SCI01 Template Game
Post by: Kawa on December 18, 2018, 07:15:26 AM
One way to find out.

*decompiles QFG1 script 0*
Code: [Select]
Decompiling script 0
WARNING:  ::proc0_1: Analyzing control flow: Expected node with two successors (then/else): 1 at 1121
Falling back to disassembly for proc0_1
WARNING:  ::proc0_31: Analyzing control flow: Inconsistent then/else branches. Possible "continue" statement?: 1 at 1835
Falling back to disassembly for proc0_31
Generated c:\users\kawa\documents\scicompanion\quest for glory 1 ega\src\Main.sc
Decompiled 60 of 62 functions successfully (96%).
Overall bytecount success rate: 95%.
Fell back to assembly for the remaining functions.
And blam.
Code: [Select]
(procedure (proc0_1 param1)
(asm
pushi    0
call     proc0_5,  0
pushi    1
pushi    100
callk    Wait,  2
pushi    #setCursor
pushi    2
lsg      global20
pushi    1
lag      gGame
send     8
pushi    #eachElementDo
pushi    1
pushi    132
lag      gSounds
send     6
lag      global325
bnt      code_10da
pushi    #number
pushi    1
push   
pushi    63
pushi    1
pushi    15
pushi    87
pushi    0
pushi    42
pushi    0
lofsa    music
send     20
code_10da:
pushi    11
&rest    param1
pushi    70
pushi    250
pushi    81
lofsa    {Restore}
push   
pushi    1
pushi    81
lofsa    { Restart_}
push   
pushi    2
pushi    81
lofsa    { Quit_}
push   
pushi    3
calle    proc255_0,  22
push   
dup     
ldi      1
eq?     
bnt      code_110f
pushi    #restore
pushi    0
lag      gGame
send     4
jmp      code_112f
code_110f:
dup     
ldi      2
eq?     
bnt      code_1121
pushi    #restart
pushi    0
lag      gGame
send     4
jmp      code_112f
code_1121:
dup     
ldi      3
eq?     
bnt      code_112f
ldi      1
sag      global4
jmp      code_1133
code_112f:
toss   
jmp      code_10da
code_1133:
ret     
)
)
Title: Re: SCI01 Template Game
Post by: OmerMor on December 18, 2018, 09:46:27 AM
Here's the actual EgoDead procedure from QfG2:
Code: [Select]
;*****************************************************
;
; EGODEAD PROCEDURE -- to kill ego off
;
(procedure (EgoDead useRandomIcon  &tmp printRet)
   (HandsOff)
   (Wait 100)
   (= normalCursor ARROW_CURSOR)
   (theGame setCursor: normalCursor TRUE)

   (sounds  eachElementDo: #stop:)     ; Stop any other music
   (if deathMusic
      (miscSound
         number: deathMusic,
         priority: 15,
         loop: 1,
         play:
      )
   )

   (repeat
      (cond
         ((not useRandomIcon)    ; Specfic icon being used
            (= printRet
               (Print
                  &rest
                  #width:  250
                  #button: {Restore}   1
                  #button: {_Restart_} 2
                  #button: {_Quit_}    3
               )
            )
         )
         ((or (== sillyClowns clownsOff)
               (and (== sillyClowns clownsOtto) (not (Random 0 1)))
            )
            ; Give a serious death icon
            (= printRet
               (Print
                  &rest
                  #width:  250
                  #button: {Restore}   1
                  #button: {_Restart_} 2
                  #button: {_Quit_}    3
                  #icon:   vStaticIcons 2 0
               )
            )
         )
         (else
            (cIcon
               loop: (Random 0 1),
               cel: 0,
               cycleSpeed: (if (== loop 1) 20 else 10)
            )

            (= printRet
               (Print
                  &rest
                  #width:  250
                  #button: {Restore}   1
                  #button: {_Restart_} 2
                  #button: {_Quit_}    3
                  #icon:   cIcon
               )
            )
         )
      )

      (switch printRet
         (1
            (theGame restore:)
         )
         (2
            (theGame restart:)
         )
         (3
            (= quit TRUE)
            (break)
         )
      )
   )
)
Title: Re: SCI01 Template Game
Post by: Kawa on December 18, 2018, 02:18:12 PM
Just casually drop that procedure in there like no big deal  ::)
Title: Re: SCI01 Template Game
Post by: EricOakford on December 21, 2018, 09:33:53 PM
Here is the third release of the SCI01 Template!

Various bug fixes (thanks to my work on R44QSCI, which revealed some scripting errors when changing rooms), more original Sierra names for procedures, and the death message procedure are all here.
Title: Re: SCI01 Template Game
Post by: MusicallyInspired on December 22, 2018, 10:05:49 AM
Wicked.
Title: Re: SCI01 Template Game
Post by: EricOakford on January 16, 2019, 08:51:02 PM
To make it easier for others to update, I've placed the template game at Github. I think it's mature enough for that now.

Here it is (https://github.com/EricOakford/SCI01-Template).
Title: Re: SCI01 Template Game
Post by: Collector on January 16, 2019, 10:42:48 PM
Now we need an SCI1 template.

I like how you have included all of the drivers and install related files that Brian deleted from his original template game.
Title: Re: SCI01 Template Game
Post by: Kawa on January 17, 2019, 08:27:09 AM
I must've tried twice but it kept breaking.
Title: Re: SCI01 Template Game
Post by: OmerMor on January 17, 2019, 01:12:20 PM
To make it easier for others to update, I've placed the template game at Github. I think it's mature enough for that now.

Here it is (https://github.com/EricOakford/SCI01-Template).

Moving to Github is great.
Would you like to take ownership on the SCI01-VGA template as well? I already uploaded it to Github: https://github.com/OmerMor/SCI01-VGA-Template (https://github.com/OmerMor/SCI01-VGA-Template)
The only diff so far is the addition of PALETTE.999 and replacing the interpreter.
Title: Re: SCI01 Template Game
Post by: EricOakford on January 17, 2019, 08:28:37 PM
The VGA version is now in its own branch. (https://github.com/EricOakford/SCI01-Template/tree/SCI01-VGA)
Title: Re: SCI01 Template Game
Post by: OmerMor on January 18, 2019, 02:21:38 AM
Thanks!
Title: Re: SCI01 Template Game
Post by: EricOakford on January 21, 2019, 08:51:01 PM
It looks like I discovered a bug in the template. When saving a game, then restoring it, certain things in the menu are messed up. Here are some screenshots of the glitchy behavior. Memory leak? Something wrong with SAVE.SC or restoring of a save? These only happen after restoring a game; they don't happen when starting a new game.

Also, when saving a game, then saving another with the same description, it sometimes doesn't overwrite the previous save, but saves a new file instead.
Title: Re: SCI01 Template Game
Post by: lskovlun on January 21, 2019, 11:18:47 PM
Yes, the saving code seems to be at fault somehow. After saving the game twice in succession I have this in my template directory:
Code: [Select]
lars@starfish:~$ ls -l ~/SCI01-Template/SCI01SG*
-rw-r--r-- 1 lars lars 7771 jan 22 05:06 /home/lars/SCI01-Template/SCI01SG.000
-rw-r--r-- 1 lars lars 7884 jan 22 05:07 /home/lars/SCI01-Template/SCI01SG.213  <- BAD!
-rw-r--r-- 1 lars lars   14 jan 22 05:07 /home/lars/SCI01-Template/SCI01SG.DIR
The Sierra SCI interpreter only supports 20 games. Apparently memory corruption can occur if you try to save a game with number 213 :) I would guess the actual corruption takes place inside the SaveGame kernel call, which does little in the way of error checking (or else one of the other saving-related kernel functions). So the way forward should be to figure out where that number 213 comes from.

EDIT: Also, it may be a good idea to delete your savegame files frequently while investigating this. The mere presence of a file like the above could be a problem.
Title: Re: SCI01 Template Game
Post by: lskovlun on January 22, 2019, 03:22:51 AM
Also, isn't the behavior of saving two games with the same title wrong to begin with? as though something is compiled or decompiled wrongly. I strongly recall being able to reuse the latest savegame slot simply by pressing <F5> <ENTER>. And if nobody changed it knowingly...
Title: Re: SCI01 Template Game
Post by: troflip on January 22, 2019, 04:20:00 PM
I think you can save multiple games with the same title...

From what I recall, the save dialog and the selector control do some weird things with embedding multiple strings in one string (a double-null terminated list of null-terminated strings). That might a place to look...
Title: Re: SCI01 Template Game
Post by: lskovlun on January 23, 2019, 04:36:41 AM
I think you can save multiple games with the same title...
I was referring to the fact that if you press ENTER without changing the title in SSCI, the latest slot will be reused. Quite handy if you need to maneuver ego along a difficult path, for instance. This is somehow different in the SCI01 template, probably indicative of the corruption. Unless it was changed knowingly, as I wrote.

Hmm, trying it again just now, that effect stops after the second save. Curious. And of course ScummVM is no help here, as it handles saving differently.
Title: Re: SCI01 Template Game
Post by: EricOakford on January 23, 2019, 09:47:23 AM
I was referring to the fact that if you press ENTER without changing the title in SSCI, the latest slot will be reused. Quite handy if you need to maneuver ego along a difficult path, for instance. This is somehow different in the SCI01 template, probably indicative of the corruption. Unless it was changed knowingly, as I wrote.

I didn't change anything in SAVE.SC. It was freshly decompiled from Seasoned Professional. Perhaps it got corrupted during decompilation. I saw similar issues in a QFG1EGA decompile. Maybe if the decompiler gets fixed to better handle break statements (so that there's no assembly in the script), we'd be able to easily fix the issue.
Title: Re: SCI01 Template Game
Post by: troflip on January 23, 2019, 02:30:55 PM
I saw similar issues in a QFG1EGA decompile. Maybe if the decompiler gets fixed to better handle break statements (so that there's no assembly in the script), we'd be able to easily fix the issue.

That is unlikely to happen :-)

A more likely outcome is for someone to reconstruct it from the asm, or borrow code from another game that we know works, or use any source code that has been "leaked" for SCI01.
Title: Re: SCI01 Template Game
Post by: EricOakford on January 24, 2019, 08:31:02 PM
Well, I was able to address the issue with the menu glitching up. I moved the restart, quit, and about dialogs to the Main script as procedures. Apparently, Sierra themselves ran into this problem, as this is exactly the way those dialogs are implemented in QFG2.
Also, I've added some fonts from the game demos!  :D
Title: Re: SCI01 Template Game
Post by: lskovlun on January 24, 2019, 10:53:09 PM
Well, I was able to address the issue with the menu glitching up. I moved the restart, quit, and about dialogs to the Main script as procedures. Apparently, Sierra themselves ran into this problem, as this is exactly the way those dialogs are implemented in QFG2.
Also, I've added some fonts from the game demos!  :D
I'd say it's quite unlikely that that is the reason the procedures were in script 0 in QfG2. All you're doing is postponing the problem for someone else to find and scratch their head over.
Title: Re: SCI01 Template Game
Post by: EricOakford on January 25, 2019, 11:55:31 AM
I'd say it's quite unlikely that that is the reason the procedures were in script 0 in QfG2. All you're doing is postponing the problem for someone else to find and scratch their head over.

Then I guess I can't think of anything else, unless somebody fixes the Save script's doit.

Now we need an SCI1 template.

I think I'll start work on that. I've got some leads on possible candidates to use as the basis - the demos for SQ1VGA, PQ3, Conquests of the Longbow... but I think the best demo to use would be Ms. Astro Chicken! It has practically the complete set of SCI1.0 system scripts. Also, the icon bar and the control panel are still intact in the game (just partially disabled for the demo), obviously left over from the full version of SQ4.
Title: Re: SCI01 Template Game
Post by: MusicallyInspired on January 27, 2019, 10:38:50 PM
Why use a demo or minigame at all? The SCI0 template game used LSL3 as a base, IIRC. The SCI11 template game is based on a stripped SQ5. I don't see the issue with basing it on a full game, unless you're just thinking it would be easier to start with less and not have to strip stuff out?

Either way, I'm really looking forward to a SCI1 template game!
Title: Re: SCI01 Template Game
Post by: EricOakford on February 27, 2019, 10:23:37 PM
Okay, I've fixed part of the issue with saving games. Based on what I did for the QFG1VGA decompile, I managed to replace the SRDialog doit with that from SCI16, adapting it for SCI01. Now, the interpreter no longer creates duplicate saves with the same name. But the graphical issue with the menu after restoring a game remains, though. It's probably some kind of buffer overflow.

UPDATE 3/5/2019: And now I've managed to address the graphical issue! What I did was put a space before each menu item in the AddMenus. This was done in KQ1SCI and Codename Iceman.
Title: Re: SCI01 Template Game
Post by: MusicallyInspired on March 10, 2019, 11:27:51 PM
Nice!
Title: Re: SCI01 Template Game
Post by: Doan Sephim on September 17, 2019, 10:01:27 AM
Quick question. I just opened up the template game and have a question.

There appears to be duplicates of resources, like views. When I  rebuild resources, they persist.

I'm not used to this and I don't know if it has advantages, disadvantages, or is completely neutral.

What's the purpose?
Title: Re: SCI01 Template Game
Post by: lskovlun on September 17, 2019, 10:25:21 AM
I assume there'd be a hint in the table view? A bunch of patches lying around would be the most likely.
Title: Re: SCI01 Template Game
Post by: Doan Sephim on September 17, 2019, 10:40:24 AM
I assume there'd be a hint in the table view? A bunch of patches lying around would be the most likely.
That is the case. Suppose I edit a patch. Will that be a problem?
Title: Re: SCI01 Template Game
Post by: MusicallyInspired on September 17, 2019, 11:25:35 AM
I don't think so. I think it just saves over the patch file.
Title: Re: SCI01 Template Game
Post by: EricOakford on September 24, 2019, 09:32:06 PM
Why use a demo or minigame at all? The SCI0 template game used LSL3 as a base, IIRC. The SCI11 template game is based on a stripped SQ5. I don't see the issue with basing it on a full game, unless you're just thinking it would be easier to start with less and not have to strip stuff out?

In both of those templates, they have clear signs of their origins.

SCI0 had the option of window colors (which is specific to LSL3) and the "Order Hintbook" joke option in the death dialog (again, this is only in LSL2 and 3).

SCI1.1 has SQ5's specific fonts, subclasses, and status code.

My main focus was to make my templates as generic and minimalist as possible, and mainly use the stock SCI resources that can be found in game demos. Since they're officially freely available and have minimal game-specific scripts, it makes perfect sense to repurpose those.
Title: Re: SCI01 Template Game
Post by: EricOakford on October 15, 2019, 09:15:08 PM
Hmm... it seems I'd made a commit a month ago, but I'd forgotten to push it! Oops!    :-[

Most of the changes were in the system scripts, thankfully.
The big change here? Support for sorted features! They were used in QFG2.

Now this is as as complete as it can get. Have fun.
Title: Re: SCI01 Template Game
Post by: MusicallyInspired on October 16, 2019, 07:35:17 PM
Nice!