From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.openmailbox.org ([5.79.108.160]) by ur; Fri Apr 14 10:06:11 EDT 2017 Received: by mail.openmailbox.org (Postfix, from userid 20002) id 6DD1B515542; Fri, 14 Apr 2017 16:06:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=openmailbox.org; s=openmailbox; t=1492178767; bh=KYH3/JvXf8tR3OKPP/9vmqyA564Uz3JDNt5uZUHY9is=; h=To:From:Subject:Date:From; b=ojUgujUcTgjONJ16A5L3bLlQKIFGZRjsACHGsxazMO0kMnzi0XolrDvaZZAyn2IND yZ24xwghO1HeSXp2NP0gH/EaipTdUSecyBSgUTNGzy7ll2jlQenNr611wHwFTBwM6g HTNVf0WFN8BZ8sz92nL+dbARDwskh3CxRcsQ0BQk= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ZDZR002 X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=NO_RECEIVED,NO_RELAYS, T_DKIM_INVALID autolearn=disabled version=3.4.0 To: 9front@9front.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=openmailbox.org; s=openmailbox; t=1492178767; bh=KYH3/JvXf8tR3OKPP/9vmqyA564Uz3JDNt5uZUHY9is=; h=To:From:Subject:Date:From; b=ojUgujUcTgjONJ16A5L3bLlQKIFGZRjsACHGsxazMO0kMnzi0XolrDvaZZAyn2IND yZ24xwghO1HeSXp2NP0gH/EaipTdUSecyBSgUTNGzy7ll2jlQenNr611wHwFTBwM6g HTNVf0WFN8BZ8sz92nL+dbARDwskh3CxRcsQ0BQk= From: Tony Kaku Subject: [PATCH] games/blit: render screen from top to bottom rather than around center Message-ID: Date: Fri, 14 Apr 2017 16:08:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------F5A5DE4329C8E86FF514DEF3" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: managed JSON over AJAX singleton table This is a multi-part message in MIME format. --------------F5A5DE4329C8E86FF514DEF3 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit It makes more sense to favor showing the top of the screen than the middle when the enclosing window's dimensions are smaller than 800x1024. The cursors' alignment is still kinda wonky, but you can make them align by moving the host cursor outside the window and moving it back in through the top left corner. Also added -m flag for easier keeping track of cursor alignment. tkk --------------F5A5DE4329C8E86FF514DEF3 Content-Type: text/x-patch; name="blit.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="blit.patch" diff -r f1b3bbf7c96b sys/src/games/blit/blit.c --- a/sys/src/games/blit/blit.c Tue Apr 11 02:26:39 2017 +0200 +++ b/sys/src/games/blit/blit.c Fri Apr 14 15:57:12 2017 +0200 @@ -10,7 +10,6 @@ int baud = 40000; int scale = 1; -Rectangle picr; Image *tmp, *bg; Channel *keych, *uartrxch, *uarttxch; Mousectl *mc; @@ -26,10 +25,6 @@ static void screeninit(void) { - Point p; - - p = divpt(addpt(screen->r.min, screen->r.max), 2); - picr = (Rectangle){subpt(p, Pt(scale * SX/2, scale * SY/2)), addpt(p, Pt(scale * SX/2, scale * SY/2))}; if(tmp != nil) freeimage(tmp); tmp = allocimage(display, Rect(0, 0, scale * SX, scale > 1 ? 1 : scale * SY), CHAN1(CMap, 1), scale > 1, 0); if(bg != nil) freeimage(bg); @@ -56,9 +51,9 @@ screeninit(); } while(nbrecv(mc->c, &m) > 0){ - if(ptinrect(m.xy, picr)){ - mousex = picr.max.x - m.xy.x - 1; - mousey = picr.max.y - m.xy.y - 1; + if(ptinrect(m.xy, screen->r)){ + mousex = screen->r.max.x - m.xy.x - 1; + mousey = screen->r.max.y - m.xy.y - 1; } n = m.buttons >> 2 & 1 | m.buttons & 2 | m.buttons << 2 & 4; if(n != mousebut){ @@ -88,10 +83,10 @@ loadimage(tmp, r, pic+o, Dy(r)*(SX/8)); if(realcolors){ - draw(screen, rectaddpt(r, picr.min), colfg, nil, r.min); - draw(screen, rectaddpt(r, picr.min), colbg, tmp, r.min); + draw(screen, rectaddpt(r, screen->r.min), colfg, nil, r.min); + draw(screen, rectaddpt(r, screen->r.min), colbg, tmp, r.min); }else - draw(screen, rectaddpt(r, picr.min), tmp, nil, r.min); + draw(screen, rectaddpt(r, screen->r.min), tmp, nil, r.min); updated = Rect(SX, SY, 0, 0); flushimage(display, 1); } @@ -157,12 +152,13 @@ void threadmain(int argc, char **argv) { - int n; + int n, ms; static Cursor blank; char *telnet; char *p; extern int diag; + ms = 0; telnet = nil; ARGBEGIN{ case 'b': @@ -184,6 +180,9 @@ case 'd': diag++; break; + case 'm': + ms++; + break; default: usage(); }ARGEND; if(argc != 0) usage(); @@ -201,7 +200,8 @@ mc = initmouse(nil, screen); if(mc == nil) sysfatal("initmouse: %r"); - setcursor(mc, &blank); + if(ms == 0) + setcursor(mc, &blank); cpureset(); for(;;){ --------------F5A5DE4329C8E86FF514DEF3--