JSW... how does the game "finish" in assembly?

edited May 2008 in Games
It seems the ZX and C64 versions of Jet Set Willy suffer from the same "unfinishable" problem. Thankfully the ZX version has been patched with pokes to fix it, but the C64 version has not. I changed 2 rooms in the C64 version so I can collect the items, so now I think I have all of them...
But nothing happens at the bedroom. Maria has disappeared but the bed is still deadly.
Judging by my experiences changing the room data, a lot of JSW has been ported from the ZX version, perhaps the room data is even byte for byte. What I need to know from this page though...

http://www.geocities.com/andrewbroad/spectrum/willy/disassemblies.html

is what exactly

8F05 3ADF85 LD A, (#85DF) ; All items collected? *** Not MM ***
8F08 E602 AND #02
8F0A 0F RRCA
8F0B AB XOR E

means? No matter what I cheat and set the C64 items total to the bed remains deadly. So perhaps I need to collect the last item and then a trigger is set, rather than touching the bed and then the game checking my items total?
Any musings much appreciated!!
(As I pointed out at c.s.s., I am fully aware of the direness of the C64 port. The stairs and jumping are suckola. I just want to see what the ending is like really!)
Thanks all.
Post edited by DanSolo on

Comments

  • edited April 2008
    I'm afraid I know nothing of all that coding lark... But here's an rzx of the game being completed (on the Speccy):

    http://www.rzxarchive.co.uk/videos/jsw.php

    :smile:
  • edited April 2008
    DanSolo wrote: »
    ...is what exactly

    8F05 3ADF85 LD A, (#85DF) ; All items collected? *** Not MM ***
    8F08 E602 AND #02
    8F0A 0F RRCA
    8F0B AB XOR E

    ...is meaningless in this context. A number gets masked and divided by two making it odd or even and is then mushed with another value!

    Blah!

    NEED MORE INFO!
  • edited April 2008
    It might be meaningless in this context, but to put it in context I would need to post 1000s of lines of disassembly, which I gave a link to anyway.

    85DE 00 DEFB #00 ; number of items collected
    85DF 00 DEFB #00 ; game/item status:
    ; 0: normal
    1: all collected
    2: running from bedroom
    3: in toilet


    8F04 5F LD E, A
    8F05 3ADF85 LD A, (#85DF) ; All items collected? *** Not MM ***
    8F08 E602 AND #02
    8F0A 0F RRCA
    8F0B AB XOR E

    I'm only going by what I know of 6502 assembly, so I guess this part is checking 85DF to see what do next at the end of the game. But can anyone see in this code where 85DF gets set to 1? There is this bit

    8F8F 3ADF85 LD A, (#85DF) ; *** Item to collect? ***
    8F92 CB4F BIT 1, A
    8F94 2026 JR NZ, #8FBC
    8F96 AF XOR A

    but I don't know what it does. Maybe I should go back to the C64 emulator, set the items to 70 or so and collect 15 items. Maybe that will trigger the ending.
  • edited April 2008
    Sorry mate. I need much more info.

    Didn't mean to insult you.
    A = BOLLOCKS!
    
    8F04 5F LD E, A ; what the fuck is in A?
    8F05 3ADF85 LD A, (#85DF) ; All items collected? *** Not MM ***
    8F08 E602 AND #02 ; great - isolate bit 1 of A
    8F0A 0F RRCA ; A now becomes 'odd' or 'even'
    8F0B AB XOR E ; MASH A WITH BOLLOCKS!
    
    A = BOLLOCKS!
    

    WHAT IS BOLLOCKS!

    I need to know what happens before and after these instructions!

    Can you just give me a chuck before and after too!

    Is it a conditional jump or return or does it add a value to beeper tone of reduce your lives or change the border colour or sprite position or end game or pause game or what?

    What does 'A' hold at the start of this code?
  • xxlxxl
    edited April 2008
    DanSolo wrote: »
    But nothing happens at the bedroom. Maria has disappeared but the bed is still deadly.

    hmmm, search something like this:

    no_maria lda POSITION ; Get Willys position
    and #$1F ; Get X coordinate
    cmp #$06 ; Further left than X=6?
    bcs _rts ; Not reached the bed yet
    !!! lda #$02 ; Reached the bed
    !!! sta STATUS ; Set STATUS to 2 to indicate fleeing
    _rts rts
  • edited April 2008
    The way the end-game sequence works in Spectrum-JSW is like this:

    The byte at #85DF is a completion flag with the following values:
    0 => Normal
    1 => All items have been collected
    2 => Willy is running to the right
    3 => Willy's head is down the toilet.

    The code that's already been posted relates to keyboard control (if bit 1 of that byte is set, Willy is not under the player's full control). In the disassembly at http://mdfs.net/Software/JSW/JGH/Docs/jsw48.lst it starts on line 1504 at 8ED4h.

    The code that draws Maria and checks for the start of the end sequence is from 9534h to 9583h. In particular, the very last bit, which xxl has handily translated into 6502 for you. Here it is in the original Z80:
    9576  3AD385  	L9576:		LD	A,(POSITION)	; Get Willy's position
    9579  E61F    			AND	&1F		; Get X coordinate
    957B  FE06    			CP	&06		; Further left than X=6?
    957D  D0      			RET	NC		; Not reached the bed yet
    957E  3E02    			LD	A,&02		; Reached the bed
    9580  32DF85  			LD	(STATUS),A	; Set STATUS to 2 to indicate fleeing
    9583  C9      			RET
    

    Now, to C64-JSW. The code that handles Maria is at 3284h and adds Maria as a guardian:
    3284  AD0004	L3284:	LDA	STATUS
    3287  D04B		BNE	L32D4	;Status is nonzero, don't draw Maria
    3289  A50E		LDA	SHEET
    328B  C923		CMP	#35	;Master bedroom?
    328D  D045		BNE	L32D4	;Not Master bedroom
    ;
    ; [ code that adds Maria to the guardian list ]
    ;
    
    However, unlike in the Spectrum version, I don't immediately see code that sets STATUS to 2 or 3. There doesn't seem to be another check for the room being 35 anywhere else, so if there is victory sequence code I'd expect it to be between 3284h and 32D4h. But all I can see there is Maria raising her arm. Hmm. Perhaps, on the C64 version, the cake is a lie.
  • edited April 2008
    I'm scared
  • edited April 2008
    The code that's already been posted relates to keyboard control (if bit 1 of that byte is set, Willy is not under the player's full control).

    3284 AD0004 L3284: LDA STATUS 3287 D04B BNE L32D4 ;Status is nonzero, don't draw Maria 3289 A50E LDA SHEET 328B C923 CMP #35 ;Master bedroom? 328D D045 BNE L32D4 ;Not Master bedroom ; [/QUOTE] Another player of the C64 version says that Maria does indeed disappear, when you collect over about 50 items, although this is not the total number of items, and there are the another 7 that cannot be collected in the original C64 version. Is it possible the "Maria disappear" and "make bed non-lethal" are different? I'll try to find that status register and all references to it in the 6502 code later. Master Bedroom is hex 23 in C64 version too... Thanks for that... I know what to look for now anyway.[code]
    3284 AD0004 L3284: LDA STATUS
    3287 D04B BNE L32D4 ;Status is nonzero, don't draw Maria
    3289 A50E LDA SHEET
    328B C923 CMP #35 ;Master bedroom?
    328D D045 BNE L32D4 ;Not Master bedroom
    ;

    Another player of the C64 version says that Maria does indeed disappear, when you collect over about 50 items, although this is not the total number of items, and there are the another 7 that cannot be collected in the original C64 version. Is it possible the "Maria disappear" and "make bed non-lethal" are different? I'll try to find that status register and all references to it in the 6502 code later. Master Bedroom is hex 23 in C64 version too...
    Thanks for that... I know what to look for now anyway.
  • edited April 2008
    DanSolo wrote: »
    Is it possible the "Maria disappear" and "make bed non-lethal" are different?

    "Make bed non-lethal" is a bit of a misnomer. The pillow stays lethal but Willy gets sent running to the right before he reaches it. On the Spectrum, both of these are handled in the same code block; but the corresponding bit in the C64 version only covers drawing Maria or not, as appropriate.
  • edited April 2008
    My ML monitor seems to say "status" is 0400. In my regulat game it is set to 0. I guess I can set that to 1 and jump on the bed...

    ....and nothing happens. Maria disappears alright, but touching the bed does nothing. When I set it to 2, which should make Willy walk to the right, nothing happens. Same with 3. I guess that's the end of it then, in more ways then one!
  • edited May 2008
    9576  3AD385  	L9576:		LD	A,(POSITION)	; Get Willy's position
    9579  E61F    			AND	&1F		; Get X coordinate
    957B  FE06    			CP	&06		; Further left than X=6?
    957D  D0      			RET	NC		; Not reached the bed yet
    957E  3E02    			LD	A,&02		; Reached the bed
    9580  32DF85  			LD	(STATUS),A	; Set STATUS to 2 to indicate fleeing
    9583  C9      			RET
    

    Now, to C64-JSW. The code that handles Maria is at 3284h and adds Maria as a guardian:
    3284  AD0004	L3284:	LDA	STATUS
    3287  D04B		BNE	L32D4	;Status is nonzero, don't draw Maria
    3289  A50E		LDA	SHEET
    328B  C923		CMP	#35	;Master bedroom?
    328D  D045		BNE	L32D4	;Not Master bedroom
    ;
    ; [ code that adds Maria to the guardian list ]
    ;
    

    Sorry for the delay! I've failed rather miserably to repeat what you did here and find code that corresponds between the two versions. I'm seeing if I can add an ending to this game, but I need to find two parts of the C64 disassembly. The first is where it checks if Willy is on a conveyor
    ; Move Willy
    ; ==========
    L8ED4:		LD	E,&FF		; Prepare E with 'not moving'
    		LD	A,(ONROPE)
    		DEC	A
    		BIT	7,A
    		JR	Z,L8EFA
    		LD	A,(FALLING)
    		CP	&0C
    		JP	NC,DIED1
    		XOR	A
    		LD	(FALLING),A
    		LD	A,(CONVEYOR)	; Get conveyor attribute
    		CP	(HL)		; Check attribute under Willy
    		JR	Z,L8EF4		; Standing on a conveyor
    
    Here I plan to jmp to some empty space, and if room = bedroom then set that status register to 2. Then jump back.

    I might be able to find the control routines myself then by looking for references to the joystick address. Then I'll jump elsewhere, and if status = 2 then jump to control = move right.

    I can probably shove the (if status = 2) and (if room = bathroom) and (if Willy's X and Y coordinates = whatever) routine that changes the toilet sprites in then.

    Any help welcome!
Sign In or Register to comment.