Most of the MMBasic for my vector game gets written in MMB4L on the Mac, with testing on the CMM2. Both speak MMBasic, but the graphics commands aren’t the same. MMB4L uses GRAPHICS WINDOW, GRAPHICS BUFFER, GRAPHICS WRITE, and GRAPHICS COPY. The CMM2 calls it MODE, PAGE WRITE, and PAGE COPY. Rather than maintain two files, I drive both from one source.
Detect the platform
MM.DEVICE$ returns the platform name. MMB4L gives you "MMB4L", the CMM2 returns something else. I turn that into two flags I reference everywhere later on.
DIM INTEGER IS_MMB4L, IS_CMM2
IF MM.DEVICE$ = "MMB4L" THEN
IS_MMB4L = 1
IS_CMM2 = 0
ELSE
IS_MMB4L = 0
IS_CMM2 = 1
ENDIF
Set up graphics
On MMB4L you have to create the window and an off-screen buffer yourself. On the CMM2, MODE 1, 8 switches into graphics mode and gives you several pages right away.
IF IS_MMB4L THEN
GRAPHICS WINDOW 0, SCREEN_W, SCREEN_H, -1, -1, "Game"
GRAPHICS BUFFER 1, SCREEN_W, SCREEN_H
ELSEIF IS_CMM2 THEN
MODE 1, 8
CLS
ENDIF
Inside the frame loop
I always draw to the off-screen buffer and copy it to the display at the end of the frame. That avoids the flicker you get the moment you draw straight to the visible page.
IF IS_MMB4L THEN
GRAPHICS WRITE 1
GRAPHICS CLS 1, RGB(BLACK)
ELSEIF IS_CMM2 THEN
PAGE WRITE 1
CLS
ENDIF
' draw all objects
IF IS_MMB4L THEN
GRAPHICS COPY 1 TO 0
ELSEIF IS_CMM2 THEN
PAGE COPY 1 TO 0
ENDIF
What cost me hours early on: the buffer-1-as-working, page-0-as-display logic is identical on both platforms, but the commands around it aren’t. Miss one branch and you get smeared frames or a black screen. I deliberately keep the two paths sitting right next to each other so I can tell at a glance that both sides are up to date.
The geometry and math primitives like LINE, POLYGON, PIXEL, and the MATH family behave the same on both. So the platform switch only matters during init and at the top and bottom of the frame loop. Everything in between stays clean.