set display mode 1024,768,32
hide mouse
sync on
sync rate 100
gosub backdrop
 
rem === MAIN ===
do
  rem input
  u=upkey()*100:d=downkey()*100
  inc range,u-d
  if range <1 then range=1
 
  rem output
  copy bitmap 1,0
  for n = 0 to 199
    cx = (n/40)*200
    cy = (n-(n/40)*40)*18
    set cursor cx,cy
    print n+range;" =  ";romanums$(n+range)
  next n
  sync
loop
end
 
rem === SUBROUTINES ===
backdrop:
  sw = screen width()
  sh = screen height()
  create bitmap 1,sw,sh
  for i = 0 to 255
    ink i,0
    box 0,i*(sh/255),sw-1,(i+1)*3
  next i
  set text font "arial",1
  set text size 14
  set text to italic
  ink -2,0
  text sw-50,sh-16,"OBese87"
  set text to normal
  set text size 20
  text 1,sh-20,"Press UP to increase the numbers and DOWN to decrease them."
  set current bitmap 0
return
`//
 
rem === FUNCTIONS ===
function romanums$(n)
  num$ = ""
  while n>0
    rem I's
    if n<5
      num$ = num$+"I"
      if n>=4 then inc n,1 else dec n,1
    else
      rem V's
      if n<9
        num$ = num$+"V" : dec n,5
      else
        rem I for 9
        if n<10
          num$ = num$+"I" : inc n,1
        else
          rem X's (same as I's)
          if n<50
            num$ = num$+"X"
            if n>=40 then inc n,10 else dec n,10
          else
            rem L's (same as V's)
            if n<90
              num$ = num$+"L" : dec n,50
            else
              rem X for 90 (same as I for 9)
              if n<100
                num$ = num$+"X" : inc n,10
              else
                rem C's (same as I's)
                if n<500
                  num$ = num$+"C"
                  if n>=400 then inc n,100 else dec n,100
                else
                  rem D's (same as V's)
                  if n<900
                    num$ = num$+"D" : dec n,500
                  else
                    rem C for 900 (same as I for 9)
                    if n<1000
                      num$ = num$+"C" : inc n,100
                    else
                      rem M's (final character)
                      num$ = num$+"M" : dec n,1000
                    endif
                  endif
                endif
              endif
            endif
          endif
        endif
      endif
    endif
  endwhile
endfunction num$