Norman Sword Posted February 6, 2018 Report Share Posted February 6, 2018 (edited) 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 searchlower_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 routineaddress old code replace with93D1 ld h,#A4 ld hl,#A4ff << LS of hl modified93d293d3 ld a,($A3ff)93d4 nop93d5 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 RLCA9440 RLCA RLCA9441 RLCA RLCA9442 RLCA AND #089443 AND #89444 ADD A, #609445 ADD A,#609446 LD D,A9447 LD D,A PUSH HL9448 PUSH HL LD HL, #80E19449 LD HL,#80E1944A944B CALL #9699 ;call address is 2 bytes earlier944C LD B,#8944D944E CALL #969B POP HL ;new branch to here944F INC L9450 LD A,L9451 POP HL CP #00; old branch to here9452 INC L9453 JR NZ,93D7 JR NZ, #93D7 ;UNCHANGED94549456 RET RET ;UNCHANGED ;-------------------------------- keys are stored in this fashionSTART OFFSET IN $A3FF OFFSET IN $A3FE THE 255TH ENTRYOFFSET 0 v v v0,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 February 6, 2018 by Norman Sword IRF, Spider and jetsetdanny 3 Quote Link to comment Share on other sites More sharing options...
Norman Sword Posted February 6, 2018 Report Share Posted February 6, 2018 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. IRF, Spider and jetsetdanny 3 Quote Link to comment Share on other sites More sharing options...
IRF Posted February 6, 2018 Author Report Share Posted February 6, 2018 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? jetsetdanny 1 Quote Link to comment Share on other sites More sharing options...
IRF Posted February 6, 2018 Author Report Share Posted February 6, 2018 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! Quote Link to comment Share on other sites More sharing options...
Norman Sword Posted February 6, 2018 Report Share Posted February 6, 2018 (edited) 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 tile35770 LD C,L35771 LD A,H35772 ADD A,2735774 OR 735776 LD B,A35777 DEC B35778 LD A,(BC)35779 INC B35780 LD (BC),A35781 DEC B35782 LD A,B35783 AND 735785 JR NZ,3577735787 XOR A35788 LD (BC),A35789 LD A,B35790 ADD A,735792 LD B,A35793 LD A,(BC)35794 OR A35795 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,8loop 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 February 6, 2018 by Norman Sword IRF 1 Quote Link to comment Share on other sites More sharing options...
IRF Posted February 6, 2018 Author Report Share Posted February 6, 2018 Thanks Norman! That seems quite a lot simpler than the original routine! Quote Link to comment Share on other sites More sharing options...
IRF Posted February 6, 2018 Author Report Share Posted February 6, 2018 (edited) Taking up the idea in this post:http://jswmm.co.uk/topic/184-guardian-aura-bug-fix/page-5?do=findComment&comment=8867This 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,ALD H,#A4filter_loop:LD A,(#8420)XOR (HL)AND #3FJR Z,match_foundINC LJR 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,#C9LD (#93D1),A ; disable the Item-drawing routine whilst Willy is in this roomRETmatch_found:LD A,(HL) LD A,LLD (#93D2),A ; value used to initiate the item-drawing loop in this roomfind_last_item loop:INC LLD A,(#8420)XOR (HL)AND #3FJR 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,LLD (#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,#21LD (#93D1),A ; enable the Item-drawing routine whilst Willy is in this roomRET------------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=8871with minor additional amendments as follows:93D7 BIT 6,(HL) ; has the item under consideration been collected yet?93D9-DF NOP x 793E0 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 February 12, 2018 by IRF Quote Link to comment Share on other sites More sharing options...
IRF Posted February 6, 2018 Author Report Share Posted February 6, 2018 (edited) 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-127LD A,(#8420) ; current room numberAND #40JR Z,lower_setLD B,C ; adjust B and C forLD C,#00 ; upper set of rooms/itemslower_set:LD L,BLD H,#A4filter_loop:LD A,(#8420)XOR (HL)AND #3FJR Z,match_foundINC LLD A,LCP CJR 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,#C9LD (#93D1),A ; disable the Item-drawing routine whilst Willy is in this roomRETmatch_found:LD A,(HL) LD A,LLD (#93D2),A ; value used to initiate the item-drawing loop in this roomfind_last_item loop:INC LLD A,(#8420)XOR (HL)AND #3FJR 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,LLD (#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,#21LD (#93D1),A ; enable the Item-drawing routine whilst Willy is in this roomRET------------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=8871with minor additional amendments as follows:93D7 BIT 6,(HL) ; has the item under consideration been collected yet?93D9-DF NOP x 793E0 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 February 12, 2018 by IRF Quote Link to comment Share on other sites More sharing options...
IRF Posted February 6, 2018 Author Report Share Posted February 6, 2018 (edited) 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 February 12, 2018 by IRF Quote Link to comment Share on other sites More sharing options...
Norman Sword Posted February 6, 2018 Report Share Posted February 6, 2018 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 IRF 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.