9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Tony Kaku <tonykaku@openmailbox.org>
To: 9front@9front.org
Subject: [PATCH] games/blit: render screen from top to bottom rather than around center
Date: Fri, 14 Apr 2017 16:08:16 +0200	[thread overview]
Message-ID: <eb307c89-d7b8-df7a-5808-e9aef6a578fe@openmailbox.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 383 bytes --]

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


[-- Attachment #2: blit.patch --]
[-- Type: text/x-patch, Size: 2165 bytes --]

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(;;){

                 reply	other threads:[~2017-04-14 14:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eb307c89-d7b8-df7a-5808-e9aef6a578fe@openmailbox.org \
    --to=tonykaku@openmailbox.org \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).