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

#if compile_RO > 311
 .MEMC_mask			DCD 0	;previous MEMC field mask
 .environment_handlers		DCD 0	;space to track handlers
#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
 .our_channel_handler		DBD 4	;PRM4-10 our Channel Handler
 .our_scheduler			DCD 0	;PRM4-12 our Scheduler
 .soundDMA_restarting		DCD 0	;<>0 if SoundDMA is restarting
#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
 .Error_handler_buffer		DCD 0	;pointer to error handler buffer
 .domainID			DCD &FF8	;RO3.5+ address of DomainID
 .JIT_task_ID			DCD 0, 0	;current task domain ID and Wimp ID
 .Module_being_inserted		DCD 0	;=Stub Module base during 26bit Module init
 .remapping_video_memory	DCD 0	;<>0 if we need to remap video memory
 .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
 #if compile_RO == 400
   .IRQ_vector			DCD 0	;copy of &18
 #endif

 .hypervised_vectors
   DCD 0
   .hypervised_Undefined	DCD 0
   DCD 0
   DCD 0
   DCD 0
   DCD 0
   .hypervised_IRQ		DCD 0

; STRUCT hardware_vectors
; {
;   .reset		DCD 0
;   .undefined		DCD 0
;   .swi			DCD 0
;   .prefetch		DCD 0
;   .data_abort		DCD 0
;   .address_exception	DCD 0
;   .irq			DCD 0
; }

 .hypervised_IRQ1V		DCD 0	;IRQ1V entry
 .page_zero_EnvString		DCD 0	;RO address of EnvString
 .page_zero_EnvTime		DCD 0	;RO address of EnvTime

 #if JIT_predictive_branching == 1
 ;-------------- BRANCH PREDICTION ------------
				DCD 0	;current pointer in the circular BPT
 .JIT_branch_prediction_table	DBD JIT_branch_prediction_max
 ;--------- END OF BRANCH PREDICTION ----------
 #endif
 .VProtect_Module		DCD 0	;address of VProtect Module
				DCD 0	;size of VProtect
 .JIT_ARM4			DCD 0	;JIT mode - bits 0..7 0=ARMv3 1=ARMv4
					;   cache   bit 31    0=on    1=off
 .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_os_exit		DCD 0	;SWI OS_Exit
 .jit_managed_swi		DCD 0	;SWI 0

 .jit_task_count		DCD 0	;number of JIT tasks running
 .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

 .jit_claimed_vectors		DCD 0	;address of claimed vector table
 .Vector_Claim_Handlers		DCD 0	;address of vector entry points
 .DeviceVectors	DBB (last_device_to_track + 1) * device_table.size
 ALIGN

 #if compile_IOMD == 1 OR compile_GPU == 1
   .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
 #endif
 #if compile_GPU == 1
   .old_VIDC20_HCR		DCD 0	;overall screen width
   .old_VIDC20_VCR		DCD 0	;overall screen height
   .our_GraphicsV_ID		DCD 0	;<>0 if GraphicsV claimed
 #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
   .blitter_FPS		DCD 0		;refresh rate of the blitter
 #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
 .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
 .vsync_unthreaded		DCD 0		;<>0 raise VSync unthreaded
 .IOC_registers			DBB &80 >> 2	;1 byte per IOC register
				ALIGN
#endif

 .SVC_stack_init		DCD 0		;top of SVC stack
#if compile_RO == 400
 .riscos6			DCD 0		;<>0 if running on RISCOS6
#endif
#if compile_RO > 311
 .IRQ_stack_init		DCD 0		;top of IRQ stack
 .transient_stack_DA_number	DCD 0
 .transient_stacks		DCD 0		;address of transient stacks
 .transient_stacks_used		DCD 0		;bitmap of used stacks
 .IOC_IRQ_stack			DCD 0		;stack used for IOC IRQ emulation
 .pre_JIT_wimp_slot_size	DCD 0		;size of WimpSlot to return
 #if compile_RO == 400
   .abt_stack			DCD 0		;32bit Abort stack on IOMD
   .abort_stack_DA_number	DCD 0
   .und_stack			DCD 0		;32bit Abort stack on IOMD
   .undefined_stack_DA_number	DCD 0
 #endif
 #if compile_IOMD == 1
  .VIDC20_addr		DCD VIDC20_base_addr	;base address of VIDC20
  .TV_offset		DCD 0			;*TV adjustment
 #endif

  .MEMC_CinitOS	DCD 0			;pointer address as passed by the OS
.MEMC_registers				;MEMC registers
  .MEMC_Vinit	DCD 0
  .MEMC_Vstart	DCD 0
  .MEMC_Vend	DCD 0
  .MEMC_Cinit	DCD RO3xx_Pointer_Buffer
  .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*(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
.miscop_floppy_HD	DCD 0		;is the floppy HD?
.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
 #if compile_RO >= 450
  .current_PageSizeSH	DCD 0		;size of memory pages as a shift (1<<n)
 #endif
.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

.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_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

.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
.floppy_content_changed	DCD 0		;<>0 if floppy needs flushing

.BASICTrans_loaded	DCD 0		;<>0 if BASICTrans was loaded
#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
.instruction_trace_ptr	DCD 0		;address of the instruction trace
#endif

.ZIP_workspace		DCD 0		;pointer to RMA allocation

; ******* Joystick variables *********
			DCD 0		;Event_Joystick, must directly preceed Joystick_Keymapping
			;Jn RLDU B1 B2 B3 B4 B5 B6 B7 B8
			;        A  B  X  Y  LB RB Bk St
.Joystick_Keymapping	DBB Max_Joysticks*Joystick_Keys.size, &FF
.Joystick_Buttons	DBD Max_Joysticks
.Econet_Registers	DCD &F8, 0, 0, 0 ;Econet, %FUDLR, %UDLFR000
#if Max_Joysticks>3
  DBD Max_Joysticks-3
#endif
.screen_OS_units_X	DCD 0		;width of screen in OS units
.screen_OS_units_Y	DCD 0		;height of screen in OS units
.Joystick_Mousemapping	DBB Joystick_Mouse.size
.Joystick_DeadZones	DBD Max_Joysticks, Joystick_Percentage*25
.Joystick_DeadZonesSQ	DBD Max_Joysticks, (Joystick_Percentage*25)^2
; ************************************

.DiscOp_CPSR		DCD 0		;DiscOp's CPSR to exit with
.MiscOp_CPSR		DCD 0		;MiscOp's CPSR to exit with
.trap_aborts_in_Finalise	DCD 0	;<>0 if Module Finalise executing
