OBJ c : "clibsd" dat score0 long 0 score1 long 0 ymin long 0 center long 0 pub splash c.putchar(0) c.printf0(string("PONG\n")) c.printf0(string("----\n")) c.printf0(string("Press 'q' and 'a' to move the")) c.printf0(string(" left paddle up and down\n")) c.printf0(string("Press 'p' and 'l' to move the")) c.printf0(string(" right paddle up and down\n")) c.printf0(string("Press 'x' to exit\n")) c.printf0(string("Press any key to start\n")) c.getchar pub updatevars(p_ymin, p_center, p_score0, p_score1) ymin := p_ymin center := p_center score0 := p_score0 score1 := p_score1 pub plotit(xpos, ypos, val) moveto(xpos, ypos) c.putchar(val) pub moveto(xpos, ypos) c.putchar(2) c.putchar(xpos) c.putchar(ypos) pub kbhit | stream, handle, rxhead, rxtail stream := c.getstdin handle := long[stream][1] rxhead := word[handle][6] rxtail := word[handle][7] return rxhead <> rxtail dat digit byte %111111, %110011, %110011, %110011, %111111 byte %001100, %011100, %001100, %001100, %011110 byte %111111, %000011, %111111, %110000, %111111 byte %111111, %000011, %001111, %000011, %111111 byte %110011, %110011, %111111, %000011, %000011 byte %111111, %110000, %111111, %000011, %111111 byte %111111, %110000, %111111, %110011, %111111 byte %111111, %000011, %000110, %000110, %000110 byte %111111, %110011, %111111, %110011, %111111 byte %111111, %110011, %111111, %000011, %000011 pub getval(xpos, ypos) | ptr, val if xpos == center return "." if ypos < ymin + 1 or ypos > ymin + 5 return " " if xpos < center - 8 or xpos > center + 8 return " " if xpos > center - 3 and xpos < center + 3 return " " if xpos < center val := score0 xpos -= center - 8 else val := score1 xpos -= center + 3 val := byte[@digit][val*5 + ypos - ymin - 1] if val & ($20 >> xpos) result := "#" else result := " " pub putnum(xpos, ypos, num) | ptr, temp, i, j i := 5 ptr := @digit + (num//10)*5 repeat while i-- j := 6 temp := byte[ptr++] moveto(xpos, ypos++) repeat while j-- if temp & $20 c.putchar("#") else c.putchar(" ") temp <<= 1 pub plotpaddle(xpos, ypos, height) | i i := ypos - height repeat while i =< ypos + height plotit(xpos, i, "#") i++