void TileMapView::Draw() { if (!tile_source_) { return; } glEnable(GL_TEXTURE_2D); DrawTiles( precache_, 0 ); DrawTiles( tiles_, 10000 ); glDisable(GL_TEXTURE_2D); }
// ---------------------------------------------------------------------------- void Main() { PushBank( BANKC1 ); LoadFile( ANGELTITLE1BIGFILE_TRACKFILEID, ANGELTITLE1H_DATAPTR ); // TITLE TOP IN C1-CODESEGMENT4000 memcpy( CODESEGMENT4000, ANGELTITLEBMPTOPBINPCK_PTR, ANGELTITLEBMPTOPBINPCK_SIZE ); PopBank(); // TITLE BOTTOM IN C3-CODESEGMENT4000 bank_memcpy( 0xC0, CODESEGMENTC000, ANGELTITLEBMPBOTTOMBINPCK_PTR, ANGELTITLEBMPBOTTOMBINPCK_SIZE ); Unpack( VIDEOSEGMENTC000, ANGELTILEBMPSPRRAWDATA1PCK_PTR ); ShiftTile( VIDEOSEGMENTC000 ); SetPaletteFrom8( GetPalette() ); // Cloud BankUnpack( 0xC4, CODESEGMENT0000, VIDEOSEGMENT0000 ); // Draw Cloud PushBank( BANKC1 ); DrawTiles(MASKTYPE_NOMASK, VIDEOSEGMENT0000, VIDEOSEGMENT4000, VIDEOSEGMENTC000 ); PopBank(); DrawCloud_VIDEOSEGMENT8000(); // Apply Part palette UnshiftTile( VIDEOSEGMENTC000 ); PushBank( BANKC1 ); DrawTiles(MASKTYPE_NOMASK, VIDEOSEGMENT0000, VIDEOSEGMENT4000, VIDEOSEGMENTC000 ); PopBank(); WaitVBL(); SetPalette( GetPalette() ); FlipScreen(); // Load Cloud LoadFile( ANGELTITLECLOUDBMPBINPCK_TRACKFILEID, VIDEOSEGMENT8000 ); BankUnpack( 0xC4, CODESEGMENT0000, VIDEOSEGMENT8000 ); BankUnpack( 0xC1, VIDEOSEGMENT8000, CODESEGMENT4000 ); BankUnpack( 0xC0, VIDEOSEGMENTC000, CODESEGMENTC000 ); PushBank( BANKC3 ); DrawTiles(MASKTYPE_MASK, VIDEOSEGMENT8000, VIDEOSEGMENT4000, VIDEOSEGMENTC000 ); PopBank(); DrawCloudReverse_VIDEOSEGMENT0000(); }
void DocEdit::Paint(Draw& w) { Size sz = GetSize(); Color bg = color[IsShowEnabled() && !IsReadOnly() ? PAPER_NORMAL : PAPER_READONLY]; if(nobg) bg = Null; int y = -sb + 1; int pos = 0; int sell, selh; GetSelection(sell, selh); for(int i = 0; i < para.GetCount() && y < sz.cy; i++) { int h = GetHeight(i); if(y + h >= 0) { WString text = line[i]; Fmt fmt = Format(text); int p = pos; for(int i = 0; i < fmt.line.GetCount(); i++) { int n = fmt.LineEnd(i) - fmt.line[i]; int a = minmax(sell - p, 0, n); int b = minmax(selh - p, 0, n) - a; int c = n - a - b; int *wa = fmt.width + fmt.line[i]; int *wb = fmt.width + fmt.line[i] + a; int *wc = fmt.width + fmt.line[i] + a + b; int acx = sSum(wa, a); int bcx = sSum(wb, b); int ccx = sSum(wc, c); w.DrawRect(1, y, acx, fmt.fi.GetHeight(), bg); w.DrawText(1, y, ~fmt.text + fmt.line[i], font, IsShowEnabled() ? color[INK_NORMAL] : color[INK_DISABLED], a, wa); w.DrawRect(1 + acx, y, bcx, fmt.fi.GetHeight(), color[PAPER_SELECTED]); w.DrawText(1 + acx, y, ~fmt.text + fmt.line[i] + a, font, color[INK_SELECTED], b, wb); w.DrawRect(1 + acx + bcx, y, ccx, fmt.fi.GetHeight(), bg); w.DrawText(1 + acx + bcx, y, ~fmt.text + fmt.line[i] + a + b, font, color[INK_NORMAL], c, wc); p += n; w.DrawRect(1 + acx + bcx + ccx, y, cx - (acx + bcx + ccx), fmt.fi.GetHeight(), p >= sell && p < selh ? color[PAPER_SELECTED] : bg); y += fmt.fi.GetHeight(); } w.DrawRect(1, y, cx, after, color[PAPER_NORMAL]); y += after; } else y += h; pos += line[i].GetLength() + 1; } w.DrawRect(0, -sb, sz.cx, 1, bg); w.DrawRect(0, 0, 1, sz.cy, bg); w.DrawRect(sz.cx - 1, 0, 1, sz.cy, bg); if(eofline) w.DrawRect(1, y++, cx, 1, SColorShadow); if(y < sz.cy) w.DrawRect(1, y, cx, sz.cy - y, bg); DrawTiles(w, DropCaret(), CtrlImg::checkers()); }
// d2 d6 d5 d4 a3 a4 void DrawTiles_LR_2(int patternBase, int numTiles, int x, int y, int* layerCoords, ubyte** layout) { auto addr = Calc_VRAM_Pos(x, y, layerCoords); uint* tileAddr; for(int i = 0; i < numTiles; i++) { auto block = GetBlockAddr(x, y, layerCoords, layout, tileAddr); DrawTiles(addr, patternBase, tileAddr, block); addr = (addr + 4) & 0x7F; x += 16; } }
void LineEdit::Paint0(Draw& w) { int sell, selh; GetSelection(sell, selh); if(!IsEnabled()) sell = selh = 0; Size sz = GetSize(); Size fsz = GetFontSize(); Point sc = sb; int ll = min(line.GetCount(), sz.cy / fsz.cy + sc.y + 1); int y = 0; cpos = GetPos(sc.y); cline = sc.y; sell -= cpos; selh -= cpos; int pos = cpos; Vector<int> dx, dx2; int fascent = font.Info().GetAscent(); for(int i = sc.y; i < ll; i++) { WString tx = line[i]; int len = tx.GetLength(); if(w.IsPainting(0, y, sz.cx, fsz.cy)) { Highlight ih; ih.ink = color[IsShowEnabled() ? INK_NORMAL : INK_DISABLED]; ih.paper = color[IsReadOnly() || !IsShowEnabled() ? PAPER_READONLY : PAPER_NORMAL]; if(nobg) ih.paper = Null; ih.font = font; ih.chr = 0; Vector<Highlight> hl; hl.SetCount(len + 1, ih); for(int q = 0; q < tx.GetCount(); q++) hl[q].chr = tx[q]; HighlightLine(i, hl, pos); int ln = hl.GetCount() - 1; int l = max(sell, 0); int h = selh > len ? len : selh; if(l < h) for(int i = l; i < h; i++) { hl[i].paper = color[PAPER_SELECTED]; hl[i].ink = color[INK_SELECTED]; } if(sell <= len && selh > len) for(int i = len; i < hl.GetCount(); i++) { hl[i].paper = color[PAPER_SELECTED]; hl[i].ink = color[INK_SELECTED]; } Buffer<wchar> txt(ln); for(int i = 0; i < ln; i++) txt[i] = hl[i].chr; for(int pass = 0; pass < 2; pass++) { int gp = 0; int scx = fsz.cx * sc.x; if(ln >= 0) { int q = 0; while(q < ln) { Highlight& h = hl[q]; if(txt[q] == '\t') { int ngp = (gp + tabsize) / tabsize * tabsize; int l = ngp - gp; LLOG("Highlight -> tab[" << q << "] paper = " << h.paper); if(pass == 0) { w.DrawRect(gp * fsz.cx - scx, y, fsz.cx * l, fsz.cy, h.paper); if(showtabs && h.paper != SColorHighlight && q < tx.GetLength()) { Color c = Blend(SColorLight, SColorHighlight); w.DrawRect(gp * fsz.cx - scx + 2, y + fsz.cy / 2, l * fsz.cx - 4, 1, c); w.DrawRect(ngp * fsz.cx - scx - 3, y + 3, 1, fsz.cy - 6, c); } if(bordercolumn > 0 && bordercolumn >= gp && bordercolumn < gp + l) w.DrawRect((bordercolumn - sc.x) * fsz.cx, y, 1, fsz.cy, bordercolor); } q++; gp = ngp; } else if(txt[q] == ' ') { LLOG("Highlight -> space[" << q << "] paper = " << h.paper); if(pass == 0) { w.DrawRect(gp * fsz.cx - scx, y, fsz.cx, fsz.cy, h.paper); if(showspaces && h.paper != SColorHighlight && q < tx.GetLength()) { Color c = Blend(SColorLight, SColorHighlight); w.DrawRect(gp * fsz.cx - scx + fsz.cx / 2, y + fsz.cy / 2, 2, 2, c); } if(bordercolumn > 0 && bordercolumn >= gp && bordercolumn < gp + 1) w.DrawRect((bordercolumn - sc.x) * fsz.cx, y, 1, fsz.cy, bordercolor); } q++; gp++; } else { bool cjk = IsCJKIdeograph(txt[q]); int p = q + 1; while(p < len && h == hl[p] && txt[p] != '\t' && txt[p] != ' ' && IsCJKIdeograph(txt[p]) == cjk && p - q < 128) p++; int l = p - q; int ll = cjk ? 2 * l : l; LLOG("Highlight -> paper[" << q << "] = " << h.paper); int x = gp * fsz.cx - scx; int xx = x + (gp + ll) * fsz.cx; if(max(x, 0) < min(xx, sz.cx)) if(pass == 0) { w.DrawRect(x, y, fsz.cx * ll, fsz.cy, h.paper); if(bordercolumn > 0 && bordercolumn >= gp && bordercolumn < gp + ll) w.DrawRect((bordercolumn - sc.x) * fsz.cx, y, 1, fsz.cy, bordercolor); } else { if(cjk) dx2.At(l, 2 * fsz.cx); else dx.At(l, fsz.cx); w.DrawText(x, y + fascent - h.font.Info().GetAscent(), ~txt + q, h.font, h.ink, l, cjk ? dx2 : dx); } q = p; gp += ll; if(x > sz.cx) break; } } } if(pass == 0) { int gpx = gp * fsz.cx - scx; w.DrawRect(gpx, y, sz.cx - gpx, fsz.cy, hl.Top().paper); if(bordercolumn > 0 && bordercolumn >= gp) w.DrawRect((bordercolumn - sc.x) * fsz.cx, y, 1, fsz.cy, bordercolor); } } } y += fsz.cy; sell -= len + 1; selh -= len + 1; pos += len + 1; } w.DrawRect(0, y, sz.cx, sz.cy - y, color[IsReadOnly() || !IsShowEnabled() ? PAPER_READONLY : PAPER_NORMAL]); DrawTiles(w, DropCaret(), CtrlImg::checkers()); }
void CZone::DrawZone() { DrawTiles(); // draw the tiles (ground) first. DrawEnvironment(); // then the environment.. cliffs, trees, stones, water ... you name it. // DrawShadows(); // then draw the shadows (not shadows from environment objects but, cloudy areas, darker places etc). }
// ---------------------------------------------------------------------------- void Main() { // Load Tile (8-15 pixel index range) LoadFile( PLASMATILE2BMPSPRRAWDATA1PCK_TRACKFILEID, VIDEOSEGMENT0000 ); Unpack( VIDEOSEGMENTC000, VIDEOSEGMENT0000 ); ShiftTile( VIDEOSEGMENTC000 ); SetPaletteFrom8( GetPalette() ); // Load Transit Data LoadFile( TRANSITLINESFX2BINPCK_TRACKFILEID, VIDEOSEGMENT0000 ); BankUnpack( 0xC4, 0x6880, VIDEOSEGMENT0000 ); // Load Transit Code LoadFile( MAINDRAWTRIANGLEONLYZ80BINPCK_TRACKFILEID_2, VIDEOSEGMENT0000 ); Unpack( CODESEGMENT0000, VIDEOSEGMENT0000 ); // Draw Transit Line FX PushBank( BANKC1 ); DrawTiles(MASKTYPE_NOMASK, VIDEOSEGMENT0000, VIDEOSEGMENT4000, VIDEOSEGMENTC000 ); PopBank(); bank_memcpy( 0xC6, 0x4080, VIDEOSEGMENT8000, VIDEOSEGMENT8000_SIZE ); bank_memcpy( 0xC7, VIDEOSEGMENT4000, VIDEOSEGMENTC000, VIDEOSEGMENTC000_SIZE ); bank_memcpy( 0xC4, 0x4080, VIDEOSEGMENT0000, VIDEOSEGMENT0000_SIZE); bank_memcpy( 0xC0, 0x7000, VIDEOSEGMENT4000, 0x1000 ); bank_memcpy( 0xC0, 0xE800, 0x5000, 0x1800 ); __asm call _IsScreenFlipped ld a, l call &2800 __endasm; // PATCH bank_memcpy( 0xC0, VIDEOSEGMENTC000, VIDEOSEGMENT4000, VIDEOSEGMENT4000_SIZE ); // Load title PushBank( BANKC1 ); LoadFile( PLASMATITLEBIGFILE_TRACKFILEID, CODESEGMENT4000 ); PopBank(); // Load Cloud LoadFile( PLASMATITLECLOUDBMPBINPCK_TRACKFILEID, VIDEOSEGMENT0000 ); BankUnpack( 0xC4, CODESEGMENT0000, VIDEOSEGMENT0000 ); // Apply Part palette LoadFile( PLASMATILE2BMPSPRRAWDATA1PCK_TRACKFILEID_2, VIDEOSEGMENT0000 ); Unpack( VIDEOSEGMENTC000, VIDEOSEGMENT0000 ); UnshiftTile( VIDEOSEGMENTC000 ); PushBank( BANKC1 ); DrawTiles(MASKTYPE_NOMASK, VIDEOSEGMENT0000, VIDEOSEGMENT4000, VIDEOSEGMENTC000 ); PopBank(); WaitVBL(); SetPalette( GetPalette() ); FlipScreen(); // Load title BankUnpack( 0xC0, VIDEOSEGMENT8000, PLASMATITLEBMPTOPBINPCK_PTR ); BankUnpack( 0xC0, VIDEOSEGMENTC000, PLASMATITLEBMPBOTTOMBINPCK_PTR ); PushBank( BANKC3 ); DrawTiles(MASKTYPE_MASK, VIDEOSEGMENT8000, VIDEOSEGMENT4000, VIDEOSEGMENTC000 ); PopBank(); // Prepare for part bank_memcpy( 0xC6, CODESEGMENT4000, CODESEGMENT0000, CODESEGMENT0000_SIZE ); DrawCloudReverse_VIDEOSEGMENT0000(); FlipScreen(); // Load Cloud LoadFile( PLASMATITLECLOUD3BMPBINPCK_TRACKFILEID, VIDEOSEGMENT0000 ); BankUnpack( 0xC4, CODESEGMENT0000, VIDEOSEGMENT0000 ); bank_memcpy( 0xC6, CODESEGMENT4000, CODESEGMENT0000, CODESEGMENT0000_SIZE ); LoadFile( PLASMABACKGROUNDBMPTOPBINPCK_TRACKFILEID, VIDEOSEGMENT0000 ); BankUnpack( 0xC6, VIDEOSEGMENT4000, VIDEOSEGMENT0000 ); LoadFile( PLASMADATA1BIGFILEPCK_TRACKFILEID, CODESEGMENT0000 ); PushBank( BANKC1 ); Unpack( CODESEGMENT4000, CODESEGMENT0000 ); PopBank(); bank_memcpy( 0xC0, CODESEGMENTC000, CODESEGMENT4000, CODESEGMENT4000_SIZE ); bank_memcpy( 0xC6, VIDEOSEGMENT0000, VIDEOSEGMENT4000, VIDEOSEGMENT0000_SIZE ); LoadFile( PLASMABACKGROUNDBMPBOTTOMBINPCK_TRACKFILEID, CODESEGMENT0000 ); PushBank( BANKC1 ); Unpack( VIDEOSEGMENT4000, CODESEGMENT0000 ); PopBank(); LoadFile( PLASMATITLECLOUD2BMPBINPCK_TRACKFILEID, VIDEOSEGMENTC000 ); }
void LineEdit::Paint0(Draw& w) { LTIMING("LineEdit::Paint0"); int sell, selh; GetSelection(sell, selh); if(!IsEnabled()) sell = selh = 0; Rect rect; bool rectsel = IsRectSelection(); if(IsRectSelection()) rect = GetRectSelection(); Size sz = GetSize(); Size fsz = GetFontSize(); Point sc = sb; int ll = min(line.GetCount(), sz.cy / fsz.cy + sc.y + 1); int y = 0; sc.y = minmax(sc.y, 0, line.GetCount() - 1); cpos = GetPos(sc.y); cline = sc.y; sell -= cpos; selh -= cpos; int pos = cpos; int fascent = font.Info().GetAscent(); int cursorline = GetLine(cursor); Highlight ih; ih.ink = color[IsShowEnabled() ? INK_NORMAL : INK_DISABLED]; ih.paper = color[IsReadOnly() && showreadonly || !IsShowEnabled() ? PAPER_READONLY : PAPER_NORMAL]; if(nobg) ih.paper = Null; ih.font = font; ih.chr = 0; for(int i = sc.y; i < ll; i++) { Color showcolor = color[WHITESPACE]; WString tx = line[i]; bool warn_whitespace = false; if(warnwhitespace && !IsSelection()) { int pos = GetCursor(); int linei = GetLinePos(pos); if(linei != i || pos < tx.GetCount()) { int wkind = 0; bool empty = true; for(const wchar *s = tx; *s; s++) { if(*s == '\t') { if(wkind == ' ') { warn_whitespace = true; break; } wkind = '\t'; } else if(*s == ' ') wkind = ' '; else if(*s > ' ') { empty = false; wkind = 0; } } if(wkind && !empty) warn_whitespace = true; if(warn_whitespace) showcolor = color[WARN_WHITESPACE]; } } bool do_highlight = tx.GetCount() < 100000; int len = tx.GetLength(); if(w.IsPainting(0, y, sz.cx, fsz.cy)) { LTIMING("PaintLine"); Vector<Highlight> hl; int ln; if(do_highlight) { hl.SetCount(len + 1, ih); for(int q = 0; q < tx.GetCount(); q++) hl[q].chr = tx[q]; LTIMING("HighlightLine"); HighlightLine(i, hl, pos); ln = hl.GetCount() - 1; } else ln = tx.GetCount(); int lgp = -1; for(int pass = 0; pass < 2; pass++) { int gp = 0; int scx = fsz.cx * sc.x; sOptimizedRectRenderer rw(w); if(ln >= 0) { int q = 0; int x = 0; int scx2 = scx - max(2, tabsize) * fsz.cx; while(q < ln && x < scx2) { // Skip part before left border wchar chr = do_highlight ? hl[q++].chr : tx[q++]; if(chr == '\t') { gp = (gp + tabsize) / tabsize * tabsize; x = fsz.cx * gp; } else if(IsCJKIdeograph(chr)) { x += 2 * fsz.cx; gp += 2; } else { x += fsz.cx; gp++; } } sOptimizedTextRenderer tw(w); while(q < ln) { if(q == tx.GetCount()) lgp = gp; Highlight h; if(do_highlight) h = hl[q]; else { h = ih; h.chr = tx[q]; } int pos = min(q, len); // Highligting can add chars at the end of line if(rectsel ? i >= rect.top && i <= rect.bottom && gp >= rect.left && gp < rect.right : pos >= sell && pos < selh) { h.paper = color[PAPER_SELECTED]; h.ink = color[INK_SELECTED]; } int x = gp * fsz.cx - scx; if(h.chr == '\t') { int ngp = (gp + tabsize) / tabsize * tabsize; int l = ngp - gp; LLOG("Highlight -> tab[" << q << "] paper = " << h.paper); if(pass == 0 && x >= -fsz.cy * tabsize) { rw.DrawRect(x, y, fsz.cx * l, fsz.cy, h.paper); if((showtabs || warn_whitespace) && h.paper != SColorHighlight && q < tx.GetLength()) { rw.DrawRect(x + 2, y + fsz.cy / 2, l * fsz.cx - 4, 1, showcolor); rw.DrawRect(ngp * fsz.cx - scx - 3, y + 3, 1, fsz.cy - 6, showcolor); } if(bordercolumn > 0 && bordercolumn >= gp && bordercolumn < gp + l) rw.DrawRect((bordercolumn - sc.x) * fsz.cx, y, 1, fsz.cy, bordercolor); } q++; gp = ngp; } else if(h.chr == ' ') { LLOG("Highlight -> space[" << q << "] paper = " << h.paper); if(pass == 0 && x >= -fsz.cy) { rw.DrawRect(x, y, fsz.cx, fsz.cy, h.paper); if((showspaces || warn_whitespace) && h.paper != SColorHighlight && q < tx.GetLength()) { int n = fsz.cy / 10 + 1; rw.DrawRect(x + fsz.cx / 2, y + fsz.cy / 2, n, n, showcolor); } if(bordercolumn > 0 && bordercolumn >= gp && bordercolumn < gp + 1) rw.DrawRect((bordercolumn - sc.x) * fsz.cx, y, 1, fsz.cy, bordercolor); } q++; gp++; } else { bool cjk = IsCJKIdeograph(h.chr); LLOG("Highlight -> paper[" << q << "] = " << h.paper); int xx = x + (gp + 1 + cjk) * fsz.cx; if(max(x, 0) < min(xx, sz.cx) && fsz.cx >= -fsz.cy) { if(pass == 0) { rw.DrawRect(x, y, (cjk + 1) * fsz.cx, fsz.cy, h.paper); if(bordercolumn > 0 && bordercolumn >= gp && bordercolumn < gp + 1 + cjk) rw.DrawRect((bordercolumn - sc.x) * fsz.cx, y, 1, fsz.cy, bordercolor); } else tw.DrawChar(x + (h.flags & SHIFT_L ? -fsz.cx / 6 : h.flags & SHIFT_R ? fsz.cx / 6 : 0), y + fascent - h.font.GetAscent(), h.chr, (cjk + 1) * fsz.cx, h.font, h.ink); } q++; gp += 1 + cjk; if(x > sz.cx) break; } } } if(pass == 0) { int gpx = gp * fsz.cx - scx; rw.DrawRect(gpx, y, sz.cx - gpx, fsz.cy, !rectsel && sell <= len && len < selh ? color[PAPER_SELECTED] : (do_highlight ? hl.Top() : ih).paper); if(bordercolumn > 0 && bordercolumn >= gp) rw.DrawRect((bordercolumn - sc.x) * fsz.cx, y, 1, fsz.cy, bordercolor); } if(pass == 0 && (showlines || warn_whitespace)) { int yy = 2 * fsz.cy / 3; int x = (lgp >= 0 ? lgp : gp) * fsz.cx - scx; rw.DrawRect(x, y + yy, fsz.cx / 2, 1, showcolor); if(fsz.cx > 2) rw.DrawRect(x + 1, y + yy - 1, 1, 3, showcolor); if(fsz.cx > 5) rw.DrawRect(x + 2, y + yy - 2, 1, 5, showcolor); rw.DrawRect(x + fsz.cx / 2, y + yy / 2, 1, yy - yy / 2, showcolor); } if(pass == 0 && !IsNull(hline) && sell == selh && i == cursorline) { rw.DrawRect(0, y, sz.cx, 1, hline); rw.DrawRect(0, y + fsz.cy - 1, sz.cx, 1, hline); } if(pass == 0 && rectsel && rect.left == rect.right && i >= rect.top && i <= rect.bottom) rw.DrawRect(rect.left * fsz.cx - scx, y, 2, fsz.cy, Blend(color[PAPER_SELECTED], color[PAPER_NORMAL])); } } y += fsz.cy; sell -= len + 1; selh -= len + 1; pos += len + 1; } w.DrawRect(0, y, sz.cx, sz.cy - y, color[IsReadOnly() && showreadonly || !IsShowEnabled() ? PAPER_READONLY : PAPER_NORMAL]); DrawTiles(w, DropCaret(), CtrlImg::checkers()); }