\ --- Mod: Code removed for Demonstration Disc: -------> \.SVE \ \JSR GTNME \ Clear the screen and ask for the commander filename \ \ to save, storing the name at INWK \ \JSR TRNME \ Transfer the commander filename from INWK to NA% \ \JSR ZERO \ Zero-fill pages &9, &A, &B, &C and &D, which clears \ \ the ship data blocks, the ship line heap, the ship \ \ slots for the local bubble of universe, and various \ \ flight and ship status variables \ \LSR SVC \ Halve the save count value in SVC \ \LDX #NT% \ We now want to copy the current commander data block \ \ from location TP to the last saved commander block at \ \ NA%+8, so set a counter in X to copy the NT% bytes in \ \ the commander data block \ \ \ \ We also want to copy the data block to another \ \ location &0B00, which is normally used for the ship \ \ lines heap \ \.SVL1 \ \LDA TP,X \ Copy the X-th byte of TP to the X-th byte of &0B00 \STA &0B00,X \ and NA%+8 \STA NA%+8,X \ \DEX \ Decrement the loop counter \ \BPL SVL1 \ Loop back until we have copied all the bytes in the \ \ commander data block \ \JSR CHECK \ Call CHECK to calculate the checksum for the last \ \ saved commander and return it in A \ \STA CHK \ Store the checksum in CHK, which is at the end of the \ \ last saved commander block \ \PHA \ Store the checksum on the stack \ \ORA #%10000000 \ Set K = checksum with bit 7 set \STA K \ \EOR COK \ Set K+2 = K EOR COK (the competition flags) \STA K+2 \ \EOR CASH+2 \ Set K+1 = K+2 EOR CASH+2 (the third cash byte) \STA K+1 \ \EOR #&5A \ Set K+3 = K+1 EOR &5A EOR TALLY+1 (the high byte of \EOR TALLY+1 \ the kill tally) \STA K+3 \ \JSR BPRNT \ Print the competition number stored in K to K+3. The \ \ value of U might affect how this is printed, and as \ \ it's a temporary variable in zero page that isn't \ \ reset by ZERO, it might have any value, but as the \ \ competition code is a 10-digit number, this just means \ \ it may or may not have an extra space of padding \ \JSR TT67 \ Call TT67 twice to print two newlines \JSR TT67 \ \PLA \ Restore the checksum from the stack \ \STA &0B00+NT% \ Store the checksum in the last byte of the save file \ \ at &0B00 (the equivalent of CHK in the last saved \ \ block) \ \EOR #&A9 \ Store the checksum EOR &A9 in CHK2, the penultimate \STA CHK2 \ byte of the last saved commander block \ \STA &0AFF+NT% \ Store the checksum EOR &A9 in the penultimate byte of \ \ the save file at &0B00 (the equivalent of CHK2 in the \ \ last saved block) \ \LDY #&B \ Set up an OSFILE block at &0C00, containing: \STY &0C0B \ \INY \ Start address for save = &00000B00 in &0C0A to &0C0D \STY &0C0F \ \ \ End address for save = &00000C00 in &0C0E to &0C11 \ \ \ \ Y is left containing &C which we use below \ \LDA #%10000001 \ Clear 6522 System VIA interrupt enable register IER \STA VIA+&4E \ (SHEILA &4E) bit 1 (i.e. enable the CA2 interrupt, \ \ which comes from the keyboard) \ \INC SVN \ Increment SVN to indicate we are about to start saving \ \LDA #0 \ Call QUS1 with A = 0, Y = &C to save the commander \JSR QUS1 \ file with the filename we copied to INWK at the start \ \ of this routine \ \LDX #0 \ Set X = 0 for storing in SVN below \ \\STX VIA+&4E \ This instruction is commented out in the original \ \ source. It would affect the 6522 System VIA interrupt \ \ enable register IER (SHEILA &4E) if any of bits 0-6 \ \ of X were set, but they aren't, so this instruction \ \ would have no effect anyway \ \\DEX \ This instruction is commented out in the original \ \ source. It would end up setting SVN to &FF, which \ \ affects the logic in the IRQ1 handler \ \STX SVN \ Set SVN to 0 to indicate we are done saving \ \JMP BAY \ Go to the docking bay (i.e. show Status Mode) \ --- End of removed code ----------------------------->Name: SVE, Removed [Show more] Type: Subroutine Category: Save and load Summary: Save the commander file Deep dive: Commander save files The competition codeContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file