Sigrid Haflínudóttirfirst dirty version of the portd7ad0686 years agoHistory
1395 lines · 27.2 KB · C
RawDownload
/*	CONTROLM.h 	Copyright (C) 2007 Paul C. Pratt 	You can redistribute this file and/or modify it under the terms	of version 2 of the GNU General Public License as published by	the Free Software Foundation.  You should have received a copy	of the license along with this file; see the file COPYING. 	This file is distributed in the hope that it will be useful,	but WITHOUT ANY WARRANTY; without even the implied warranty of	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the	license for more details.*/ /*	CONTROL Mode*/ #ifdef CONTROLM_H#error "header already included"#else#define CONTROLM_H#endif enum {#if EnableDemoMsg	SpclModeDemo,#endif#if EnableAltKeysMode	SpclModeAltKeyText,#endif#if UseActvCode	SpclModeActvCode,#endif	SpclModeNoRom,	SpclModeMessage,#if UseControlKeys	SpclModeControl,#endif 	kNumSpclModes}; LOCALVAR uimr SpecialModes = 0; LOCALVAR blnr NeedWholeScreenDraw = falseblnr; #define SpecialModeSet(i) SpecialModes |= (1 << (i))#define SpecialModeClr(i) SpecialModes &= ~ (1 << (i))#define SpecialModeTst(i) (0 != (SpecialModes & (1 << (i)))) #define MacMsgDisplayed SpecialModeTst(SpclModeMessage) LOCALVAR ui3p CntrlDisplayBuff = nullpr; LOCALPROC DrawCell(unsigned int h, unsigned int v, int x){#if 1	/* safety check */	if ((h < ((long)vMacScreenWidth / 8 - 2))		&& (v < (vMacScreenHeight / 16 - 1)))#endif	{		int i;		ui3p p0 = ((ui3p)CellData) + 16 * x; #if 0 != vMacScreenDepth		if (UseColorMode) {			ui3p p = CntrlDisplayBuff				+ ((h + 1) << vMacScreenDepth)				+ (v * 16 + 11) * vMacScreenByteWidth; 			for (i = 16; --i >= 0; ) {#if 1 == vMacScreenDepth				int k;				ui3b t0 = *p0;				ui3p p2 = p;				for (k = 2; --k >= 0; ) {					*p2++ = (((t0) & 0x80) ? 0xC0 : 0x00)						| (((t0) & 0x40) ? 0x30 : 0x00)						| (((t0) & 0x20) ? 0x0C : 0x00)						| (((t0) & 0x10) ? 0x03 : 0x00);						/* black RRGGBBAA, white RRGGBBAA */					t0 <<= 4;				}#elif 2 == vMacScreenDepth				int k;				ui3b t0 = *p0;				ui3p p2 = p;				for (k = 4; --k >= 0; ) {					*p2++ = (((t0) & 0x40) ? 0x0F : 0x00)						| (((t0) & 0x80) ? 0xF0 : 0x00);						/* black RRGGBBAA, white RRGGBBAA */					t0 <<= 2;				}#elif 3 == vMacScreenDepth				int k;				ui3b t0 = *p0;				ui3p p2 = p;				for (k = 8; --k >= 0; ) {					*p2++ = ((t0 >> k) & 0x01) ? 0xFF : 0x00;						/* black RRGGBBAA, white RRGGBBAA */				}#elif 4 == vMacScreenDepth				int k;				ui4r v;				ui3b t0 = *p0;				ui3p p2 = p;				for (k = 8; --k >= 0; ) {					v = ((t0 >> k) & 0x01) ? 0x0000 : 0x7FFF;						/* black RRGGBBAA, white RRGGBBAA */					/* *((ui4b *)p2)++ = v; need big endian, so : */					*p2++ = v >> 8;					*p2++ = v;				}#elif 5 == vMacScreenDepth				int k;				ui5r v;				ui3b t0 = *p0;				ui3p p2 = p;				for (k = 8; --k >= 0; ) {					v = ((t0 >> k) & 0x01) ? 0x00000000 : 0x00FFFFFF;						/* black RRGGBBAA, white RRGGBBAA */					/* *((ui5b *)p2)++ = v; need big endian, so : */					*p2++ = v >> 24;					*p2++ = v >> 16;					*p2++ = v >> 8;					*p2++ = v;				}#endif				p += vMacScreenByteWidth;				p0 ++;			}		} else#endif		{			ui3p p = CntrlDisplayBuff + (h + 1)				+ (v * 16 + 11) * vMacScreenMonoByteWidth; 			for (i = 16; --i >= 0; ) {				*p = *p0;				p += vMacScreenMonoByteWidth;				p0 ++;			}		}	}} #define ControlBoxh0 0#define ControlBoxw 62#define ControlBoxv0 0 #define hLimit (ControlBoxh0 + ControlBoxw - 1)#define hStart (ControlBoxh0 + 1)  LOCALVAR int CurCellh0;LOCALVAR int CurCellv0; LOCALPROC DrawCellsBeginLine(void){	DrawCell(ControlBoxh0, CurCellv0, kCellMiddleLeft);	CurCellh0 = hStart;} LOCALPROC DrawCellsEndLine(void){	int i; 	for (i = CurCellh0; i < hLimit; ++i) {		DrawCell(i, CurCellv0, kCellSpace);	}	DrawCell(hLimit, CurCellv0, kCellMiddleRight);	CurCellv0++;} LOCALPROC DrawCellsBottomLine(void){	int i; 	DrawCell(ControlBoxh0 + 0, CurCellv0, kCellLowerLeft);	for (i = hStart; i < hLimit; ++i) {		DrawCell(i, CurCellv0, kCellLowerMiddle);	}	DrawCell(hLimit, CurCellv0, kCellLowerRight);} LOCALPROC DrawCellAdvance(int x){	DrawCell(CurCellh0, CurCellv0, x);	CurCellh0++;} LOCALPROC DrawCellsBlankLine(void){	DrawCellsBeginLine();	DrawCellsEndLine();} LOCALPROC DrawCellsFromStr(char *s){	ui3b ps[ClStrMaxLength];	ui3b cs;	int L;	int i;	int j;	int w; 	ClStrFromSubstCStr(&L, ps, s); 	i = 0; 	while (i < L) {		cs = ps[i];		i++;		if (CurCellh0 < hLimit) {			DrawCellAdvance(cs);		} else {			/* line is too wide, wrap */			if (kCellSpace != cs) {				--i; /* back up one char, at least */ 				/* now try backing up to beginning of word */				j = i;				w = CurCellh0 - hStart; 				while ((w > 0) && (j > 0)					&& (ps[j - 1] != kCellSpace))				{					--j;					--w;				}				if (w != 0) {					i = j;					CurCellh0 = hStart + w;				}				/*					else if w == 0, then have backed up to					beginning of line, so just let the word					be split.				*/			}			/*				else if cs == kCellSpace, just lose the space.			*/			DrawCellsEndLine();				/*					draw white space over the part of					the word that have already drawn				*/			DrawCellsBeginLine();		}	}} LOCALPROC DrawCellsOneLineStr(char *s){	DrawCellsBeginLine();	DrawCellsFromStr(s);	DrawCellsEndLine();} LOCALPROC DrawCellsKeyCommand(char *k, char *s){	DrawCellsBeginLine();	DrawCellsFromStr(" ");	DrawCellsFromStr(k);	DrawCellsFromStr(" - ");	DrawCellsFromStr(s);	DrawCellsEndLine();} typedef void (*SpclModeBody) (void); LOCALPROC DrawSpclMode0(char *Title, SpclModeBody Body){	int i;	int k; 	CurCellv0 = ControlBoxv0 + 0;	DrawCell(ControlBoxh0 + 0, CurCellv0, kCellUpperLeft);	k = kCellIcon00;	for (i = hStart; i < hStart + 4; ++i) {		DrawCell(i, CurCellv0, k);		k++;	}	for (i = hStart + 4; i < hLimit; ++i) {		DrawCell(i, CurCellv0, kCellUpperMiddle);	}	DrawCell(hLimit, CurCellv0, kCellUpperRight);	++CurCellv0; 	DrawCellsBeginLine();	for (i = hStart; i < hStart + 4; ++i) {		DrawCellAdvance(k);		k++;	}	DrawCellAdvance(kCellSpace);	DrawCellsFromStr(Title);	DrawCellsEndLine(); 	DrawCellsBeginLine();	for (i = hStart; i < hStart + 4; ++i) {		DrawCellAdvance(k);		k++;	}	for (i = hStart + 4; i < hLimit; ++i) {		DrawCellAdvance(kCellGraySep);	}	DrawCellsEndLine(); 	if (nullpr != Body) {		Body();	} 	DrawCellsBottomLine();} #if EnableAltKeysMode#include "ALTKEYSM.h"#else#define Keyboard_UpdateKeyMap1 Keyboard_UpdateKeyMap#define DisconnectKeyCodes1 DisconnectKeyCodes#endif #if WantAbnormalReports || UseActvFileLOCALPROC ClStrAppendHexNib(int *L0, ui3b *r, ui3r v){	if (v < 10) {		ClStrAppendChar(L0, r, kCellDigit0 + v);	} else {		ClStrAppendChar(L0, r, kCellUpA + (v - 10));	}}#endif #if WantAbnormalReports || UseActvFileLOCALPROC ClStrAppendHexByte(int *L0, ui3b *r, ui3r v){	ClStrAppendHexNib(L0, r, (v >> 4) & 0x0F);	ClStrAppendHexNib(L0, r, v & 0x0F);}#endif #if WantAbnormalReports || UseActvFileLOCALPROC ClStrAppendHexWord(int *L0, ui3b *r, ui4r v){	ClStrAppendHexByte(L0, r, (v >> 8) & 0xFF);	ClStrAppendHexByte(L0, r, v & 0xFF);}#endif #if WantAbnormalReportsLOCALPROC DrawCellsOneLineHexWord(ui4r v){	ui3b ps[ClStrMaxLength];	int L = 0;	int i; 	ClStrAppendHexWord(&L, ps, v); 	DrawCellsBeginLine();	for (i = 0; i < L; ++i) {		DrawCellAdvance(ps[i]);	}	DrawCellsEndLine();}#endif LOCALPROC DrawCellsMessageModeBody(void){	DrawCellsOneLineStr(SavedBriefMsg);	DrawCellsBlankLine();	DrawCellsOneLineStr(SavedLongMsg);#if WantAbnormalReports	if (0 != SavedIDMsg) {		DrawCellsBlankLine();		DrawCellsOneLineHexWord(SavedIDMsg);	}#endif} LOCALPROC DrawMessageMode(void){	DrawSpclMode0(kStrModeMessage, DrawCellsMessageModeBody);} LOCALPROC MacMsgDisplayOff(void){	SpecialModeClr(SpclModeMessage);	SavedBriefMsg = nullpr;#if WantAbnormalReports	SavedIDMsg = 0;#endif	NeedWholeScreenDraw = trueblnr;} LOCALPROC MacMsgDisplayOn(void){	NeedWholeScreenDraw = trueblnr;	DisconnectKeyCodes1(kKeepMaskControl | kKeepMaskCapsLock);		/* command */	SpecialModeSet(SpclModeMessage);} LOCALPROC DoMessageModeKey(ui3r key){	if (MKC_C == key) {		MacMsgDisplayOff();	}} LOCALPROC MacMsgOverride(char *briefMsg, char *longMsg){	if (MacMsgDisplayed) {		MacMsgDisplayOff();	}	MacMsg(briefMsg, longMsg, falseblnr);} #if NeedDoMoreCommandsMsgLOCALPROC DoMoreCommandsMsg(void){	MacMsgOverride(kStrMoreCommandsTitle,		kStrMoreCommandsMessage);}#endif #if NeedDoAboutMsgLOCALPROC DoAboutMsg(void){	MacMsgOverride(kStrAboutTitle,		kStrAboutMessage);}#endif LOCALPROC NoRomMsgDisplayOff(void){	SpecialModeClr(SpclModeNoRom);	NeedWholeScreenDraw = trueblnr;} LOCALPROC NoRomMsgDisplayOn(void){	NeedWholeScreenDraw = trueblnr;	SpecialModeSet(SpclModeNoRom);} LOCALPROC DrawCellsNoRomModeBody(void){	DrawCellsOneLineStr(kStrNoROMMessage);} LOCALPROC DrawNoRomMode(void){	DrawSpclMode0(kStrNoROMTitle, DrawCellsNoRomModeBody);} #if UseControlKeys LOCALVAR blnr LastControlKey = falseblnr;LOCALVAR int CurControlMode = 0;LOCALVAR int ControlMessage = 0; enum {	kCntrlModeOff,	kCntrlModeBase,#if WantEnblCtrlRst	kCntrlModeConfirmReset,#endif#if WantEnblCtrlInt	kCntrlModeConfirmInterrupt,#endif	kCntrlModeConfirmQuit,	kCntrlModeSpeedControl, 	kNumCntrlModes}; enum {	kCntrlMsgBaseStart,#if EnableMagnify	kCntrlMsgMagnify,#endif#if VarFullScreen	kCntrlMsgFullScreen,#endif#if WantEnblCtrlRst	kCntrlMsgConfirmResetStart,	kCntrlMsgHaveReset,	kCntrlMsgResetCancelled,#endif#if WantEnblCtrlInt	kCntrlMsgConfirmInterruptStart,	kCntrlMsgHaveInterrupted,	kCntrlMsgInterruptCancelled,#endif	kCntrlMsgConfirmQuitStart,

Lines 1–500 of 1395.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t