void SSD1306::setPixel(int16_t x, int16_t y, uint16_t color) { uint8_t row; uint8_t pixel; uint8_t mask; if((x < 0) ||(x >= 128) || (y < 0) || (y >= 32)) return; row = y>>3; pixel = y & 0x07; mask = 1<<pixel; if (color) { _buffer[C2B(x, row)] |= mask; } else { _buffer[C2B(x, row)] &= ~mask; } if (_buffered == 0) { setPage(row); setY(x); data(_buffer[C2B(x, row)]); } }
/* stack operator **nest** > Creates a fresh stack with current TOS on it. Saves current dstack onto > rstack. */ bvm_cache *nest(bvm_cache *this_bvm){ // nest# mword *nest_body = dstack_get(this_bvm,0); // mword *new_stack = dstack_get(this_bvm,1); mword *save_TOS = dstack_get(this_bvm,1); popd(this_bvm); popd(this_bvm); mword *save_dstack = (mword*)icar(this_bvm->dstack_ptr); mword *save_ustack = (mword*)icar(this_bvm->ustack_ptr); clear(this_bvm); // clear the stack //rgive(this_bvm, new_stack); pushd(this_bvm, save_TOS, IMMORTAL); mword *nest_return = (mword*)icdr(icar(this_bvm->code_ptr)); mword *nest_rstack_entry = consa2(this_bvm, save_dstack, consa2(this_bvm, save_ustack, consa2(this_bvm, nest_return, nil))); pushr(this_bvm, nest_rstack_entry, _hash8(C2B("/babel/tag/nest"))); this_bvm->code_ptr = consa2(this_bvm, nest_body,nil); icar(this_bvm->advance_type) = BVM_CONTINUE; return this_bvm; }
void SSD1306::updateDisplay() { for (int p = 0; p < 7; p++) { setPage(p); setY(0); for (int y = 0; y < 128; y++) { data(_buffer[C2B(y, p)]); } } }
void bpdl_init_macro_table(bvm_cache *this_bvm){ // bpdl_init_macro_table# #if(defined BPDL_TRACE || defined BABEL_RESET_TRACE) _trace; #endif this_bvm->flags->MC_USE_MALLOC = FLAG_SET; mword *macro_table = _slurp(this_bvm, C2B("src/macro_table.bbl")); bpdl_macro_table = _load(this_bvm, macro_table, size(macro_table)); this_bvm->flags->MC_USE_MALLOC = FLAG_CLR; }
void bpdl_init_opcode_table(bvm_cache *this_bvm){ // bpdl_init_opcode_table# #if(defined BPDL_TRACE || defined BABEL_RESET_TRACE) _trace; #endif this_bvm->flags->MC_USE_MALLOC = FLAG_SET; mword *opcode_table = _slurp(this_bvm, C2B("src/opcode_table.bbl")); bpdl_opcode_table = _load(this_bvm, opcode_table, size(opcode_table)); this_bvm->flags->MC_USE_MALLOC = FLAG_CLR; bpdl_return_opcode = _ith(this_bvm, trie_lookup_hash(this_bvm, bpdl_opcode_table, HASH8(this_bvm, "return"), nil), 2); }