#name ^.Object.SortScreen
#type &ffd

#include <Bolmaster$Path>Sources.Structures
#include <Bolmaster$Path>Sources.Variables

;Sorts out the screen, changing mode and accessing files if necessary

LDR R0,[R12,#v.mode]
LDR R1,[R12,#v.loadedmode]
CMP R0,R1
BEQ modeok
STR R0,[R12,#v.loadedmode]
SWI 256+22
SWI OS_WriteC
MOV R0,#0
STR R0,[R12,#v.scr]
.modeok
MOV R0,#113
MOV R1,#1
SWI OS_Byte
ADR R0,vdublock
ADD R1,R12,#v.screenadr
SWI OS_ReadVduVariables
B skip
.vdublock
DCD 149;disp.hardware scr start
DCD 150;mode size
DCD 6
DCD -1
.skip
LDR R0,[R12,#v.scr]
LDR R1,[R12,#v.loadedscr]
CMP R0,R1
BEQ scrok
;load a screen here
LDR R0,[R12,#v.scr]
STR R0,[R12,#v.loadedscr]
.scrok
