; ==================================================================================================
; === RICKY GERVAIS' SIMON: for the 1K ZX80 (with 4K ROM BASIC)
; === Written by John Connolly for the 2021 comp.sys.sinclair Crap Games Competition
; ==================================================================================================

; Set tab stops to 4 to view this file properly!

; This assembly listing produces a .O/.80 format tape file. These formats are essentially a
; representation of the ZX80's memory, from $4000 to E_LINE - 1, thus they contain the
; entire state of the system (minus the DFILE).

; Many thanks to Martin Korth, upon whose NO$ZX specification document I relied upon heavily
; during the development of this program.

org $4000										; Start of ZX80 memory

; === ZX80 SYSTEM VARIABLES

ERR_NR:		db $ff								; Error no. (report code - 1)
FLAGS:		db $88
PPC:		dw $fffe							; Next line number to execute
P_PTR:		dw $4034							; Position of edit cursor in RAM
E_PPC:		dw $0000							; Line number of selection cursor
VARS:		dw PRG_VARS							; Address of start of variable area
E_LINE:		dw PRG_END							; Address of start of edit line
D_FILE:		dw PRG_END+2						; Start of display file
DF_EA:		dw PRG_END+3						; Start of edit area of display file
DF_END:		dw PRG_END+3						; End of display file

DF_SZ:		db $02								; Number of lines in edit area
S_TOP:		dw $0000							; Number of 1st line on screen
X_PTR:		dw $0000							; Address of character preceding [S] marker
OLDPPC:		dw $0000							; Line number for CONTINUE
FLAGX:		db $00

T_ADDR:		dw $07b0							; Address of next item in syntax table
SEED:		dw $0000							; Seed for random number generator
FRAMES:		dw $0000							; Count of frames since boot-up
DEST:		dw $0000
RESULT:		dw $0000
S_POSN_X:	db $21
S_POSN_Y:	db $17
CH_ADD:		dw PRG_END+1

; === LINE 0

PRG_LINE0:
; This line will start the program off
	db $00, $00									; Line 0 (stored in big-endian format)
	
	db $f4, $3a, $38, $37, $da, $1c, $d9		; PRINT USR(0)
	
	db $76										; HALT

; === LINE 1
PRG_LINE1:


; === VARIABLE AREA

PRG_VARS:
	db $80										; End of variable area marker

PRG_END:	equ $
