Enterprise Forever
:UK => Programming => Topic started by: gflorez on 2017.October.22. 00:17:25
-
The Point&Click adventure game genre started on Maniac Mansion for the C64 and spread easily over other 8 bit computers based on the 68XX processor family. Then the game and the genre jumped to the 16 bits without even touching one Z80 computer.
Mouse control wasn't planed on the 1987 release, after all that was the precise time when the device was being introduced. But also because in the C64 memory didn't remain space to put the needed mouse driver.
Later in 2009, a C64 enthusiast nicked enthusi made an attempt to put mouse control on the C64 game.
But the best is: to do it he reverse engineered completely the game. First he removed the special disc format, and then he carefully placed all the found data on a NeoRam-GeoRam cartridge image. He explains the process on his release instructions (http://www.pagetable.com/?p=603). A pity he didn't free the code obtained.
The special game image can be downloaded from here (http://csdb.dk/release/?id=84165). I have installed the ViceC64 emulator, as it supports the NeoRam-GeoRam cartridge emulation, and it works flawlessly. Once the image is loaded it must be launched with SYS 57000 or SYS 57E3. He has added mouse control, some extras and has fixed the flagrant errors found, but the game works exactly the same.
As you already know, this game is based on a script language and parser named SCUMM, this first time version 0. The subsequent versions up to 2 where made for the other computers conversions, removing the "C64 only" characteristics on Maniac Mansion(like SID music, side scroll, hardware sprites or graphic modes) to make SCUMM more portable. Later on, new games added more and more characteristics to SCUMM, up to version 8.
The NeoRam-GeoRam cartridge is a Ram expansion, but the NeoRam version has a battery to maintain the memory content. It works paginating 16Kb segments like the Enterprise memory. I have peeked the image with an Hex editor, and all the information is there completely accessible without protections. Probably even the SID songs can be easily extracted and converted.
-
I have found a disassembly of the Maniac Mansion script here (https://github.com/segrax/Maniac.Mansion.Disassembly). It is not the code of the program, much better, the rules that govern its behaviour.
It even has several maps of the game:
[attach=1]
-
The scripts seem to match the real content of the NeoRam image:
[attachimg=1]
Observe: 40h cutscene()
6001h cursorCommand(kModeKeypad)
0C01h loadSound(1)
5301h lockSound(1)
0C3Ah loadSound(58)
533Ah lockSound(58)
..........etc.
-
Now I have found the entry point of the NeoRam image, 00000h at the image is DE00h at the processor's memory:
ORG = DE00
DE00 78 SEI
DE01 A2 1A LDX #$1A
DE03 BD 00 DE LDA $DE00,X
DE06 8D 00 08 STA $0800
DE09 E8 INX
DE0A F0 06 BEQ $DE12
DE0C EE 07 DE INC $DE07
DE0F 4C 03 DE JMP $DE03
DE12 A9 00 LDA #$00
DE14 8D 07 DE STA $DE07
DE17 4C 00 08 JMP $0800
DE1A A9 00 LDA #$00
DE1C 8D FF DF STA $DFFF
DE1F 8D FE DF STA $DFFE
DE22 AD CE DE LDA $DECE
DE25 85 02 STA $02
DE27 AD 11 D0 LDA $D011
DE2A 29 EF AND #$EF
DE2C 8D 11 D0 STA $D011
DE2F AD 91 08 LDA $0891
DE32 8D 93 08 STA $0893
DE35 29 3F AND #$3F
DE37 8D FE DF STA $DFFE
DE3A AD 92 08 LDA $0892
DE3D 0E 93 08 ASL $0893
DE40 2A ROL A
DE41 0E 93 08 ASL $0893
DE44 2A ROL A
DE45 8D FF DF STA $DFFF
DE48 A2 00 LDX #$00
DE4A BD 00 DE LDA $DE00,X
DE4D 9D 00 10 STA $1000,X
DE50 E8 INX
DE51 D0 F7 BNE $DE4A
DE53 EE 35 08 INC $0835
DE56 EE 91 08 INC $0891
DE59 D0 03 BNE $DE5E
DE5B EE 92 08 INC $0892
DE5E AD 35 08 LDA $0835
DE61 C9 40 CMP #$40
DE63 D0 B5 BNE $DE1A
DE65 4C 00 10 JMP $1000
DE68 .END
But to understand what it does I need to learn some 6510 assembler code, and also how is organised the C64 memory with a NeoRam cartridge.
-
The problem is that this is a huge work, the scripts seems to be very useful, but i think it is about 1 year work for 1 person. :(
-
Perfect! the kind of absurd and boring knowledge that I like...
-
Perfect! the kind of absurd and boring knowledge that I like...
It is not boring, and absurd, and I would like to see Maniac Mansion, and Zak Mckraken on EP even I played only 2-3 times with those games on C64, and I am happy if you start it :)
-
I can map and disassemble all zones of the cartridge image, but at the end "somebody" has to overtake the information and convert the game.
Zak Mckraken is version 1 of SCUMM. It is out of my intentions now, but knowing how Maniac Mansion(MM from now on) works will make easier to understand the evolution.
I want to create a new thread for this named "Mapping and disassembling C64's Maniac Mansion".
-
I want to create a new thread for this named "Mapping and disassembling C64's Maniac Mansion".
Done!
-
I want to create a new thread for this named "Mapping and disassembling C64's Maniac Mansion".
We can try :)
-
Ok, chapter one.
First of all I have to explain a little how the GeoRam-NeoRam cartridge works. It takes advantage of a little zone in the C64 memory map used for I/O with interface extensions, from DE00h to DFFFh. The cartridge implements a 256b window on DE00h-DEFFh to read/write the extra memory. To select the visible 256b area two memory registers are provided, DFFFh to select the 16kb block and DFFEh to select the 256b page inside the 16kb block.
A typical cartridge has 512k of memory inside, but can grow up to 4M, i.e. DFFFh will contain from 0 to 31 or up to 255. On the other side DFFEh will hold 0 to 63, the number of possible 256b pages on a 16k block. Both registers are write-only, so the values have to be maintained on the program's variable zone.
------------
Launcher: just at block 0, page 0, there is a little launcher that copies a loader on main memory. The game can be started with SYS 57000, SYS 57E3 OR SYS DE00(I don't know why all the possibilities).
DE00 78 SEI ;disable interrupt
DE01 A2 1A LDX #$1A ;load index register X inmediate with 1Ah
DE03 BD 00 DE LDA $DE00,X ;load A absolute indexed with X, (base address $DE00+X)
DE06 8D 00 08 STA $0800 ;store A absolute on ($0800)
DE09 E8 INX ;increment X
DE0A F0 06 BEQ $DE12 ;branch if 0 so, copy from $DE1A to $DEFF
DE0C EE 07 DE INC $DE07 ;automodified code increments byte at $DE07
DE0F 4C 03 DE JMP $DE03 ;loop ;jump to absolute address
DE12 A9 00 LDA #$00 ;ld A inmediate with $00
DE14 8D 07 DE STA $DE07 ;automodified code restores a $00 byte at $DE07
DE17 4C 00 08 JMP $0800 ;jump to the copied code at $0800
This copies the following 230b chunk from the 256b window to 0800h in main memory and then jumps at it.
Loader:
0800 A9 00 LDA #$00 ;ld A inmediate with $00
0802 8D FF DF STA $DFFF ;selects NeoRam 16k block 0
0805 8D FE DF STA $DFFE ;selects NeoRam 256b page 0
0808 AD CE DE LDA $DECE ; still unknown
080B 85 02 STA $02 ;this address is left unused on stock configuration
080D AD 11 D0 LDA $D011 ;Screen control register #1
0810 29 EF AND #$EF ;11101111b Bit #4: 0 = Screen off
0812 8D 11 D0 STA $D011 ;Screen control register #1
0815 AD 91 08 LDA $0891 ;middle byte address of NeoRam ?
0818 8D 93 08 STA $0893 ;store intermediary value
081B 29 3F AND #$3F ;00111111b 0 to 63 256b pages
081D 8D FE DF STA $DFFE ;selects NeoRam 256b page
0820 AD 92 08 LDA $0892 ;high byte address of NeoRam ?
0823 0E 93 08 ASL $0893 ;\
0826 2A ROL A ; \ take two higher bits of the intermediary byte and
0827 0E 93 08 ASL $0893 ; / put them on the two lower bits of the accumulator
082A 2A ROL A ;/
082B 8D FF DF STA $DFFF ;selects NeoRam 16k block
082E A2 00 LDX #$00
0830 BD 00 DE LDA $DE00,X ;\ transfer 256bytes chunks always from the $DE00-$DEFF
0833 9D 00 10 STA $1000,X ; \ cartridge window, to $1000-$3FFF the code starts
0836 E8 INX ; / at $60C00-$63BFF on the cartridge memory always 16kb
0837 D0 F7 BNE $0830 ;/ block 18h, 24d, and 256b pages from 0Ch-3Bh, 12d-59d
0839 EE 35 08 INC $0835 ; this increases 256b the destination pointer
083C EE 91 08 INC $0891 ; this increases the page on the cartridge pointer
083F D0 03 BNE $0844 ; end of pages on the 16kb block
0841 EE 92 08 INC $0892 ;next 16kb block
0844 AD 35 08 LDA $0835 ;
0847 C9 40 CMP #$40 ;check if end of count
0849 D0 B5 BNE $0800 ;loop
084B 4C 00 10 JMP $1000 ;start the game
084E to 088D:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
088E 4C 00 DE JMP $DE00
0891 0C
0892 06
0893 00
0894 to 08B2:
65 6E 74 68 75 73 69 20 6F 66 20 6F 6E 73 6C 61
75 67 68 74 20 20 20 6F 70 74 69 6F 6E 73 3A
"enthusi of onslaught options:"
08B3 7C
08B4 00
08B5 00
08B6 7C
08B7 to 08E5:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Basically what it does is to load a contiguous zone from the cartridge to main memory at 1000h. This is very good news, because then I can take directly the chunk from the cartridge image and disassembly it externally of WinVice, the emulator and de-bugger I am using.
-
Cool :)
Do you use ICU64, or infiltrator disassembler?
I downloaded them in this weekend, seems to be useful.
-
Being little chunks I have used an online disassembler: masswerk (http://www.masswerk.at/6502/disassembler.html).
But from now on I will need one installed. Thanks for the advice.
-
Being little chunks I have used an online disassembler: masswerk (http://www.masswerk.at/6502/disassembler.html).
But from now on I will need one installed. Thanks for the advice.
I would suggest both of them, ICU works on the fly, the other works on snapshots.
-
I have found a disassembly of the Maniac Mansion script here (https://github.com/segrax/Maniac.Mansion.Disassembly). It is not the code of the program, much better, the rules that govern its behaviour.
It even has several maps of the game:
I know this topic is very old, but I have also wanted to see an Enterprise version of Maniac Mansion for about three decades!
gflorez, are you still on this project?
Rather than disassembling, an approach that suits me better is to use the ScummVM source (https://github.com/scummvm/scummvm) as "documentation".
Based on that, and after a long time, what I've managed to do is create a viewer program for the background graphics of every room.
Not particularly fast (z88dk C implementation), but someone with better skills might be able to improve on that, and at least it proves that maybe it's not an impossible mission after all.
It uses the same data as the one on the C64 floppy disks; conversion of the graphics is done in run time.
Please try it out if you'd like. (I've attached a floppy disk image, because I'm using random access in the data files (EXOS 10), which is apparently not supported by EPFILEIO. Sorry about that.)
-
You have put red my face...
I started the task with a lot of strength... but it always happens that other things more interesting surface....
It seems that you have been more constant than me....
The problem with my approach was that I needed to learn 6502 assembler at the same time.... and I only have little Z80 knowledge.
Maybe it will be better to support your more advanced work. Thanks for sharing it.
-
I started also, and created a z80 code from 6502, but it is full with errors :D :D I got also the data from D64 , now i see there is an extractor :D :D
as i checked the SCUMMVM , we should implement the SCRIPT V0 for MM, am i right?
-
Hello Geco. How can I execute the disk image? The program has a .COM tag, but it hangs on ISDOS and can't run it
on EXDOS.
-
Hello Geco. How can I execute the disk image? The program has a .COM tag, but it hangs on ISDOS and can't run it
on EXDOS.
It worked me without problem under EXDOS, did you try it on a stock EP128? If yes, this could be the problem, i tried it on a 640K RAM EP.
-
Ah ok, yes... I was attempting it on a 128KB config...
Yes, this is the very first SCUMM game, so I think it is version 0.
EDIT: It is more like that the file doesn't load on an stock EXDOS Rom.
Wonderful work!
-
Sorry Gflorez, I certainly didn't want to ruin your efforts or anything :oops:
Despite having owned (and loved!) an Enterprise, I haven't had very detailed knowledge about its internals or Z80 machine code / assembly; much less so about C64 (which I have never owned).
On the other hand, I had much better understanding of C/C++ as well as a lot of time in 2020 - so this is the result.
Geco: yes, MM uses SCUMM V0. But V1 (which is for C64 Zak McKracken) does not appear to add very many new features: these two versions are often handled together by ScummVM.
However, the new features of V1 might be a bit harder to reimplement for the Enterprise (iirc there is a "change palette" SCUMM-opcode, which is only easy as long as one of the lower 8 Enterprise colours are to be changed).
About the hanging: What are the symptoms?
My "development environment" was an ep128emu configured with 128K RAM, EXOS2.1 on segment 00h, ASMON1.5 on 04h, BASIC2.1 on 06h, EPFILEIO on 0x10 and EXDOS1.3 on 0x20
(A config similar to the final state of my real Enterprise.)
It also works for me (for now) with only 64k RAM, and/or with only EXOS2.1, BASIC2.1 and EXDOS1.0.
Did you issue the ":DEF_DEV_DISK" command before running? The problem may be that it tries to load the data files from "FILE:", and can't find them.
-
Yes, you are right... Sometimes I seem new on Enterprise....
-
I've made it available on GitHub: enterscumm (https://github.com/dp304/enterscumm), everyone is free to join!
Current contents of the repo:
- The source of the viewer, a bit messy
- Even messier, far from complete and possibly inaccurate, but probably the most important part: my notes about the format of the data disks
- Some BASIC programs for experimenting with palettes&biases with main focus of gray scale and skin tone
- A Python script with functions for quick experimentation. When executed, it will extract .LFLs from the .D64 disk images.