This is a very simple Chess game written in Applesoft Basic. You can try it yourself on "https://www.calormen.com/jsbasic/", or on any other emulator by uploading the "Chess.txt".

- hgr: Initializes high-resolution graphics mode.
- bp(15, 2): Array for black piece positions.
- wp(15, 2): Array for white piece positions.
- f: Frame buffer toggle.
- n: Is used to tell wich line of pieces are being created.
- sc: Scale factor for graphics.
- poke and call commands: Hardware and display initialization.
- d: Delay counter.
- gosub: Calls subroutines to define piece outlines.
- cb(63, 1): Array for the state of the chessboard.
First the Chess board is drawn, then the curser. Afterwards it loops over the key listener until the programm is terminated.
Here the Chess board is plotted and then the Pieces on top.
Assigns the current key ID to variable k and then checks k for arrow keys and the space bar to perform the corresponding actions. The Arrow keys move the curser and space grabs and places pieces.
Is not jet finished
Clears the old Curser and draws new one.
Since Applesoft Basic doesn't support multiple threads or have an integrated timer, the most common way to create a delay is to loop over nothing, using a variable that represents the duration of the wait. This method is inaccurate, as the desired value has to be estimated through trial and error, and the duration won't be consistent because it is based on computing steps rather than actual time.
Every chesspiece's outline is defined and gets a function to draw it at a given position on the board.
Sets the predefined Pieces on their respective squares.
Checks what needs to happen, when the space bar is pressed and executes it.
Draws an Empty Square at a given Position.
Pastes a copied piece at a given position.