Author Topic: King's Quest 6 Debug Mode (previous subject was: "Compilation error help")  (Read 1334 times)

0 Members and 1 Guest are viewing this topic.

Offline OmerMor

I'm trying to re-compile a decompiled script (KQ6 Spanish, script# 921).

The compiler gives the following error:
Quote
[Error]: &rest cannot be used if the send target itself contains nested procedure calls or sends. Assign the result of the procedure call or send to a temporary variable and use that instead.  Line: 17, col: 42

The relevant procedure is this:
Code: [Select]
(procedure (proc921_0 &tmp newPrint)
((= newPrint (Print new:)) addText: &rest init:)
)

I've got 2 questions:
  • Why does the decompiler output this if it's not valid?
  • What can I do to fix this?
« Last Edit: February 27, 2016, 04:47:15 PM by OmerMor »



Offline Kawa

Re: Compilation error help
« Reply #1 on: February 26, 2016, 04:57:59 PM »
I remember that. Split it up.
Code: [Select]
(procedure (proc921_0 &tmp newPrint)
(= newPrint (Print new:))
(newPrint addText: &rest init:)
)

Offline OmerMor

Re: Compilation error help
« Reply #2 on: February 26, 2016, 05:42:37 PM »
Thanks!
That did the trick.

I've been able to find and enable a debug menu for King's Quest 6. But it only works with the Spanish and Italian versions.
Every other versions crashes. I'll add more information tomorrow, and maybe together we'll be able to coerce these versions to work as well.
« Last Edit: February 27, 2016, 02:21:38 PM by OmerMor »

Offline OmerMor

Re: Compilation error help
« Reply #3 on: February 27, 2016, 03:28:32 PM »
OK, so here's what I've been doing:

I found that KQ6 is checking for the existence of the file 911.SCR as a trigger for an internal debug menu:

n0.sc:
Code: [Select]
(Format @temp0 0 0 911)   ; temp0 <-- "911.scr"
(if (FileIO fiEXISTS @temp0)
(= global100 1)
else
(= global100 0)
)

However most KQ6 versions no longer contain script# 911. The only versions that still has it are the Spanish and Italian ones.
I tried extracting 911.scr, and scummvm crashes because Print::addEdit in script# 921 is doing uninitialized read from temporary variables:
Code: [Select]
(method (addEdit param1 param2 param3 param4 param5 &tmp temp0 temp1)
(if (not dialog) (= dialog (Dialog new:)))
(StrCpy param1 (if (> argc 4) param5 else {}))
(if (> argc 2)
(= temp0 param3)
(if (> argc 3) (= temp1 param4))
)
(dialog
add:
((DEdit new:)
text: param1
max: param2
setSize:
moveTo: (+ temp0 4) (+ temp1 4)
yourself:
)
setSize:
)
)

This was easily fixed by initialized temp0 and temp1 to 0.
I tried to compile n921.sc but failed on the error from the start of this thread.
Kawa's tip was extremely helpful, and I managed to get the debug menu.
Great!

I now tried to backport this to the English versions of KQ6. I copied 911.* and 921.* to the game's folder.
Scummvm crash on start with the following error (floppy version):
  ERROR: Send to invalid selector 0xcd of object at 0001:1d56!

The backtrace gives the following:
Code: [Select]
...
6: script 99 - speedRoom::init()
    by 5 obj@0030:026b pc=0030:0065 sp=ST:002a fp=ST:0029 argp:ST:0028
7: script 911 - export 1 ()
    by 6 obj@0030:026b pc=0032:0024 sp=ST:0035 fp=ST:002b argp:ST:002a

frame 6's instruction is
  0030:005f: calle 038f 0001 00.

frame 7's instruction is
  0032:0024: send 06
  Kq6::addButton[INVALID](0001:2070)


Here's sv.exe for 911:export_1 :
Code: [Select]

; export911_1
code_0012: link $7
ldi $0
sat temp[$2]
ldi $0
sat temp[$1]
pushi $cd ; 205, setCursor
push1
lsg global[$14]
lag global[$1]
send $6

The decompiled snippet is:
Code: [Select]
(procedure (proc911_1 &tmp temp0 temp1 [temp2 5])
(= temp2 0)
(= temp1 0)
(gKq6 setCursor: gArrowCursor)

So it seems like problem is that Kq6::setCursor from Spanish-KQ6 is mapped to Kq6::addButton in English-Kq6.

Offline OmerMor

Re: Compilation error help
« Reply #4 on: February 27, 2016, 03:38:26 PM »
OK, it's not mapped to Kq6::addButton because there's no such method. It's probably just scummvm choking on this selector (0001:00cd).
I verified that in english kq6, Kq6::setCursor is located in [0c5] while in spanish kq6, Kq6::setCursor is located in [0cd] as expected.

So I guess for the 911.scr to be usable in english KQ6, it would have to be recompiled with this version.
I hope I'll manage to do that.

Offline OmerMor

Re: Compilation error help
« Reply #5 on: February 27, 2016, 03:58:57 PM »
Yay - success!  8) 8) 8)
I attached the debug script + fixed 921 (Print) script.
It is compatible with the English floppy version of King's Quest 6.

For extra credit, create an empty file named "g" in the game's folder.
When the game starts - enter one of these room number: {470, 480, 740, 750}. They all check for the existence of the "g" file, and give extra options.

Offline Kawa

Re: Compilation error help
« Reply #6 on: February 27, 2016, 04:05:45 PM »
lol "stud". I think the Carlosbashing in LSL6 was funnier for sheer scope but "where to stud" gets a good second place.

Offline MusicallyInspired

Re: King's Quest 6 Debug Mode (previous subject was: "Compilation error help")
« Reply #7 on: February 27, 2016, 04:58:12 PM »
Nice, Omer!!
Brass Lantern Prop Competition

Offline Collector

Re: King's Quest 6 Debug Mode (previous subject was: "Compilation error help")
« Reply #8 on: February 27, 2016, 05:00:55 PM »
I need to add 'magic' files to the Wiki's debug page.
KQII Remake Pic


SMF 2.0.14 | SMF © 2017, Simple Machines
Simple Audio Video Embedder

Page created in 0.099 seconds with 24 queries.