|Increasing the number of JSW48 rooms|
&C000. However, the only place where this is fixed is the code that fetches a room into the room buffer and the object location table. The current room variable and the room exits in the room data are all 8-bit values.
This patches the code to allow 7-bit room numbers to increase the number of rooms that can be used. Rooms.hex is an Intel Hex patchfile that can be applied to the original JSW48 game engine.
The room fetching code uses
OR &C0 to map a room number
from 0 to 63 to an address from
&FFxx. This could be changed to
ADD &C0 to
use the whole 8-bit value, mapping rooms 192 to 255 to the spare memory
within the code. I chose to change it to
XOR &C0, as this
maps the spare memory to rooms 64 to 127, running on from the existing 0 to
63. Also, a 7-bit room number is easier to fit into an extended object
POKE 35093,238 gives the following change:
Original code: Changed to: 8912 3A 20 84 LD A,(&8420) 8912 3A 20 84 LD A,(&8420) 8915 F6 C0 OR &C0 8915 EE C0 XOR &C0
This gives 8-bit room numbers, mapped to the following areas of memory:
|0 - 63|
|64 - 127|
|128 - 192|
|192 - 255|
&BFFFbecomes available as follows:
|&9700||87||Unused reset code|
|&9B00||91||Sprites and attributes for password entry|
&87C9needs to be bypassed. This makes this space available for patches, etc. Along with rooms 47, 61, 62 and 63, which are unused in the original JSW, this gives an additional 12 rooms that the game engine can use, making a total of 72.
This change allows room editors to use exactly the same object table as before. The 6-bit object table holds the room number in the bottom six bits, and bit 8 of the object position in bit 7. Bit 6 is overwritten by the game engine to hold the "object collected" flag. This modification moves that flag to bit 6 of the bytes in page &A6, so allowing the room number to be held in bit 0 to bit 6 of &A4xx.
The first half of page &A6xx holds the toilet sprites. If there are more than 128 objects, the toilet sprites at &A600 to &A67F need to be moved.
POKE 32769,166 POKE 37842,166 POKE 37847,203 POKE 37848,118 POKE 37849,40 POKE 37850,119 POKE 37851,37 POKE 37852,37 POKE 37853,205 POKE 37854,244 POKE 37855,150 POKE 37867,36 POKE 37950,122 POKE 37951,0 POKE 38644,78 POKE 38645,203 POKE 38646,185 POKE 38647,58 POKE 38648,32 POKE 38649,132 POKE 38650,185 POKE 38651,200 POKE 38652,36 POKE 38653,36 POKE 38654,201gives the following change:
Original code: Changed to: 8800 26 A4 LD H,&A4 8800 26 A6 LD H,&A6 93D1 26 A4 LD H,&A4 93D1 26 A6 LD H,&A6 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 93EB 25 DEC H 93EB 24 INC H 943E 7E LD A,(HL) 943E 7A LD A,D 943F 07 RLCA 943F 00 NOP 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 RETThe JSW48 object table remains in memory from &A3FF to &A5FF: