' "save_palette" should be run BEFORE your program resets the colours.
' "restore_palette" should be run RIGHT BEFORE your program ENDs.
' Save will save the original desktop colours. Restore will restore them
' after your program ends.
DIM palette(16)             ! DIMension integar array for storing colour numbers
@save_palette               ! Save Desktop colours
SETCOLOR 0,0,0,0            ! Invert screen colours
SETCOLOR 3,7,7,7
PRINT "HELLO"               ! print HELLO
~INP(2)                     ! wait for keypress
'
@restore_palette            ! Restore desktop colours
END                         ! End program
'
PROCEDURE save_palette
  LOCAL i                   ! Limit influence of variable
  FOR ctr%=0 TO 15
    palette(ctr%)=XBIOS(7,W:ctr%,W:-1)  ! XBIOS(7,ctr%,c%) sets or determines
  NEXT ctr%                             ! colour register.
RETURN                                  ! ctr%=number of colour register(0-15)
'                                       ! c%=-1 for new color
PROCEDURE restore_palette
  LOCAL ctr%               ! Limit influence of variable
  FOR ctr%=0 TO 15
    SETCOLOR ctr%,palette(ctr%)         ! restore colours using the numbers
  NEXT ctr%                             ! saved in the palette() array.
RETURN
