Changes to the JSW48 game engine to allow 7-bit room numbers ------------------------------------------------------------ J.G.Harston, 24 March 1985 The code to fetch the current room data generates the source address with XOR &C0 instead of OR &C0, so mapping rooms 64 to 127 into spare memory between &8000 and &BFFF. Object collected flags moved from bit6 of &A4xx to bit6 of &A6xx. This allows the room number in bit0-bit5 of &A4xx to extend into bit6, so allowing the object table to refer to rooms 0 to 127. If there are more than 128 objects, the toilet sprites at &A600 to &A67F need to be moved. Clear object collected flags: Change to: 8800 26 A4 LD H,&A4 8800 26 A6 LD H,&A6 8802 3A FF A3 LD A,(&A3FF) 8805 6F LD L,A 8806 32 DE 85 LD (&85DE),A 8809 CB F6 SET 6,(HL) 880B 2C INC L 880C 20 FB JR NZ,&8809 Get room data: Change to: 8912 3A 20 84 LD A,(&8420) 8915 F6 C0 OR &C0 8915 EE C0 XOR &C0 8917 67 LD H,A 8918 2E 00 LD L,&00 891A 11 00 80 LD DE,&8000 891D 01 00 01 LD BC,&0100 8920 ED B0 LDIR Process objects: Change to: 93D1 26 A4 LD H,&A4 93D1 26 A6 LD H,&A6 93D3 3A FF A3 LD A,(&A3FF) 93D6 6F LD L,A 93D7 4E LD C,(HL) 93D7 CB 76 BIT 6,(HL) 93D8 CB B9 RES 7,C 93D9 28 77 JR Z,&9452 93DA 3A 20 84 LD A,(&8420) 93DB 25 DEC H 93DD F6 40 OR &40 93DC 25 DEC H 93DF B9 CP C 93DD CD F4 96 CALL &96F4 93E0 20 70 JR NZ,&9452 93E2 7E LD A,(HL) 93E3 07 RLCA 93E4 E6 01 AND &01 93E6 C6 5C ADD A,&5C 93E8 57 LD D,A 93E9 24 INC H 93EA 5E LD E,(HL) 93EB 25 DEC H 93EB 24 INC H 93EC 1A LD A,(DE) 93ED E6 07 AND &07 93EF FE 07 CP &07 93F1 20 3D JR NZ,&9430 93F3 DD 21 7C 85 LD IX,&857C 93F7 DD 34 02 INC (IX+&02) 93FA DD 7E 02 LD A,(IX+&02) 93FD FE 3A CP &3A 93FF 20 08 JR NZ,&9409 9401 DD 36 02 30 LD (IX+&02),&30 9405 DD 2B DEC IX 9407 18 EE JR &93F7 9409 3A DE 80 LD A,(&80DE) 940C 0E 80 LD C,&80 940E D3 FE OUT (&FE),A 9410 EE 18 XOR &18 9412 5F LD E,A 9413 3E 90 LD A,&90 9415 91 SUB A,C 9416 47 LD B,A 9417 7B LD A,E 9418 10 FE DJNZ &9418 941A 0D DEC C 941B 0D DEC C 941C 20 F0 JR NZ,&940E 941E 3A DE 85 LD A,(&85DE) 9421 3C INC A 9422 32 DE 85 LD (&85DE),A 9425 20 05 JR NZ,&942C 9427 3E 01 LD A,&01 9429 32 DF 85 LD (&85DF),A 942C CB B6 RES 6,(HL) 942E 18 22 JR &9452 9430 3A CB 85 LD A,(&85CB) 9433 85 ADD A,L 9434 E6 03 AND &03 9436 C6 03 ADD A,&03 9438 4F LD C,A 9439 1A LD A,(DE) 943A E6 F8 AND &F8 943C B1 OR C 943D 12 LD (DE),A 943E 7E LD A,(HL) 943E 7A LD A,D 943F 07 RLCA 943F 00 NOP 9440 07 RLCA 9441 07 RLCA 9442 07 RLCA 9443 E6 08 AND &08 9445 C6 60 ADD A,&60 9447 57 LD D,A 9448 E5 PUSH HL 9449 21 E1 80 LD HL,&80E1 944C 06 08 LD B,&08 944E CD 9B 96 CALL &969B 9451 E1 POP HL 9452 2C INC L 9453 20 82 JR NZ,&93D7 9455 C9 RET 96F4 Spare code space 96F4 4E LD C,(HL) 96F5 CB B9 RES 7,C 96F7 3A 20 84 LD A,(&8420) 96FA B9 CP C 96FB C8 RET Z 96FC 24 INC H 96FD 24 INC H 96FE C9 RET This can be applied with the following hex patch file: :01880100A6D0 :01891500EE73 :0193D200A6F4 :0993D700CB7628772525CDF4960C :0193EB00245D :02943E007A00B2 :0C96F4004ECBB93A2084B9C82424C90028 :0000000000