9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Tony Kaku <tonykaku@openmailbox.org>
To: tim.newsham@gmail.com
Cc: 9front@9front.org, tuhs@tuhs.org
Subject: Re: [9front] Fwd: [TUHS] 8th Edition Research Unix on SIMH
Date: Wed, 26 Apr 2017 21:52:33 +0200	[thread overview]
Message-ID: <497749ae-2a3b-6932-ba9c-288153b2129f@openmailbox.org> (raw)
In-Reply-To: <3AA1B338-5347-40BE-BB5E-C4BDC5B0021F@stanleylieber.com>

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

On 04/26/2017 05:25 AM, Stanley Lieber wrote:
>
>
>
> Begin forwarded message:
>
>> *From:* Tim Newsham <tim.newsham@gmail.com
>> <mailto:tim.newsham@gmail.com>>
>> *Date:* April 25, 2017 at 11:05:25 PM EDT
>> *To:* mjkerpan@kerpan.com <mailto:mjkerpan@kerpan.com>
>> *Cc:* The Eunuchs Hysterical Society <tuhs@tuhs.org
>> <mailto:tuhs@tuhs.org>>
>> *Subject:* *Re: [TUHS] 8th Edition Research Unix on SIMH*
>>
>> I got the 9front blit sources to build and run in plan9port.  There's
>> some serious graphics issue right now causing a lot of flicker and
>> sometimes causing the graphics to not appear at all..  Anyone here
>> good with plan9port graphics ports?
>>
>> https://github.com/timnewsham/blit
>>
>>

Tim,

I've already done my own port of the blit emulator to plan9port, but I
didn't publish it anywhere.

Although I see on your GitHub page that you've already solved the
flicker problem, I thought I'd share my own solution as well. The
attached patch was made with plain diff (I didn't put my port under
version control) against 9front prior to changeset 5896 and only
covers blit.c. It also changes the virtual screen drawing algorithm so
it always displays the top left corner, as opposed to centering on the
middle. This is handy on small resolution screens since apparently
rsc's devdraw doesn't allow resizing windows to larger dimensions than
the screen, and not displaying the top of the blit's screen causes the
blit's cursor to be offset from the host system's.

You can also use the added -m flag to supress hiding of the host
cursor to make sure they are aligned.

tkk


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

--- ../others/plan9front/sys/src/games/blit/blit.c	2017-04-26 21:26:05.918471287 +0200
+++ blit.c	2017-04-14 15:55:19.338245717 +0200
@@ -10,7 +10,6 @@
 
 int baud = 40000;
 int scale = 1;
-Rectangle picr;
 Image *tmp, *bg;
 Channel *keych, *uartrxch, *uarttxch;
 Mousectl *mc;
@@ -22,14 +21,11 @@ Rectangle updated;
 u32int colbgv, colfgv;
 Image *colbg, *colfg;
 int realcolors;
+Keyboardctl *keyboard;
 
 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);
@@ -50,15 +46,15 @@ redraw(void)
 	Mouse m;
 	Rectangle r;
 		
-	if(nbrecvul(mc->resizec) > 0){
+	if((long)nbrecvul(mc->resizec) > 0){
 		if(getwindow(display, Refnone) < 0)
 			sysfatal("resize failed: %r");
 		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,44 +84,41 @@ redraw(void)
 
 	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);
 }
 
 static uchar
 keymap[] = {
-	[Kup-KF] 0xf1,
-	[Kdown-KF] 0xf2,
-	[Kleft-KF] 0xf3,
-	[Kright-KF] 0xf4,
-	[1] 0xf6, /* PF1 */
-	[2] 0xf7, /* PF2 */
-	[3] 0xf8, /* PF3 */
-	[4] 0xf9, /* PF4 */
-	[12] 0xfe, /* SET-UP */
-	[Kpgdown-KF] 0xb0, /* SCROLL */
-	[Kins-KF] 0xe0, /* BREAK */
+	[Kup-KF] = 0xf1,
+//	[Kdown-KF] = 0xf2,
+	[0x80] = 0xf2,
+	[Kleft-KF] = 0xf3,
+	[Kright-KF] = 0xf4,
+	[1] = 0xf6, /* PF1 */
+	[2] = 0xf7, /* PF2 */
+	[3] = 0xf8, /* PF3 */
+	[4] = 0xf9, /* PF4 */
+	[12] = 0xfe, /* SET-UP */
+	[Kpgdown-KF] = 0xb0, /* SCROLL */
+	[Kins-KF] = 0xe0, /* BREAK */
 };
-
+/*
 static void
-keyproc(void *)
+keyproc(void *unused)
 {
-	int fd, cfd, ch, rc;
+	int fd, ch, rc;
 	static char buf[256];
 	char *p;
 	Rune r;
 
-	fd = open("/dev/cons", OREAD);
+	fd = open("/dev/tty", OREAD);
 	if(fd < 0)
 		sysfatal("open: %r");
-	cfd = open("/dev/consctl", OWRITE);
-	if(cfd < 0)
-		sysfatal("open: %r");
-	fprint(cfd, "rawon");
 	for(;;){
 		rc = read(fd, buf, sizeof(buf) - 1);
 		if(rc <= 0)
@@ -146,6 +139,29 @@ keyproc(void *)
 		}
 	}
 }
+*/
+
+static void
+keyproc(void *unused)
+{
+	int ch;
+	Rune r;
+	
+	for(;;){
+		recv(keyboard->c, &r);
+		if(r == Kend)
+			threadexitsall(nil);
+		ch = r;
+		if(ch == '\n') ch = '\r';
+		else if(ch >= KF){
+			if(ch >= KF + nelem(keymap)) continue;
+			ch = keymap[ch - KF];
+			if(ch == 0) continue;
+		}else if(ch >= 0x80) continue;
+		//fprint(2, "%s", ch);
+		send(keych, &ch);
+	}
+}
 
 void
 usage(void)
@@ -157,12 +173,13 @@ usage(void)
 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 +201,9 @@ threadmain(int argc, char **argv)
 	case 'd':
 		diag++;
 		break;
+	case 'm':
+		ms++;
+		break;
 	default: usage();
 	}ARGEND;
 	if(argc != 0) usage();
@@ -197,11 +217,13 @@ threadmain(int argc, char **argv)
 		sysfatal("initdraw: %r");
 	
 	screeninit();
+	keyboard = initkeyboard(nil);
 	proccreate(keyproc, nil, mainstacksize);
 	mc = initmouse(nil, screen);
 	if(mc == nil)
 		sysfatal("initmouse: %r");
-	setcursor(mc, &blank);
+	if(!ms)
+		setcursor(mc, &blank);
 
 	cpureset();
 	for(;;){

      parent reply	other threads:[~2017-04-26 19:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAGSRWbhr=Yn55-VESzEzeSEm2wmjJ_5FO_km+PM=5CRnpjPXfQ@mail.gmail.com>
2017-04-26  3:25 ` Stanley Lieber
2017-04-26  4:10   ` [9front] " Bruce Ellis
2017-04-26  4:22     ` Kurt H Maier
2017-04-26  4:41       ` Bruce Ellis
2017-04-26 19:52   ` Tony Kaku [this message]

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=497749ae-2a3b-6932-ba9c-288153b2129f@openmailbox.org \
    --to=tonykaku@openmailbox.org \
    --cc=9front@9front.org \
    --cc=tim.newsham@gmail.com \
    --cc=tuhs@tuhs.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).