mirror of
https://github.com/elliotnunn/supermario.git
synced 2024-06-02 00:41:27 +00:00
ba88ed9a75
got through backlight.c fine hacked up backlight.a (lots of tables) came unstuck with backlightcpu.c, especially InitTimControls It's a fairly boring bit of code. Good luck!
545 lines
16 KiB
Diff
545 lines
16 KiB
Diff
From: Horst Beepmanh <>
|
|
Subject: Backlight hacking
|
|
|
|
---
|
|
diff --git a/Drivers/Backlight/Backlight.make b/Drivers/Backlight/Backlight.make
|
|
--- a/Drivers/Backlight/Backlight.make
|
|
+++ b/Drivers/Backlight/Backlight.make
|
|
@@ -20,7 +20,11 @@
|
|
# Backlight driver
|
|
|
|
BL_DRVR_OBJ = "{ObjDir}backlight.c.o" ∂
|
|
- "{ObjDir}backlight.a.o"
|
|
+ "{ObjDir}backlight.a.o" ∂
|
|
+ "{ObjDir}backlightcpu.c.o" ∂
|
|
+ "{ObjDir}PWM.c.o" ∂
|
|
+ "{ObjDir}register.c.o" ∂
|
|
+ "{IfObjDir}interface.o"
|
|
|
|
"{ObjDir}backlight.a.o" ƒ "{AIncludes}SysEqu.a" ∂
|
|
"{AIncludes}SysErr.a" ∂
|
|
@@ -47,7 +51,7 @@ BL_DRVR_OBJ = "{ObjDir}backlight.c.o" ∂
|
|
|
|
|
|
"{RsrcDir}Backlight.DRVW" ƒ {BL_DRVR_OBJ}
|
|
- Link -o {Targ} -rt "DRVW"=-16511 -sg backlight ∂
|
|
+ Link -map -o {Targ} -rt "DRVW"=-16511 -sg backlight ∂
|
|
"{Libraries}DRVRRuntime.o" ∂
|
|
{BL_DRVR_OBJ}
|
|
|
|
diff --git a/Drivers/Backlight/Register.c b/Drivers/Backlight/Register.c
|
|
--- a/Drivers/Backlight/Register.c
|
|
+++ b/Drivers/Backlight/Register.c
|
|
@@ -516,3 +516,9 @@ setNewKeys(int keycombo)
|
|
|
|
};
|
|
|
|
+int abs(int lala)
|
|
+{
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+
|
|
diff --git a/Drivers/Backlight/backlight.a b/Drivers/Backlight/backlight.a
|
|
--- a/Drivers/Backlight/backlight.a
|
|
+++ b/Drivers/Backlight/backlight.a
|
|
@@ -92,6 +92,44 @@ VBLEntry PROC EXPORT
|
|
rts
|
|
|
|
|
|
+PlayWithKeys
|
|
+ movem.l d1/a1,-(sp)
|
|
+ lea @zerotable,a1
|
|
+ move.l a0,d1
|
|
+
|
|
+ tst.b 5(a1)
|
|
+ beq.s @dest_sf
|
|
+
|
|
+ cmp.w #3,d1 ; control | shift
|
|
+ beq.s @dest_other
|
|
+
|
|
+ tst.b 4(a1)
|
|
+ beq.s @dest_sf
|
|
+
|
|
+ cmp.w #5,d1 ; control | option
|
|
+ bne.s @dest_sf
|
|
+
|
|
+ bra.s @return
|
|
+
|
|
+@dest_other
|
|
+ move.w KeyMap+6,d1 ; get meta-key states
|
|
+ rol.w #1,d1
|
|
+ cmp.b 5(a1),d1
|
|
+ bne.s @dest_sf
|
|
+ st 4(a1)
|
|
+ bra.s @return
|
|
+@dest_sf
|
|
+ sf 4(a1)
|
|
+ move.l (a1),a1
|
|
+ jsr (a1)
|
|
+
|
|
+@return
|
|
+ movem.l (sp)+,d1/a1
|
|
+ rts
|
|
+
|
|
+@zerotable
|
|
+ dc.l 0, 0
|
|
+
|
|
;-----------------------------------------------------------------------------------
|
|
;
|
|
;
|
|
@@ -116,17 +154,10 @@ GetBkltPrimInfo proc export
|
|
rts
|
|
|
|
|
|
-
|
|
-
|
|
- END
|
|
-
|
|
;-----------------------------------------------------------------------------------
|
|
;
|
|
PortableTable7V PROC EXPORT
|
|
- dc.w 0 ; minimum value <H7>
|
|
- dc.w @end - @start ; <H7>
|
|
-
|
|
-@start dc.b 0 ; 0 <H7>
|
|
+ dc.b 0 ; 0
|
|
dc.b 1 ; 1
|
|
dc.b 2 ; 2
|
|
dc.b 3 ; 3
|
|
@@ -156,16 +187,15 @@ PortableTable7V PROC EXPORT
|
|
dc.b 36 ; 27
|
|
dc.b 40 ; 28
|
|
dc.b 45 ; 29
|
|
-@end dc.b 50 ; 30 <H7>
|
|
+ dc.b 50 ; 30
|
|
|
|
|
|
;--------------------------------------------------------------------------------------------------------------
|
|
;
|
|
-PortableTbl5V PROC EXPORT
|
|
- dc.w 0 ; minimum value <H7>
|
|
- dc.w @end - @start ; <H7>
|
|
-@start
|
|
- dc.b 0 ; 0 <H7>
|
|
+;PortableTbl5V PROC EXPORT ; very very temporary move
|
|
+ export PortableTbl5V
|
|
+PortableTbl5V
|
|
+ dc.b 0 ; 0
|
|
dc.b 2 ; 1
|
|
dc.b 5 ; 2
|
|
dc.b 7 ; 3
|
|
@@ -195,125 +225,92 @@ PortableTbl5V PROC EXPORT
|
|
dc.b 66 ; 27
|
|
dc.b 70 ; 28
|
|
dc.b 75 ; 29
|
|
-@end dc.b 80 ; 30 <H7>
|
|
+ dc.b 80 ; 30
|
|
+
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
+ nop
|
|
|
|
|
|
;--------------------------------------------------------------------------------------------------------------
|
|
;
|
|
-asahiTbl PROC EXPORT
|
|
- dc.w 0 ; minimum value <H7>
|
|
- dc.w @end - @start ; <H7>
|
|
-
|
|
-@start dc.b 0 ; 0 <H7>
|
|
- dc.b 1 ; 1
|
|
- dc.b 2 ; 2
|
|
- dc.b 3 ; 3
|
|
- dc.b 4 ; 4
|
|
- dc.b 5 ; 5
|
|
- dc.b 6 ; 6
|
|
- dc.b 7 ; 7
|
|
- dc.b 8 ; 8
|
|
- dc.b 9 ; 9
|
|
- dc.b 10 ; 10
|
|
- dc.b 11 ; 11
|
|
- dc.b 12 ; 12
|
|
- dc.b 13 ; 13
|
|
- dc.b 14 ; 14
|
|
- dc.b 15 ; 15
|
|
- dc.b 16 ; 16
|
|
- dc.b 17 ; 17
|
|
- dc.b 18 ; 18
|
|
- dc.b 19 ; 19
|
|
- dc.b 20 ; 20
|
|
- dc.b 21 ; 21
|
|
- dc.b 22 ; 22
|
|
- dc.b 23 ; 23
|
|
- dc.b 24 ; 24
|
|
- dc.b 25 ; 25
|
|
- dc.b 26 ; 26
|
|
- dc.b 27 ; 27
|
|
- dc.b 28 ; 28
|
|
- dc.b 29 ; 29
|
|
- dc.b 30 ; 30
|
|
-@end dc.b 31 ; 31 <H7>
|
|
+;asahiTbl PROC EXPORT
|
|
+ export asahiTbl
|
|
+asahiTbl
|
|
|
|
;--------------------------------------------------------------------------------------------------------------
|
|
;
|
|
-timTbl PROC EXPORT
|
|
- dc.w 0 ; minimum value <H7>
|
|
- dc.w @end - @start ; <H7>
|
|
-
|
|
-@start dc.b 31 ; 0 <H7>
|
|
- dc.b 30 ; 1
|
|
- dc.b 29 ; 2
|
|
- dc.b 28 ; 3
|
|
- dc.b 27 ; 4
|
|
- dc.b 26 ; 5
|
|
- dc.b 25 ; 6
|
|
- dc.b 24 ; 7
|
|
- dc.b 23 ; 8
|
|
- dc.b 22 ; 9
|
|
- dc.b 21 ; 10
|
|
- dc.b 20 ; 11
|
|
- dc.b 19 ; 12
|
|
- dc.b 18 ; 13
|
|
- dc.b 17 ; 14
|
|
- dc.b 16 ; 15
|
|
- dc.b 15 ; 16
|
|
- dc.b 14 ; 17
|
|
- dc.b 13 ; 18
|
|
- dc.b 12 ; 19
|
|
- dc.b 11 ; 20
|
|
- dc.b 10 ; 21
|
|
- dc.b 9 ; 22
|
|
- dc.b 8 ; 23
|
|
- dc.b 7 ; 24
|
|
- dc.b 6 ; 25
|
|
- dc.b 5 ; 26
|
|
- dc.b 4 ; 27
|
|
- dc.b 3 ; 28
|
|
- dc.b 2 ; 29
|
|
- dc.b 1 ; 30
|
|
-@end dc.b 0 ; 31 <H7>
|
|
+;timTbl PROC EXPORT
|
|
+ export timTbl
|
|
+timTbl
|
|
|
|
;--------------------------------------------------------------------------------------------------------------
|
|
;
|
|
-timTblLow PROC EXPORT
|
|
- dc.w 0 ; minimum value <H7>
|
|
- dc.w @end - @start ; <H7>
|
|
+;timTblLow PROC EXPORT
|
|
+ export timTblLow
|
|
+timTblLow
|
|
|
|
-@start dc.b 31 ; 0 <H7>
|
|
- dc.b 30 ; 1
|
|
- dc.b 30 ; 2
|
|
- dc.b 29 ; 3
|
|
- dc.b 28 ; 4
|
|
- dc.b 28 ; 5
|
|
- dc.b 27 ; 6
|
|
- dc.b 26 ; 7
|
|
- dc.b 25 ; 8
|
|
- dc.b 25 ; 9
|
|
- dc.b 24 ; 10
|
|
- dc.b 23 ; 11
|
|
- dc.b 22 ; 12
|
|
- dc.b 22 ; 13
|
|
- dc.b 21 ; 14
|
|
- dc.b 20 ; 15
|
|
- dc.b 20 ; 16
|
|
- dc.b 19 ; 17
|
|
- dc.b 18 ; 18
|
|
- dc.b 17 ; 19
|
|
- dc.b 17 ; 20
|
|
- dc.b 16 ; 21
|
|
- dc.b 15 ; 22
|
|
- dc.b 14 ; 23
|
|
- dc.b 14 ; 24
|
|
- dc.b 13 ; 25
|
|
- dc.b 12 ; 26
|
|
- dc.b 11 ; 27
|
|
- dc.b 11 ; 28
|
|
- dc.b 11 ; 29
|
|
- dc.b 10 ; 30
|
|
-@end dc.b 10 ; 31 <H7>
|
|
+
|
|
|
|
;--------------------------------------------------------------------------------------------------------------
|
|
;
|
|
@@ -335,7 +332,7 @@ PWMMaxTbl PROC EXPORT
|
|
|
|
;--------------------------------------------------------------------------------------------------------------
|
|
;
|
|
-PotInputRangeShiftTblPWM PROC EXPORT
|
|
+;PotInputRangeShiftTblPWM PROC EXPORT
|
|
dc.w 0 ; 0
|
|
dc.w 1 ; 1
|
|
dc.w 1 ; 2
|
|
diff --git a/Drivers/Backlight/backlight.c b/Drivers/Backlight/backlight.c
|
|
--- a/Drivers/Backlight/backlight.c
|
|
+++ b/Drivers/Backlight/backlight.c
|
|
@@ -9,20 +9,6 @@
|
|
|
|
Change History (most recent first):
|
|
|
|
- <SM6> 12/13/93 PN Roll in KAOs and Horror changes to support Malcom and AJ
|
|
- machines
|
|
- <SM5> 9/2/93 SKH Update from Horror.
|
|
- <SM4> 2/11/93 CSS Update from Horror. Comments follow <H5-H2>:
|
|
- <H5> 11/9/92 ag Corrected compare statement. The compiler generated a long
|
|
- compare, so we must type cast the value to avoid the mismatch in
|
|
- types.
|
|
- <H4> 6/30/92 ag Use cpu info tables for configuring cpu dependent information.
|
|
- <H3> 4/24/92 ag added support for error returns on hardware initialization.
|
|
- this will return an open error on unknown hardware.
|
|
- <H2> 8/5/91 SWC Make InitPWMControls the default init choice in DRVROpen so that
|
|
- proc vectors are always initialized.
|
|
- <12> 3/30/92 JSM Rolled this file into SuperMario project.
|
|
- <11> 3/24/92 JSM Nuke boxFlag codenames.
|
|
<10> 3/23/92 JSM OSEvents.h is obsolete, use Events.h.
|
|
<9> 10/28/91 SAM Rolled in Regatta file.
|
|
|
|
@@ -172,13 +158,8 @@ pascal OSErr DRVROpen(CntrlParam *ctlPB,DCtlPtr dCtl) /* 'open' entry point *
|
|
#pragma unused (ctlPB)
|
|
register driverGlobalPtr globalPtr; /* pointer to globals */
|
|
PmgrGlobals **pmgrglobalhdl; /* handle to power manager globals */
|
|
- OSErr error;
|
|
- cpuDependentInfoType *cpuinfo;
|
|
- OSErr (*openProc)();
|
|
+ char boxFlag;
|
|
|
|
- cpuinfo = GetBkltPrimInfo();
|
|
- if (!cpuinfo) return(openErr);
|
|
-
|
|
globalPtr = (driverGlobalPtr) NewPtrSysClear(sizeof(driverGlobaltypes));
|
|
if (!globalPtr) return(openErr); /* not enough memory, return error */
|
|
|
|
@@ -187,46 +168,23 @@ pascal OSErr DRVROpen(CntrlParam *ctlPB,DCtlPtr dCtl) /* 'open' entry point *
|
|
|
|
/* setup variables */
|
|
globalPtr->version = DRIVERVERSION; /* driver version number, in globals for easy patching */
|
|
-
|
|
- *((unsigned int *)(((int)&(globalPtr->version)) + sizeof(globalPtr->version))) = cpuinfo->bkltinfo->flags;
|
|
- globalPtr->lowThreshold = cpuinfo->bkltinfo->lowThreshold; /*low hysteresis threshold */
|
|
- globalPtr->hiThreshold = cpuinfo->bkltinfo->hiThreshold; /* high hysteresis threshold */
|
|
- globalPtr->userInputSampleRate = cpuinfo->bkltinfo->userInputSampleRate; /* sample every 160ms */
|
|
+ globalPtr->vbl_ok = 1;
|
|
|
|
globalPtr->lastLevel = (*pmgrglobalhdl)->LastLevel; /* get current power level */
|
|
// globalPtr->userRange = 0; /* allow full power level */
|
|
globalPtr->powerRange = Larger(globalPtr->lastLevel,globalPtr->userRange);
|
|
|
|
-/* initialize tables */
|
|
- globalPtr->maximumTable = (short *) (cpuinfo->bkltroutines->maxTable);
|
|
- globalPtr->settingTableLow = (setTableType *) (cpuinfo->bkltroutines->lowTable); /* <H8> */
|
|
- globalPtr->settingTableHigh = (setTableType *) (cpuinfo->bkltroutines->hiTable); /* <H8> */
|
|
- globalPtr->settingTable = globalPtr->settingTableHigh;
|
|
-
|
|
-/* initialize vectors */
|
|
- globalPtr->setlevelproc = (intFunction) (cpuinfo->bkltroutines->setProc); /* proc to set level */
|
|
- globalPtr->userInputProc = (intFunction) (cpuinfo->bkltroutines->getProc); /* proc to read user input */
|
|
- openProc = (osFunction) (cpuinfo->bkltroutines->open); /* routine to close pwm hardware */
|
|
- globalPtr->closeProc = (intFunction) (cpuinfo->bkltroutines->close); /* routine to close pwm hardware */
|
|
- globalPtr->controlProc = (osFunction) (cpuinfo->bkltroutines->control); /* passed control routine */
|
|
- globalPtr->statusProc = (osFunction) (cpuinfo->bkltroutines->status); /* passed status routine */
|
|
- globalPtr->hardwareDependentPtr = (Ptr) (cpuinfo->bkltroutines->hwDependentVar);
|
|
- globalPtr->tableProc = (voidFunction) (cpuinfo->bkltroutines->tableProc);
|
|
-
|
|
-
|
|
-/* call custom initialization routine */
|
|
- if (openProc)
|
|
- {
|
|
- error = (*openProc)(globalPtr);
|
|
- if (error)
|
|
- {
|
|
- DisposPtr((Ptr) globalPtr); /* release memory */
|
|
- dCtl->dCtlStorage = NULL;
|
|
- return(error); /* clear out saved value for next open */
|
|
- };
|
|
- };
|
|
-
|
|
-
|
|
+ boxFlag = *(char *)0xCB3;
|
|
+ switch(boxFlag) /* boxFlag */
|
|
+ {
|
|
+ case 4: /* boxPortable */
|
|
+ InitRegControls(globalPtr);
|
|
+ break;
|
|
+ case 15: /* boxPowerBook170 (Tim) */
|
|
+ case 18: /* boxPowerBook100 (Asahi) */
|
|
+ default:
|
|
+ InitTimControls(globalPtr);
|
|
+ };
|
|
|
|
globalPtr->brightnessVbl.globals = (Ptr) globalPtr;
|
|
globalPtr->brightnessVbl.vblpb.qType = vType;
|
|
@@ -257,7 +215,6 @@ pascal OSErr DRVRClose(CntrlParam *ctlPB,DCtlPtr dCtl) /* 'open' entry point *
|
|
|
|
globalPtr = (driverGlobalPtr) dCtl->dCtlStorage; /* set context to my global data area */
|
|
|
|
- globalPtr->slewChange = false; /* always turn off slew during close <H6> */
|
|
VRemove((QElemPtr) &globalPtr->brightnessVbl.vblpb); /* remove vbl task */
|
|
if (globalPtr->closeProc != NULL) /* if hw close proc … */
|
|
(*globalPtr->closeProc)(globalPtr); /* … call close proc */
|
|
@@ -390,27 +347,10 @@ pascal OSErr DRVRStatus(CntrlParam *ctlPB,DCtlPtr dCtl) /* 'open' entry point
|
|
globalPtr->vbl_ok = false; /* disable vbl task */
|
|
switch(ctlPB->csCode)
|
|
{
|
|
- case kGetUserInput:
|
|
- ctlPB->csParam[0] = globalPtr->
|
|
- userInputProc( globalPtr ); /* Get the button inputs */
|
|
- break;
|
|
-
|
|
case KGetVersion:
|
|
ctlPB->csParam[0] = globalPtr->version; /* return current driver version */
|
|
break;
|
|
|
|
- case kGetScreenBrightness: /* <H4> return current saved brightness */
|
|
- ctlPB->csParam[0] = globalPtr->userBrightness;
|
|
- break;
|
|
-
|
|
- case kGetBrightnessRange: /* <H4> return range of brightness values */
|
|
- ctlPB->csParam[0] = globalPtr->settingTable->maximum;/* <H4> using new tables, return max setting */
|
|
- ctlPB->csParam[1] = globalPtr->settingTable->minimum;/* <H4> using new tables, return min setting */
|
|
- break;
|
|
- case kGetMaximum: /* <H4> */
|
|
- ctlPB->csParam[0] = globalPtr->maximumTable[globalPtr->powerRange];
|
|
- break;
|
|
-
|
|
default:
|
|
error = (*globalPtr->statusProc)(ctlPB,globalPtr);
|
|
};
|
|
@@ -526,7 +466,7 @@ PowerChange (driverGlobalPtr globalPtr, int currentPowerLevel)
|
|
{
|
|
if (!globalPtr->flyByWire && userInput) /* if only software controls and backlight on */
|
|
{
|
|
- userInput >>= 1; /* reduce power by 1/2 */
|
|
+ userInput = globalPtr->userBrightness >> 1; /* reduce power by 1/2 */
|
|
if (!userInput) userInput = 1; /* insure at least on */
|
|
};
|
|
};
|
|
@@ -540,6 +480,23 @@ PowerChange (driverGlobalPtr globalPtr, int currentPowerLevel)
|
|
***************************************************************************************************
|
|
*/
|
|
|
|
+int GetBacklightInfo(short mask, short shift)
|
|
+{
|
|
+ unsigned char buf;
|
|
+ ReadXPram(0x74, 1, &buf); /* PmgrPramRec.Brightness */
|
|
+ return (buf & mask) >> shift;
|
|
+}
|
|
+
|
|
+void SaveBacklightInfo(short new, short mask, short shift)
|
|
+{
|
|
+ const long ofs = 0x70;
|
|
+ unsigned char buf;
|
|
+ ReadXPram(ofs + 4, 1, &buf); /* PmgrPramRec.Brightness */
|
|
+ buf &= ~mask;
|
|
+ buf |= (new << shift) & mask;
|
|
+ WriteXPram(ofs + 4, 1, &buf);
|
|
+}
|
|
+
|
|
/*page
|
|
***************************************************************************************************
|
|
*
|
|
diff --git a/Drivers/Backlight/backlight.h b/Drivers/Backlight/backlight.h
|
|
--- a/Drivers/Backlight/backlight.h
|
|
+++ b/Drivers/Backlight/backlight.h
|
|
@@ -65,7 +65,7 @@
|
|
*
|
|
*/
|
|
#define DRIVERMAJORVERSION 0x0100
|
|
-#define DRIVERMINORVERSION 0x0001
|
|
+#define DRIVERMINORVERSION 0x0002
|
|
#define DRIVERVERSION (DRIVERMAJORVERSION + DRIVERMINORVERSION)
|
|
|
|
/* Control Calls */
|
|
@@ -203,8 +203,6 @@ typedef struct
|
|
short mousedownTicks; /* first notice of mouse down in tick count */
|
|
short keycodes; /* key combinations */
|
|
short lastatod; /* last raw a to d value */
|
|
-
|
|
- Ptr hardwareDependentPtr; /* private storage for hardware dependent code */
|
|
} driverGlobaltypes, *driverGlobalPtr;
|
|
|
|
typedef struct
|
|
diff --git a/Drivers/Backlight/backlightinput.c b/Drivers/Backlight/backlightinput.c
|
|
--- a/Drivers/Backlight/backlightinput.c
|
|
+++ b/Drivers/Backlight/backlightinput.c
|
|
@@ -123,7 +123,7 @@ int PotControl (driverGlobalPtr globalPtr)
|
|
|
|
unsigned int potvalue;
|
|
|
|
- potvalue = (* (intFunction)(globalPtr->hardwareDependentPtr))();
|
|
+ //potvalue = (* (intFunction)(globalPtr->hardwareDependentPtr))(); I, elliot, have removed this struct memb hardwareDependentPtr
|
|
|
|
if (abs(globalPtr->lastatod - potvalue) <= 5) /* was the change less than 100mv */
|
|
potvalue = globalPtr->lastatod; /* is less than, the use old value */
|
|
--
|
|
2.18.0
|
|
|