Jump to content
Jet Set Willy & Manic Miner Community

'Guardian Aura' Bug Fix and miscellaneous other patches


IRF

Recommended Posts

Revert (partialy) back to the original with the erroneous    LD A,L 

.

Using original source and I am listing what is needed (up to edit 2(now edit 3.5)) to extend the keys to enable 128 rooms. This is done without wasting a full 256 bytes of data, and uses very little to accomplish this.

.
This method gets around the key reset at game start up (no code change). It also has no need to calculate the total keys (the value is as before)

.
AT NEW ROOM set up

;

;use  $A3ff for the lower key OFFSET e.g this value is the numbers of keys in total. as before
.
; use  $A3fe for the upper key, this value holds the start of keys for rooms 64 upward
.
; storage of keys is laid out as follows
:

;from the value of ($a3ff) up to ($a3fe) the lower room keys
; from the value in ($a3fe) up to $ff the keys for rooms 64 to 128

.

new code to implement change

      ld bc,($a3fe)

;

; c=upper key pointer   ; Changed from what I originally wrote
; b=lower key pointer

   LD A,(ROOM_NUMBER)
    AND 64 ;UPPER OR LOWER SET
    JR z,lower_set
    ld b,c ;set b=upper key offset
    ld c,0 ;set limit=0 to stop search
lower_set:
    ld a,b  ;this is the start of search
    ld ($93d2),a ;set the new base for search
    ld a,c
    ld ($9452),a ; set the upper limit of search

;

;The above sets up the key collect routine

;

;-------------------------------------
modification to the key collect routine
address old code        replace with
93D1 ld h,#A4             ld hl,#A4ff  << LS of hl modified
93d2
93d3 ld a,($A3ff)
93d4                             nop
93d5                             nop

93d6 ld l,a                    nop         << remove this as well

 

(ironic that the LD a,L was ommited at the end and ommited for deletion at the beginning)
.
.
93E0 JR NZ,$9452       JR NZ,$944F  <<< THREE BYTES EARLIER
.
942E JR $9452            JR $944F  << THREE BYTES EARLIER
.

943E lD A,(HL)             LD A,D      ; 
943F RLCA                  RLCA
9440 RLCA                  RLCA
9441 RLCA                  RLCA
9442 RLCA                  AND #08
9443 AND #8
9444                            ADD A, #60
9445 ADD A,#60
9446                           LD D,A
9447 LD D,A               PUSH HL
9448 PUSH HL            LD HL, #80E1
9449 LD HL,#80E1
944A
944B                           CALL #9699  ;call address is 2 bytes earlier
944C LD B,#8
944D
944E CALL #969B      POP HL
                                   ;new branch to here
944F                           INC L
9450                           LD A,L
9451 POP HL             CP #00
; old branch to here
9452 INC L
9453 JR NZ,93D7       JR NZ, #93D7    ;UNCHANGED
9454
9456 RET                   RET                  ;UNCHANGED

;--------------------------------

keys are stored in this fashion
START                      OFFSET IN $A3FF                        OFFSET IN $A3FE         THE 255TH ENTRY
OFFSET 0                 v                                                    v                                      v
0,0,0,0,0,0.....,0,0,0,0,L,L,L,L,L.....,L,L,L,L,L,L,L,L,L,L,L,H,H,H,H ......,H,H,H,H,H,H,H
.
WHERE L IS THE DATA FOR ROOMS 0 TO 63 (THE LOW ROOMS)
.
AND H IS THE DATA FOR ROOM 64 TO 127 (THE HIGH ROOMS)

Edited by Norman Sword
Link to comment
Share on other sites

Definitely a lot easier to write code and not edit a fixed piece of code.

 

Trying to write source code with proportionally spaced font is a challenge. The presentation leaves a lot to be desired. Then every time I do a cut and paste I am presented with a file that has most of the blank lines deleted. Hence the multitude of lines with a full stop , semi colon or some other marker. This is my attempt at trying to force inclusion of blank lines.....

 

I do wonder also why the internet has decided that tabs need replacing with a space (or even nothing). If I press tab, as I write this the cursor will disappear and I have no more typing output, until I click with the mouse on the screen. Is the input designed to remove the archaic tabs at source, and is it trying to educate me in the new world order. NO TABS ALLOWED. 
 

Link to comment
Share on other sites

93d4 nop

93d5 nop

 

I think you need to NOP out the LD L,A at #93D6 as well (otherwise whatever value A retains from its previous use will be copied to L!)

 

ld b,c ;set c=upper key offset

 

Less importantly (I'm being pedantic now!), that should probably read "ld b,c ;set b=upper key offset".

 

****

 

Off-topic (or rather, even more off-topic!):

 

The crumbling floors are similar to Manic Miner, but they can have blank lines of data and are not switched off when an empty line of data occurs on the bottom row. All the data has to be removed for the floor to finish crumbling.

 

I meant to ask - how do you keep track of when all the pixel-rows have been cleared from a crumbly? Does a temporary variable count down the number of rows deleted (until the variable reaches zero), or does the subroutine check the status of all eight rows in each time-frame?

Link to comment
Share on other sites

93d6 ld a,l nop << remove this as well

 

(ironic that the LD a,L was ommited at the end and ommited for deletion at the beginning)

 

There's a perfect asymmetry about it, because it's actually a LD L,A that has to be deleted at the start, but a LD A,L that must be inserted at the end!

Link to comment
Share on other sites

In the context that I have just written this and it is not tested.

;

As defined in Manic Miner 

;
HL Address of the crumbling floor tile
35770 LD C,L
35771 LD A,H
35772 ADD A,27
35774 OR 7
35776 LD B,A
35777 DEC B
35778 LD A,(BC)
35779 INC B
35780 LD (BC),A
35781 DEC B
35782 LD A,B
35783 AND 7
35785 JR NZ,35777
35787 XOR A
35788 LD (BC),A
35789 LD A,B
35790 ADD A,7
35792 LD B,A
35793 LD A,(BC)
35794 OR A
35795 RET NZ

;

ignoring the above, no help to me

;

; this code moves the tile in hl down by one line

;
    xor a
    ld d,a
    ld b,8
loop
    ld e,(hl) ;the current line
    or d ;the line above
    ld (hl),d
    ld d,e
    inc h
    djnz loop

;
;  a=the accumalative value of the bits drawn

;

    or a    ;if a value exists then the floor is still collapsing

This permits a one pixel line to be moved down the screen

Edited by Norman Sword
Link to comment
Share on other sites

Taking up the idea in this post:
http://jswmm.co.uk/topic/184-guardian-aura-bug-fix/page-5?do=findComment&comment=8867

This is for a 64 room game, and beware that I haven't tried it out yet!

Items have to be sorted into room number order beforehand (i.e. by the game designer, manually in the hex editor). Or at very least, all of each room's items must occupy adjacent entries in the item table.

This is the new 'Item Filtering' routine, CALLed from the Room Setup code:

LD A,(#A3FF)
LD L,A
LD H,#A4

filter_loop:
LD A,(#8420)
XOR (HL)
AND #3F
JR Z,match_found
INC L
JR NZ,filter_loop

; If we get here, then we have been through all the item table entries, and there are no items (collected or uncollected) to consider in this room:
LD A,#C9
LD (#93D1),A ; disable the Item-drawing routine whilst Willy is in this room
RET

match_found:
LD A,(HL) LD A,L
LD (#93D2),A ; value used to initiate the item-drawing loop in this room

find_last_item loop:
INC L
LD A,(#8420)
XOR (HL)
AND #3F
JR Z,find_last_item

; If we get here, then HL is pointing at the first item for the next room:
LD A,(HL) LD A,L
LD (#9452),A ; value used to terminate the item-drawing loop in this room

; Now restore the first byte of the Item-drawing routine:
LD A,#21
LD (#93D1),A ; enable the Item-drawing routine whilst Willy is in this room
RET

------------

Then the item-drawing/collecting routine (#93D1, CALLed from the Main Loop) needs to be amended in accordance with Norman's post:
http://jswmm.co.uk/topic/184-guardian-aura-bug-fix/page-6?do=findComment&comment=8871

with minor additional amendments as follows:

93D7 BIT 6,(HL) ; has the item under consideration been collected yet?
93D9-DF NOP x 7
93E0 JR Z,#944F ; if so, then consider the next item for this room (or terminate the loop if we've already considered all this room's items)

Edited by IRF
Link to comment
Share on other sites

Extrapolating for a 128 room game (again, I've not tried this out yet!):

Items have to be sorted into room number order beforehand (i.e. by the game designer, manually in the hex editor). Or at very least, all of each room's items must occupy adjacent entries in the item table, and entries for Rooms 0-63 must all come before entries for Rooms 64-127.

This is the new 'Item Filtering' routine, CALLed from the Room Setup code - the first part © Norman Sword:

LD BC,(#A3FE) ; #A3FF = total number of items as before, also start of items for Rooms 0-63 ; #A3FE = start of items for Rooms 64-127

LD A,(#8420) ; current room number
AND #40
JR Z,lower_set
LD B,C ; adjust B and C for
LD C,#00 ; upper set of rooms/items

lower_set:
LD L,B
LD H,#A4

filter_loop:
LD A,(#8420)
XOR (HL)
AND #3F
JR Z,match_found
INC L
LD A,L
CP C
JR NZ,filter_loop

; EVERYTHING FROM HERE ONWARDS IS THE SAME AS FOR THE 64 ROOM VERSION IN THE PREVIOUS POST

; If we get here, then we have been through all the item table entries, and there are no items (collected or uncollected) to consider in this room:
LD A,#C9
LD (#93D1),A ; disable the Item-drawing routine whilst Willy is in this room
RET

match_found:
LD A,(HL) LD A,L
LD (#93D2),A ; value used to initiate the item-drawing loop in this room

find_last_item loop:
INC L
LD A,(#8420)
XOR (HL)
AND #3F
JR Z,find_last_item

; If we get here, then HL is pointing at the first item for the next room:
LD A,(HL) LD A,L
LD (#9452),A ; value used to terminate the item-drawing loop in this room

; Now restore the first byte of the Item-drawing routine:
LD A,#21
LD (#93D1),A ; enable the Item-drawing routine whilst Willy is in this room
RET

------------

Then the item-drawing/collecting routine (#93D1, CALLed from the Main Loop) needs to be amended in accordance with Norman's post:
http://jswmm.co.uk/t...age-6?do=findComment&comment=8871

with minor additional amendments as follows:

93D7 BIT 6,(HL) ; has the item under consideration been collected yet?
93D9-DF NOP x 7
93E0 JR Z,#944F ; if so, then consider the next item for this room (or terminate the loop if we've already considered all this room's items)

Edited by IRF
Link to comment
Share on other sites

Items have to be sorted into room number order beforehand (i.e. by the game designer, manually in the hex editor). Or at very least, all of each room's items must occupy adjacent entries in the item table, and entries for Rooms 0-63 must all come before entries for Rooms 64-127.

 

Another caveat - the last item listed in the lower set's room number must not be equal to the first item listed in the upper set's room number modulo 64 (or vice versa), otherwise the item-filtering loop will not terminate and items will jump across the 'set boundary'!

 

So it's probably safest to have the items strictly listed in room number order (although it might be a bit of a pain to set up/edit the item table in that way, so it would be wise to ensure that you're happy with the item distribution throughout the layout beforehand).

Edited by IRF
Link to comment
Share on other sites

I have no problems with the code as listed here

I changed the ld a,(hl)     (twice)

;
;-----------------              CODE by IRF       -------------------------

;

;

;

Pre_search:

    LD A,(#A3FF)                      ;offset for first key
    LD L,A
    LD H,#A4                             ;base of key list . full address now in HL

filter_loop:
    LD A,(#8420)                       ;current room
    XOR (HL)                             ; xor comparison  
    AND #3f                               ; does it match after removing key position page and collection flag. Bits 6 and bit 7
    JR Z,match_found
    INC L                                   ;move to next key
    JR NZ,filter_loop                  ;keep going through list 

;

; If we get here, then we have been through all the item table entries, and there are no items (collected or uncollected) to consider in this room:

  LD A,#C9                               ;disable item drawing by overwriting code with a "ret"

Pre_exit:
    LD (#93D1),A                     ; disable/set the Item-drawing routine whilst Willy is in this room
    RET                                    ;finished

;

match_found:
    LD A,L                                ; get the position in the list
    LD (#93D2),A                     ; and store offset .value used to initiate the item-drawing loop in this room

find_last_item:                
    INC L                                  ; wrap around is not a problem
    LD A,(#8420)                     ; the current room
    XOR (HL)                           ; comparison match
    AND #3F                            ;does it match after removing key position page and collection flag. Bits 6 and bit 7
    JR Z,find_last_item

; If we get here, then HL is pointing at the first item for the next room:
    LD A,L                               ;  get  the position in the list
    LD (#9452),A                    ; and store this offset. value used to terminate the item-drawing loop in this room

; Now restore the first byte of the Item-drawing routine:
    LD A,#21                           ;enable item drawing by replacing the LD HL,xxxx opcode
    jr  Pre_exit

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.