Sunday 24 January 2010

Cross Simulator Core Graphics

One difficulty when trying to write code to plot graphics in Redcode is the width of the core display. The four most popular simulators uses a variety of different widths:

Simulator
Display Width
pMARS SDL mode 0
157
pMARS SDL mode 2
126
CoreWin
128
ARES
80
nMars
various

The simplest solution is to define a variable for the width which can be modified by the person running the program. Alternatively it's possible to use the the predefined VERSION constant to determine the simulator:

Simulator
Version
pMARS SDL mode 0
92
pMARS SDL mode 2
92
CoreWin
230
ARES
0
nMars
93

Putting the two together we can write the following code which sets the correct width for pMARS SDL, CoreWin and ARES:

width equ ( (VERSION==92)*157 + (VERSION==230)*128 + (VERSION==0)*80 )

No comments: