83Plus:Basic:Tricks ExecAsm

From WikiTI
Revision as of 11:05, 7 January 2009 by FloppusMaximus (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


This is organized such that first comes the "name" of the routine, then the sequence of hexadecimal codes, and then (usually) comes the asm instructions that were used to get the sequence of hexadecimal codes, in case anyone wishes to attempt to edit anything in the routine. In order to use these, you can enter these as a string argument in Omnicalc's ExecAsm( function, or you can create a new program, put AsmPrgm (found in the Catalog) as the first instruction, type the hexadecimal code sequence, and then (VERY IMPORTANT) add C9 to the end of the hex code sequence. If you do this, you will have to do Asm(prgmYOURPRGM in order to run your program, replacing YOURPRGM with whatever you named the program in which you entered this sequence. You should also note that any routine ending with "BCALL _StoAns" will be saving something to the Ans variable.

FloppusMaximus wrote: Looks like the ExecAsm function *always* returns 1?! Probably the best thing to do in this case is change the StoAns to a StoX (EFBF4A → EFD14A) and read the result from X rather than Ans.If you really wanted to use Ans, you could also just reset the numOP1 flag yourself (FDCB0786).
The code to reset the numOP1 flag should be put at the end of the sequence when using Omnicalc, if you still wish to use Ans. These changes can be ignored if putting the hexcode sequences in a separate program.
Warning
You should ensure that you type in these hexcode sequences as ACCURATELY as possible as the alteration of a SINGLE character CAN and most likely WILL cause the calculator to CRASH. Use these at your own risk.



Screen

Shift

Shift screen right (no LCD update)
2140930E40060CB7CB1E2310FB0D20F5
To update the LCD, add EF6A48 at the end (before adding C9 if in a prgm)
 21 40 93 -  	ld hl,gbuf
 0E 40 -  -  	ld c,64
 -  -  -  -  loop:
 06 0C -  -  	ld b,12
 B7 -  -  -  	or a
 -  -  -  -  smalloop:
 CB 1E -  -  	rr (hl)
 23 -  -  -  	inc hl
 10 FB -  -  	djnz smalloop
 0D -  -  -  	dec c
 20 F5 -  -  	jr nz,loop
-Jim e
Shift screen left (no LCD update)
213F960E40060CB7CB162B10FB0D20F5
To update the LCD, add EF6A48 at the end (before adding C9 if in a prgm)
 21 3F 96 -  	ld hl,gbuf+767
 0E 40 -  -  	ld c,64
 -  -  -  -  loop2:
 06 0C -  -  	ld b,12
 B7 -  -  -  	or a
 -  -  -  -  smalloop2:
 CB 16 -  -  	rl (hl)
 2B -  -  -  	dec hl
 10 FB -  -  	djnz smalloop2
 0D -  -  -  	dec c
 20 F5 -  -  	jr nz,loop2
 -Jim e
Shift screen up one line (no LCD update)
214C9311409301F402EDB0EB010C00EF304C
To update the LCD, add EF6A48 at the end (before adding C9 if in a prgm)
ld hl,plotSScreen+12  ; 214C93
ld de,plotSScreen     ; 114093
ld bc,756             ; 01F402
ldir                  ; EDB0
ex de,hl              ; EB
ld bc,12              ; 010C00
BCALL _MemClear       ; EF304C
-FloppusMaximus
Shift screen down one line (no LCD update)
213396113F9601F402EDB823010C00EF304C
To update the LCD, add EF6A48 at the end (before adding C9 if in a prgm)
ld hl,plotSScreen+767-12  ; 213396
ld de,plotSScreen+767     ; 113F96
ld bc,756                 ; 01F402
lddr                      ; EDB8
inc hl                    ; 23
ld bc,12                  ; 010C00
BCALL _MemClear           ; EF304C
-FloppusMaximus

Contrast

Increase the Contrast
2147847EC604FE28D077C6D8CD0B00D310
ld hl,contrast ; 21478477C6D8CD0B00D310
ld a,(hl)      ; 7E
add a,4        ; C604 (or whatever)
cp 28h         ; FE28
ret nc         ; D0
ld (hl),a      ; 77
add a,D8h      ; C6D8
call 0bh       ; CD0B00
out (10h),a    ; D310
-FloppusMaximus
Decrease the Contrast
2147847ED604D877C6D8CD0B00D310
ld hl,contrast ; 214784
ld a,(hl)      ; 7E
sub 4          ; D604 (or whatever)
ret c          ; D8
ld (hl),a      ; 77
add a,D8h      ; C6D8
call 0bh       ; CD0B00
out (10h),a    ; D310
-FloppusMaximus
X → temporary contrast (0 <=X <= 63)
EFE04AEFEF4AC6C0CD0B00D310
BCALL _RclX    ; EFE04A
BCALL _ConvOP1 ; EFEF4A
add a,C0h      ; C6C0
call 0bh       ; CD0B00
out (10h),a    ; D310

Invert/Black/Clear

Black graph (no LCD update)
2140930100033EFFEF334C
To update the LCD, add EF6A48 at the end (before adding C9 if in a prgm)
 ld hl,plotsscreen ;214093
 ld bc,768         ;010003
 ld a,$FF          ;3EFF
 bcall(_memset)    ;EF334C
 -RobbieMc
Clear Graph (no LCD update)
EFD04B
To update the LCD, add EF6A48 at the end (before adding C9 if in a prgm)
B_CALL _GrBufClr ; EFD04B
Invert HomeScreen
FDCB05DEEF7945FDCB059E
set textInverse,(iy+textFlags)  ; FDCB05DE
B_CALL _RstrShadow              ; EF7945
res textInverse,(iy+textFlags)  ; FDCB059E 
-FloppusMaximus
Invert graph (no LCD update)
2140930100037E2F77230B78B120F7
To update the LCD, add EF6A48 at the end (before adding C9 if in a prgm)
 ld hl,plotsscreen ;214093
 ld bc,768         ;010003
 ld a,(hl)         ;7E
 cpl               ;2F
 ld (hl),a         ;77
 inc hl            ;23
 dec bc            ;0B
 ld a,b            ;78
 or c              ;B1
 jr nz,$-7         ;20F7
 -RobbieMc
Invert Screen (Any)
F33E20CD0B00D3103E80CD0B00D310060EC5063F2E7FCD0B00DB112C
CD0B00DB112FF57DCD0B00D311CD0B00DB11F1CD0B00D31110E5C110D8
Note: This should be one LONG sequence. The line-break is inserted for readability only.
     DI                               ;F3
     LD A, $20                        ;3E20
     CALL $B                          ;CD0B00
     OUT ($10), A                     ;D310
     LD A, $80                        ;3E80
     CALL $B                          ;CD0B00
     OUT ($10), A                     ;D310
     LD B, 14                         ;060E
loop:
     PUSH BC                          ;C5
     LD B, 63                         ;063F
     LD L, $7F                        ;2E7F
     CALL $B                          ;CD0B00
     IN A, ($11)     ;dummy read       DB11
loop1:
     INC L           ;row counter      2C
     CALL $B                          ;CD0B00
     IN A, ($11)                      ;DB11
     CPL                              ;2F
     PUSH AF                          ;F5
     LD A, L         ;reset the row    7D
     CALL $B                          ;CD0B00
     OUT ($11), A                     ;D311
     CALL $B                          ;CD0B00
     IN A, ($11)     ;dummy read...    DB11
     POP AF                           ;F1
     CALL $B                          ;CD0B00
     OUT ($11), A                     ;D311
     DJNZ loop1                       ;10E5
     POP BC                           ;C1
     DJNZ loop                        ;10D8
-Taricorp

Miscellaneous

Enabling Fast Circles
FDCB3CE6
set useFastCirc, (iy+plotFlag3) FD CB 3C E6
-Michael Cimino
Toggle the Screen On and Off
DB10CB6F20053E03D310C93E02D310
 in a,(10h)     ; DB10
 bit 5,a        ; CB6F
 jr nz,turnoff  ; 2005
 ld a,3         ; 3E03
 out (10h),a    ; D310
 ret            ; C9
turnoff:
 ld a,2         ; 3E02
 out (10h),a    ; D310
 -FloppusMaximus

System

Flags

Enable Alpha Lock
FDCB12E6FDCB12F6
set shiftAlpha,(iy+shiftFlags) ; FDCB12E6
set shiftALock,(iy+shiftFlags) ; FDCB12F6
-FloppusMaximus
Toggling Lowercase
21148A3E08AE77
ld hl,flags+appLwrCaseFlag ; 21148A
ld a,8                     ; 3E08
xor (hl)                   ; AE
ld (hl),a                  ; 77
-FloppusMaximus
Remove "Done"
res donePrgm,(iy+doneFlags) ; FDCB00AE
-FloppusMaximus
Toggle Inverse Text
21F5893E08AE77
ld hl,flags+textFlags
ld a,8
xor (hl)
ld (hl),a

Power

Automatic Power Down (APD)
210101224884FDCB08DEFB76
Theoretically, this should return to your program after execution.
ld hl,0101h                  ; 210101
ld (apdSubTimer),hl          ; 224884
set apdRunning,(iy+apdFlags) ; FDCB08DE
ei                           ; FB
halt                         ; 76
-FloppusMaximus
X → APD Timers
EFE04AEFEF4AEB214884732372
BCALL _RclX    ; EFE04A
BCALL _ConvOP1 ; EFEF4A
ex de,hl       ; EB
ld hl,apdsubTimer ;214884
ld (hl),e      ; 73
inc hl         ; 23
ld (hl),d      ; 72
-Saibot84
Turn Off the Calc
3E01D30376FDCB09A6
This should return to your program after execution.
ld a,1                        ; 3E01
out (3),a                     ; D303
halt                          ; 76
res onInterrupt,(iy+onFlags)  ; FDCB09A6
-FloppusMaximus
Powerdown
EF0850
This routine should (theoretically) not return to your program.
bcall(_PowerOff)

Properties

Battery state (0 = good, 1 = bad)
EFBF41EFB3502003EF9B41EFBF4A
  BCALL _OP1Set0      ; EFBF41
  BCALL _Chk_Batt_Low ; EFB350
  jr nz,good           ; 2003
  BCALL _OP1Set1      ; EF9B41
good:
  BCALL _StoAns       ; EFBF4A
-FloppusMaximus
Get Amount of Free Ram
EFE542EF9247EF5641EFBF4A
BCALL _MemChk     ; EFE542
BCALL _SetXXXXOP2 ; EF9247
BCALL _OP2ToOP1   ; EF5641
BCALL _StoAns     ; EFBF4A
-FloppusMaximus
OS Version
EF6F4CF578EF8C47EF6742EF6742F1EF8F47F7EFBF4A
BCALL _GetBaseVer ; EF6F4C
push af           ; F5
ld a,b            ; 78
BCALL _SetXXOP1   ; EF8C47
BCALL _DecO1Exp   ; EF6742
BCALL _DecO1Exp   ; EF6742
pop af            ; F1
BCALL _SetXXOP2   ; EF8F47
rst 30h           ; F7
BCALL _StoAns     ; EFBF4A
-FloppusMaximus
Hardware Version
EFBA80EF8C47EFBF4A
BCALL _GetHWVer  ; EFBA80
BCALL _SetXXOP1  ; EF8C47
BCALL _StoAns    ; EFBF4A
-FloppusMaximus
GetKey
EF7045FB76EF4447B728F8EF5641EFD14A
 B_CALL _RunIndicOff ; EF7045
again:
 ei                  ; FB
 halt                ; 76
 B_CALL _GetK        ; EF4447
 or a                ; B7
 jr z,again          ; 28F8
 B_CALL _OP2ToOP1    ; EF5641
 B_CALL _StoX        ; EFD14A
-FloppusMaximus
Amount of Free ROM → X
This routines is still being discussed in the Detached Solutions forum. The final version will be posted here as soon as all parties have come to an agreement.
Toggle Archiving Privileges in Programs
21F8893E02AE77
You should run this directly before and directly after archiving/unarciving programs within a TI-BASIC program.
	ld hl,flags+apdFlags
	ld a,2
	xor (hl)
	ld (hl),a