![]() |
Routines |
Prev: 02056 | Up: Map |
Used by the routine at SAVE_ETC.
There are three main parts to this routine.
Start therefore with the loading of the data block.
|
|||||||||
ME_CONTRL | 02230 | LD C,(IX+11) | Fetch the 'length' of the data block. | ||||||
02233 | LD B,(IX+12) | ||||||||
02236 | PUSH BC | Save a copy of the 'length'. | |||||||
02237 | INC BC | Now make 'length+1' locations available in the work space. | |||||||
02238 | RST 48 | ||||||||
02239 | LD (HL),128 | Place an end marker in the extra location. | |||||||
02241 | EX DE,HL | Move the 'start' pointer to the HL register pair. | |||||||
02242 | POP DE | Fetch the original 'length'. | |||||||
02243 | PUSH HL | Save a copy of the 'start'. | |||||||
02244 | PUSH HL | Now set the IX register pair for the actual load. | |||||||
02245 | POP IX | ||||||||
02247 | SCF | Signal 'LOAD'. | |||||||
02248 | LD A,255 | Signal 'data block only'. | |||||||
02250 | CALL LD_BLOCK | Load the data block. | |||||||
The lines of the new program are merged with the lines of the old program.
|
|||||||||
02253 | POP HL | Fetch the 'start' of the new program. | |||||||
02254 | LD DE,(23635) | Initialise DE to the 'start' of the old program (PROG). | |||||||
Enter a loop to deal with the lines of the new program.
|
|||||||||
ME_NEW_LP | 02258 | LD A,(HL) | Fetch a line number and test it. | ||||||
02259 | AND 192 | ||||||||
02261 | JR NZ,ME_VAR_LP | Jump when finished with all the lines. | |||||||
Now enter an inner loop to deal with the lines of the old program.
|
|||||||||
ME_OLD_LP | 02263 | LD A,(DE) | Fetch the high line number byte and compare it. Jump forward if it does not match but in any case advance both pointers. | ||||||
02264 | INC DE | ||||||||
02265 | CP (HL) | ||||||||
02266 | INC HL | ||||||||
02267 | JR NZ,ME_OLD_L1 | ||||||||
02269 | LD A,(DE) | Repeat the comparison for the low line number bytes. | |||||||
02270 | CP (HL) | ||||||||
ME_OLD_L1 | 02271 | DEC DE | Now retreat the pointers. | ||||||
02272 | DEC HL | ||||||||
02273 | JR NC,ME_NEW_L2 | Jump forward if the correct place has been found for a line of the new program. | |||||||
02275 | PUSH HL | Otherwise find the address of the start of the next old line. | |||||||
02276 | EX DE,HL | ||||||||
02277 | CALL NEXT_ONE | ||||||||
02280 | POP HL | ||||||||
02281 | JR ME_OLD_LP | Go round the loop for each of the 'old lines'. | |||||||
ME_NEW_L2 | 02283 | CALL ME_ENTER | Enter the 'new line' and go round the outer loop again. | ||||||
02286 | JR ME_NEW_LP | ||||||||
In a similar manner the variables of the new program are merged with the variables of the old program.
|
|||||||||
ME_VAR_LP | 02288 | LD A,(HL) | Fetch each variable name in turn and test it. | ||||||
02289 | LD C,A | ||||||||
02290 | CP 128 | Return when all the variables have been considered. | |||||||
02292 | RET Z | ||||||||
02293 | PUSH HL | Save the current new pointer. | |||||||
02294 | LD HL,(23627) | Fetch VARS (for the old program). | |||||||
Now enter an inner loop to search the existing variables area.
|
|||||||||
ME_OLD_VP | 02297 | LD A,(HL) | Fetch each variable name and test it. | ||||||
02298 | CP 128 | ||||||||
02300 | JR Z,ME_VAR_L2 | Jump forward once the end marker is found. (Make an 'addition'.) | |||||||
02302 | CP C | Compare the names (first bytes). | |||||||
02303 | JR Z,ME_OLD_V2 | Jump forward to consider it further, returning here if it proves not to match fully. | |||||||
ME_OLD_V1 | 02305 | PUSH BC | Save the new variable's name whilst the next 'old variable' is located. | ||||||
02306 | CALL NEXT_ONE | ||||||||
02309 | POP BC | ||||||||
02310 | EX DE,HL | Restore the pointer to the DE register pair and go round the loop again. | |||||||
02311 | JR ME_OLD_VP | ||||||||
The old and new variables match with respect to their first bytes but variables with long names will need to be matched fully.
|
|||||||||
ME_OLD_V2 | 02313 | AND 224 | Consider bits 7, 6 and 5 only. | ||||||
02315 | CP 160 | Accept all the variable types except 'long named variables'. | |||||||
02317 | JR NZ,ME_VAR_L1 | ||||||||
02319 | POP DE | Make DE point to the first character of the 'new name'. | |||||||
02320 | PUSH DE | ||||||||
02321 | PUSH HL | Save the pointer to the 'old name'. | |||||||
Enter a loop to compare the letters of the long names.
|
|||||||||
ME_OLD_V3 | 02322 | INC HL | Update both the 'old' and the 'new' pointers. | ||||||
02323 | INC DE | ||||||||
02324 | LD A,(DE) | Compare the two letters. | |||||||
02325 | CP (HL) | ||||||||
02326 | JR NZ,ME_OLD_V4 | Jump forward if the match fails. | |||||||
02328 | RLA | Go round the loop until the 'last character' is found. | |||||||
02329 | JR NC,ME_OLD_V3 | ||||||||
02331 | POP HL | Fetch the pointer to the start of the 'old' name and jump forward - successful. | |||||||
02332 | JR ME_VAR_L1 | ||||||||
ME_OLD_V4 | 02334 | POP HL | Fetch the pointer and jump back - unsuccessful. | ||||||
02335 | JR ME_OLD_V1 | ||||||||
Come here if the match was found.
|
|||||||||
ME_VAR_L1 | 02337 | LD A,255 | Signal 'replace' variable. | ||||||
And here if not. (A holds 128 - variable to be 'added'.)
|
|||||||||
ME_VAR_L2 | 02339 | POP DE | Fetch pointer to 'new' name. | ||||||
02340 | EX DE,HL | Switch over the registers. | |||||||
02341 | INC A | The zero flag is to be set if there is to be a 'replacement', reset for an 'addition'. | |||||||
02342 | SCF | Signal 'handling variables'. | |||||||
02343 | CALL ME_ENTER | Now make the entry. | |||||||
02346 | JR ME_VAR_LP | Go round the loop to consider the next new variable. |
Prev: 02056 | Up: Map |