about summary refs log tree commit diff stats
path: root/js/games/nluqo.github.io/~bh/v3ch2/math31.gif
Commit message (Expand)AuthorAgeFilesLines
* *elioat2023-08-231-0/+0
>12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63






























































                                                                                                 
# Guess the result of mixing two colors.

fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) {
  var second-buffer: screen
  var second-screen/edi: (addr screen) <- address second-buffer
  initialize-screen second-screen, 0x80, 0x30, 1/include-pixels
  var leftx/edx: int <- copy 0x80
  var rightx/ebx: int <- copy 0x380
  {
    compare leftx, rightx
    break-if->=
    clear-screen second-screen
    # interesting value: 9/blue with 0xe/yellow
    color-field second-screen, leftx 0x40/y, 0x40/width 0x40/height, 1/blue
    color-field second-screen, rightx 0x41/y, 0x40/width 0x40/height, 2/green
    copy-pixels second-screen, screen
    # on the first iteration, give everyone a chance to make their guess
    {
      compare leftx, 0x80
      break-if->
      var x/eax: byte <- read-key keyboard
      compare x, 0
      loop-if-=
    }
    leftx <- add 2
    rightx <- subtract 2
    loop
  }
}

fn color-field screen: (addr screen), xmin: int, ymin: int, width: int, height: int, color: int {
  var xmax/esi: int <- copy xmin
  xmax <- add width
  var ymax/edi: int <- copy ymin
  ymax <- add height
  var y/eax: int <- copy ymin
  {
    compare y, ymax
    break-if->=
    var x/ecx: int <- copy xmin
    {
      compare x, xmax
      break-if->=
      pixel screen, x, y, color
      x <- add 2
      loop
    }
    y <- increment
    compare y, ymax
    break-if->=
    var x/ecx: int <- copy xmin
    x <- increment
    {
      compare x, xmax
      break-if->=
      pixel screen, x, y, color
      x <- add 2
      loop
    }
    y <- increment
    loop
  }
}