;********************** Build specific Variables **********************

#if compile_RO > 311
 .env_handler_buffer		DCD 0	;buffer space
 .env_handler_registers		DCD 0	;callback space
 .environment_handlers		DCD 0	;space to track handlers
#endif

#if JIT_WIMP_support == 1
 .domainID			DCD &FF8	;RO3.5+ address of DomainID
 .JIT_task_ID			DCD 0	;current task ID
#endif

#if Managed_ChannelHandler == 1
 .our_sound_DA_number		DCD 0
 .os_sound_configure		DBD 5	;Sound_Configure previous values
 .hypervised_sound_configure	DBB sound_config_struct.size
				;^^^^^^^^Sound_Configure values game uses
				ALIGN
 .our_channel_handler		DBD 4	;PRM4-10 our Channel Handler
 .our_scheduler			DCD 0	;PRM4-12 our Scheduler
#endif

#if compile_RO > 400
 .page_zero_module_cmdline	DCD 0	;commandline 26bit Module was
					;entered with, used for Aborts
#endif

#if compile_RO > 311
 .Module_being_inserted		DCD 0	;=Stub Module base during 26bit Module init
 .is_screen_remapped		DCD 0	;<>0 when screen memory is remapped
 .readVDUstart				;used to get the screen start address
  DCD 149				;PRM1-731 display start
  DCD 150				;size of screen
  DCD -1
  DCD 0
  DCD 0
					;table of cache ops to action on JIT exit

 ;-------------- CACHE OPS -------------
				DCD 0	;cache_ops_size
				DCD 0	;cache_ops_index
 .pending_cache_ops		DBB max_cache_ops_index
 ;--------- END OF CACHE OPS -----------

 .emulate_RISCOS		DCD -1	;default to current RISCOS behaviour
 .JIT_fixups			DCD 0	;address of fixup table
 .JIT_module_fixups		DCD 0	;address of module fixup table
 .IRQ_vector			DCD 0	;copy of &18
 .hypervised_IRQ1V		DCD 0	;game IRQ1V entry
 .hypervised_IRQv		DCD 0	;game IRQv entry
 .page_zero_EnvString		DCD 0	;address of EnvString in page zero
 .page_zero_EnvTime		DCD 0	;address of EnvTime in page zero
 .page_zero_CursorFudgeFactor	DCD 0	;CursorFudgeFactor value (10D4 on RO3.5 - 4.x)
 .page_zero_VertAdjust		DCD 0	;VertAdjust value        (1588 on RO3.5 - 4.x)
 .page_zero_HSWRSoftCopy	DCD 0	;HSWRSoftCopy value      (1474 on RO3.5 - 4.x)

 ;-------------- BRANCH PREDICTION ------------
				DCD 0	;current pointer in the circular BPT
 .JIT_branch_prediction_table	DBD JIT_branch_prediction_max
 ;--------- END OF BRANCH PREDICTION ----------
 .JIT_event11_active		DCD 0	;track event 11, as we've enabled it
 .JIT_started_at		DCD 0	;the start address of the current code
					;the JIT is interpreting
 .JIT_processed_counter		DCD 0	;counts how many instructions handled
 .codelet_cache_flush		DBD 2	;pending codelet cache flush
 .jit_managed_ldr_pc_r13_2	DCD 0	;address of general use LDR PC,[R13],#4
 .jit_managed_ldr_pc_r13	DCD 0	;address of general use LDR PC,[R13],#4
 .jit_managed_BASIC_entry	DCD 0	;address of BASIC entry/exit codelet
 .jit_managed_IRQ_entry		DCD 0	;B <address> that game sees at &18
 .jit_managed_os_exit		DCD 0	;SWI OS_Exit

 .jit_code			DCD 0	;translated code address
					;this is a static value once setup
 .first_codelet			DCD 0	;first codelet address
					;this is a static value once setup

 .existing_Branch_thru_zero	DCD 0	;RISCOS Branch Thru Zero handler
 .page_zero_L2PT		DCD 0	;copy of page zero L2PT entry

					;space for claimed vectors
 .jit_claimed_vectors	DBB max_vectors_to_track * vector_table.size
			ALIGN
 .DeviceVectors	DBB (last_device_to_track + 1) * device_table.size
			ALIGN

 .VIDC20_width		DCD 0		;VIDC20 screen width
 .VIDC20_height		DCD 0		;VIDC20 screen height
 .VIDC20_aspect_ratio	DCD 0		;VIDC20 screen ratio: 0=5:4 1=2:3 2=10:4
 #if compile_GPU == 1
   .old_VIDC20_HCR	DCD 0		;overall screen width
   .old_VIDC20_VCR	DCD 0		;overall screen height
 #endif

 .os_memory_block	DCD 0, 0, 0	;block for OS_Memory actions
 #if compile_IOMD == 1 AND JIT_debug == 1
   .current_screen_mode	DCD 0		;current screen mode VIDC parameter ptr
 #endif
 .closest_screen_mode	DCD -1		;the actual MODE no.

 .IOMD_FSIZE_value	DCD 0		;track IOMD FSIZE value

					;track VIDC20 registers
 .vidc20_regs		DBD (VIDC20_VCER - VIDC20_HCR) + 1

 .vram_available	DCD 0		;amount of VRAM
 .TV_offset		DCD 0		;*TV adjustment
 .IOMD_addr		DCD IOC_addr	;base address of IOMD
					;default to IOC address for 32bit

					;speed of VIDC20 clock
					;RPC   - 24000
					;A7000 - 32000
 .VIDC20_clock		DCD RPC_reference_clock
					;space for claimed devices
#endif

#if compile_GPU == 1
 .IOC_registers			DBB &80 >> 2	;1 byte per IOC register
				ALIGN
#endif

#if compile_RO > 311
 .jit_IRQ1V_db			DCD 0		;debug copy of IRQ1V
 .jit_IRQv_db			DCD 0		;debug copy of IRQv
 .SVC_stack_init		DCD 0		;top of SVC stack
 .IRQ_stack_init		DCD 0		;top of IRQ stack
 .managed_EnvironmentHandlers	DCD 0		;managed Environment handlers
 .our_IOC_IRQ_DA_number		DCD 0
 .our_26bit_DA_number		DCD 0
 .our_IRQ_DA_number		DCD 0
 .tmp_module_stack		DCD 0		;address of Module private stack
 .IOC_IRQ_stack			DCD 0		;stack used for IOC IRQ emulation
 .Otmp_module_stack		DCD 0		;original for reset
 .OIRQ_vector_stack		DCD 0		;original for reset
 .pre_JIT_wimp_slot_size	DCD 0		;size of WimpSlot to return
 #if compile_IOMD == 1
  .VIDC20_addr		DCD VIDC20_base_addr	;base address of VIDC20
 #endif

.MEMC_registers				;MEMC registers
  .MEMC_Vinit	DCD 0
  .MEMC_Vstart	DCD 0
  .MEMC_Vend	DCD 0
  .MEMC_Cinit	DCD &1F03800
  .MEMC_Sstart  DCD 0
  .MEMC_SendN   DCD 0
  .MEMC_Sptr	DCD 0
		DCD &36E0D0C		;MEMC CR
					;current speed for VIDC1 clock
  .VIDC1_clock		DCD VIDC1_reference_clock
  .VIDC1_CR		DCD &E0000000	;current VIDC1 Control Register
  .modeextension_in_progress DCD 0	;are we processing a Mode_Extension
  .current_mode_bitdepth DCD 0		;bitdepth of mode in VIDC1 format VIDC1-20
#endif

#if compile_RO == 311
  .DA_mask	DCD 0
  .RO31_Next_DynamicAreaNo	DCD  RO31_First_DynamicAreaNo	;our DA number on RO3.1
  .RO31_DynamicAreaAddress	DCD  &1000000			;..end address
  .RO31_DA_table
  ;1st is always ADFFS
  .DA_address	DCD 0			;ADFFS buffer address
		DCD 0, 0
  .reserve_DA	DCD 0			;<>0 prevent the DA from shrinking
  ;2nd onward are 3rd party
  DBD (4*4)*(RO31_Last_DynamicAreaNo-RO31_First_DynamicAreaNo)
#else
  .DA_address	DCD 0			;ADFFS buffer address
  .reserve_DA	DCD 0			;<>0 prevent the DA from shrinking
  .fscontrol_filename	DBB Max_File_Length
			ALIGN		;^^^ buffer for DiscOp recordings
#endif

;********************** Variables across all builds **********************

.Open_Filer_Window      DCB "Filer_OpenDir "
.ADFFS_Current_DiscName DCB "12345678901234567890123456789012.$", 0
                        ALIGN		;^^^ must follow Open_Filer_Window
.Star_Dismount		DCB "adfs:DISMOUNT "
.Star_Dismount_DiscName DCB "78901234567890123456789012", 0
                        ALIGN		;^^^ must follow Star_Dismount

.softwareVectors	DBD (LastVectorToTrack - FirstVectorToTrack + 1) * 2
					;^^^ software vector table
.softwareVectorBitmap	DBD (LastVectorToTrack + 31) DIV 32
					;^^^ bit is set if vector is claimed by us

.FileType_Loaded	DCD 0		;"ADF", "APD" or "JFD"
.Current_File_Mounted	DBB Max_File_Length
			ALIGN		;^^^ must follow FileType_Loaded

.record_filename	DBB Max_File_Length
			ALIGN		;^^^ buffer for DiscOp recordings

.JFD_tmp		DBB JFD_Header	;space to load JFD headers
			ALIGN
.VARS

.force_mono		DCD 0		;-127/127 to force audio to left/right
.stereo_position	DBD 2		;1 byte per channel for stereo position

.our_Floppy_DA_number	DCD 0		;our Dynamic Area number
.DA_size		DCD 0		;size of Dynamic Area
.IRQsema		DCD &108	;pointer to IRQsema

.miscop_sequence_no	DCD 0		;OS uses this to track changes
.emulate_1772		DCD 1		;0=710/711, 1=1772
.FDC_Error_Sector_Not_Found DCD Error_Sector_Not_Found_1772	;errors to return
.FDC_Error_Sector_CRC DCD Error_Sector_CRC_1772			;..FDC dependent
.current_PageSize	DCD 0		;size of memory pages
.cpu_id			DCD 0		;CPU model no
.obey_file_offset	DCD 0		;offset address of floppy Boot script
.os_version		DCD 0		;BCD of OS version ie 3.11 would be &31100
.force_vsync		DCD 0		;=no. of VSync's to wait at OS_Byte 113
.BootFloppyRequested	DCD 0		;=1 if the Filer wants to boot a floppy
.prevent_CMOSchanges	DCD 0		;<>0 CMOS changes are prevented
.prevent_RMKills	DCD 0		;<>0 prevent essential module kills
.prevent_Hourglass	DCD 0		;<>0 don't display hourglass

.MonotonicTime		DCD 0		;time we reset monotonic time PRM1-446

.VecPtrTab		DCD 0		;address of software vector table
					;.. &7D8 on 3.7
.new_style_error_block	DCD 0, 0, 0	;new style error for newer OS versions



.time_last		DCD 0		;time DiscOp was last called, used
					;to advance the virtual disc head

.File_Size_Limit	DCD O_File_Size_Limit * 1024

.privateWord		DCD 0		;our module private word pointer

.APD_tmp		DCD 0, 0	;temp buffer to read 4 bytes of a file

.SiS			DCD 0, 0, 0, 0	;nested sector cache
.current_density	DCD 0		;density (1, 2, 4, 8)
.sector_timing		DCD 0		;bit position * this = time in ms
					;                      from start of track


.ADFS_FileCore_Private	DCD 0		;ADFS' private word
.FileCore_Notify_Background DCD 0	;address to call after background transfer
.FileCore_Release_FIQ	DCD 0		;address to call to release floppy FIQ

.ADFS_FS_Create_Block
 DCD 0					;Filing system number etc
 DCD ADFS_Module			;Filing system title
 DCD ADFS_boot				;Boot text
 DCD Entry_DiscOp			;DiscOp entry
 DCD Entry_MiscOp			;Misc entry

.Format_Requested	DCD 0		;zero terminated format eg "F", 0
.Floppy_Title		DCD 0, 0, 0	;buffer for floppy title
.date_5byte_format	DCD 0, 0	;buffer for date result

.Format_In_Progress	DCD 0		;points to our disc rec during a format
.Format_Bad_Blocks	DCD -1		;blank bad block list

.disk_swap_pending	DCD 0		;<>0 if a disk change is pending
.disk_swap_in_progress	DCD 0		;<>0 if a disk change is occuring
.ADF_Buffer_Address	DCD 0		;address of disc data in memory
.ADF_Buffer_Length	DCD 0		;size of disc image
.ADF_Mounted		DCD 0		;0=unmounted, 1=ADF, 2=APD, 3=JFD
.ADF_Changed		DCD 0		;1=disc has changed
.APD_Temp_Track		DCD 0		;temp buffer address
.APD_Temp_Track_Length	DCD 0		;temp buffer length
.APD_File_Position	DCD 0		;current position within track
.GZ_File_Handle		DCD 0		;ZLib file handle
.APD_Temp_Header	DCD 0		;buffer for APD header
.APD_Temp_Header_Pos	DCD 0		;current position within APD header

.APD_Tracks		DCD 0		;address of track info
.APD_Sectors		DCD 0		;address of sector info
.APD_TrackSector_Length	DCD 0		;size of track and sector tables

.head_position		DCD 0		;pointer to sector head is currently on
.head_track		DCD -1		;current track head is on, reset to -1
						;..when the disc is changed

.MFM_crc		DCD 0		;FM/MFM CRC
.sec_sync_mark		DCD 0		;sector header sync mark
.bit_sync_mark		DCD 0		;bitstream sync mark
.SiS_syncmark		DCD 0		;lower byte of bit_sync_mark converted
						; from MFM / FM
.mfm5554		DCD 0		;xFM ID start
.mfm5545		DCD 0		;xFM normal data start

.DiscOp_CPSR		DCD 0		;DiscOp's CPSR to exit with
.MiscOp_CPSR		DCD 0		;MiscOp's CPSR to exit with

.recording_ptr		DCD 0		;offset of next entry in record buffer
.recording_addr		DCD 0		;address of recording buffer
.recordStack		DCD 0, 0, 0, 0, 0, -1
					;^^^ ;R1,R2,R4,[R5,#0],[R5,#DR_discsize]

.non_scatter_original	DCD 0, 0, 0	;used to return R2, R3, R4
					;  if a data or ID CRC occurs
.non_scatter_R3_return  DCD 0
			DCD 0, 0
.DiscOp_local_scatter	DCD 0, 0, -8, 0
.DiscOp_return_error	DCD 0
#if compile_GPU == 1
 .graphicsV_claimed	DCD 0		;<>0 if GraphicsV claimed
#endif
#if Private_CLib == 1
.private_CLibCounter	DCD 0		;address of CLibCounter
.private_RISCOSLibWord	DCD 0		;address of RISCOSLibWord
.private_CLibWord	DCD 0		;address of CLibWord
#endif
#if Private_BASIC == 1
.BASICTrans_loaded	DCD 0		;<>0 if BASICTrans was loaded
#endif
#if compile_RO >= 400
  .Current_Machine_State	DBB Machine_State.Size
  ALIGN
#endif
#if JIT_instruction_trace == 1
.our_IT_DA_number	DCD 0		;instruction trace DA number
.IT_DA_address		DCD 0		;instruction trace DA address
#endif