.ClearMemory LDA #&04 \ Set (Q P) = &0400 STA Q \ LDA #&00 \ We use this as the start address for clearing memory, STA P \ which is where the game code starts \ \ This also sets A = 0, which we can use to zero memory .cmem1 LDY #&FF \ Set Y = &FF to use as a byte counter .cmem2 STA (P),Y \ Zero the Y-th byte at (Q P) DEY \ Decrement the byte counter BNE cmem2 \ Loop back until we have zeroed a whole page of memory INC Q \ Increment the high byte of (Q P) to point to the next \ page in memory LDX Q \ Loop back until (Q P) reaches &7C00, at which point we CPX #&7C \ have zeroed all the game code (including any code BCC cmem1 \ still left at the higher memory address where it's \ first loaded) LDA #&00 \ Set the Break Intercept code to a BRK instruction to STA BRKIV \ reinstate the default break handler RTS \ Return from the subroutine EQUB &20, &65, &74, &73, &36, &0D, &12, &CA \ These bytes are unused until EQUB &19, &20, &20, &20, &20, &20, &20, &4C \ the game is in progress, at EQUB &44, &58, &23, &36, &3A, &4A, &53, &52 \ which point this whole section EQUB &20, &43, &46, &4C, &53, &48, &0D, &12 \ of memory is reused EQUB &D4, &05, &20, &0D, &12, &DE, &0D, &2E \ EQUB &65, &74, &73, &36, &20, &72, &74, &73 \ These values are workspace EQUB &0D, &12, &E8, &05, &20, &0D, &12, &F2 \ noise and have no meaning EQUB &05, &20, &0D, &12, &FC, &05, &20, &0D \ EQUB &13, &06, &05, &20, &0D, &13, &10, &05 \ They actually contain snippets EQUB &20, &0D, &13, &1A, &05, &20, &0D, &13 \ of the original source code EQUB &24, &05, &20, &0D, &13, &2E, &2A, &2E EQUB &4D, &49, &4E, &49, &20, &4C, &44, &41 EQUB &23, &31, &32, &38, &3A, &53, &54, &41 EQUB &20, &4D, &45, &41, &4E, &59, &2C, &58 EQUB &3A, &53, &54, &41, &20, &4D, &45, &4D EQUB &4F, &52, &59, &2C, &58, &0D, &13, &38 EQUB &1F, &20, &20, &20, &20, &20, &20, &4C EQUB &44, &41, &23, &30, &3A, &53, &54, &41 EQUB &20, &4D, &45, &41, &4E, &59, &53, &43 EQUB &41, &4E, &2C, &58, &0D, &13, &42, &22 EQUB &20, &20, &20, &20, &20, &20, &4C, &44 EQUB &41, &23, &36, &34, &3A, &53, &54, &41 EQUB &20, &4D, &54, &52, &59, &43, &4E, &54 EQUB &2C, &58, &3A, &72, &74, &73, &0D, &13 EQUB &4C, &05, &20, &0D, &13, &56, &1A, &2E EQUB &4D, &45, &41, &4E, &20, &4C, &44, &41 EQUB &23, &34, &30, &3A, &53, &54, &41, &20 EQUB &43, &4F, &56, &45, &52, &0D, &13, &60 EQUB &1B, &20, &20, &20, &20, &20, &20, &4C EQUB &44, &58, &20, &45, &54, &45, &4D, &3A EQUB &53, &54, &58, &20, &58, &54Name: ClearMemory [Show more] Type: Subroutine Category: Setup Summary: Clear game memory, so that the BREAK key can remove all trace of the game code in early versions of the operating systemContext: See this subroutine in context in the source code References: This subroutine is called as follows: * ConfigureMachine calls ClearMemory
[X]
Configuration variable BRKIV = &0287
The Break Intercept code (which is a JMP instruction to the Break Intercept handler)
[X]
Label cmem1 is local to this routine
[X]
Label cmem2 is local to this routine