.MakeRom LDA &F4 \ Switch to the sideways RAM bank in X, storing the PHA \ current ROM bank on the stack STX &F4 STX VIA+&30 \ We start by copying 256 bytes from eliteRomHeader into \ the sideways RAM bank at address ROM, and zeroing the \ next 256 bytes at ROM + &100 \ \ This sets up the sideways RAM bank with the ROM header \ needed for our sideways RAM image LDY #0 \ Set a loop counter in Y to step through the 256 bytes .mrom1 LDA eliteRomHeader,Y \ Copy the Y-th byte from eliteRomHeader to ROM STA ROM,Y LDA #0 \ Zero the Y-th byte at ROM + &100 STA ROM_XX21,Y INY \ Increment the loop counter BNE mrom1 \ Loop back until we have copied and zeroed all 256 \ bytes \ Next we load all the ship blueprint files into our \ sideways RAM image, from D.MOA to D.MOP, combining \ them into a single, complete set of ship blueprints LDA #LO(ROM+&200) \ Set ZP(1 0) = ROM + &200 STA ZP \ LDA #HI(ROM+&200) \ So the call to LoadShipFiles loads the ship blueprint STA ZP+1 \ files to location &200 in the sideways RAM image JSR LoadShipFiles \ Load all the ship blueprint files into the sideways \ RAM image to the location in ZP(1 0) \ Now that we have created our sideways RAM image, we \ intercept calls to OSFILE so they call our custom file \ handler routine, FileHandler, in sideways RAM \ \ For this we need to use the extended vectors, which \ work like the normal vectors, except they switch to a \ specified ROM bank before calling the handler, and \ switch back afterwards LDA XFILEV \ Copy the extended vector XFILEV into XIND1V so we can STA XIND1V \ pass any calls to XFILEV down the chain by calling LDA XFILEV+1 \ the IND1 vector STA XIND1V+1 LDA XFILEV+2 STA XIND1V+2 LDA #LO(FileHandler) \ Set the extended vector XFILEV to point to the STA XFILEV \ FileHandler routine in the sideways RAM bank that we LDA #HI(FileHandler) \ are building STA XFILEV+1 \ LDA &F4 \ The format for the extended vector is the address of STA XFILEV+2 \ the handler in the first two bytes, followed by the \ ROM bank number in the third byte, which we can fetch \ from &F4 LDA #LO(OSXIND1) \ Point IND1V to IND1V's extended vector handler, so we STA IND1V \ can pass any calls to XFILEV down the chain by calling LDA #HI(OSXIND1) \ JMP (IND1V) from our custom file handler in the STA IND1V+1 \ FileHandler routine PLA \ Switch back to the ROM bank number that we saved on STA &F4 \ the stack at the start of the routine STA VIA+&30 RTS \ Return from the subroutineName: MakeRom [Show more] Type: Subroutine Category: Loader Summary: Create a ROM image in sideways RAM that contains all the ship blueprint filesContext: See this subroutine in context in the source code References: This subroutine is called as follows: * makerom% calls MakeRom
Arguments: X The bank number of sideways RAM to use for Elite
[X]
Subroutine FileHandler (category: Loader)
The custom file handler that checks whether OSFILE is loading a ship blueprint file and if so, redirects the load to sideways RAM
[X]
Configuration variable IND1V = &0230
The IND1 vector
[X]
Subroutine LoadShipFiles (category: Loader)
Load all the ship blueprint files into sideways RAM
[X]
Configuration variable OSXIND1 = &FF48
IND1V's extended vector handler
[X]
Variable ROM (category: Loader)
The ROM header code that forms the first part of the sideways RAM image containing the ship blueprint files
[X]
Configuration variable ROM_XX21 = &8100
The address of the ship blueprints lookup table in the sideways RAM image that we build
[X]
Configuration variable VIA = &FE00
Memory-mapped space for accessing internal hardware, such as the video ULA, 6845 CRTC and 6522 VIAs (also known as SHEILA)
[X]
Configuration variable XFILEV = &0DBA
The extended FILE vector
[X]
Configuration variable XIND1V = &0DE7
The extended IND1 vector
[X]
Workspace ZP (category: Workspaces)
Important variables used by the sideways RAM loader
[X]
Variable eliteRomHeader (category: Loader)
The ROM header code that gets copied to &8000 to create a sideways RAM image containing the ship blueprint files
[X]
Label mrom1 is local to this routine