Compare commits
6 Commits
244776a7eb
...
4e1fe916be
Author | SHA1 | Date | |
---|---|---|---|
|
4e1fe916be | ||
|
2791dd992e | ||
|
62ae1012df | ||
|
a6aba40327 | ||
|
06a4674317 | ||
|
a476773813 |
4
blk/050
4
blk/050
@ -4,6 +4,8 @@ Memory
|
||||
! n a -- Store n in address a
|
||||
? a -- Print value of addr a
|
||||
+! n a -- Increase value of addr a by n
|
||||
BIT@ b a -- f Get bit b from addr a.
|
||||
BIT! f b a -- Set bit b to f in addr a.
|
||||
C@ a -- c Set c to byte at address a
|
||||
C@+ a -- a+1 c Fetch c from a and inc a.
|
||||
C@- a -- a-1 c Fetch c from a and dec a.
|
||||
@ -11,6 +13,4 @@ C! c a -- Store byte c in address a
|
||||
C!+ c a -- a+1 Store byte c in a and inc a.
|
||||
C!- c a -- a-1 Store byte c in a and dec a.
|
||||
CURRENT -- a Set a to wordref of last added entry.
|
||||
CURRENT* -- a A pointer to active CURRENT*. Useful
|
||||
when we have multiple active dicts.
|
||||
(cont.)
|
||||
|
2
blk/051
2
blk/051
@ -1,3 +1,5 @@
|
||||
CURRENT* -- a A pointer to active CURRENT*. Useful
|
||||
when we have multiple active dicts.
|
||||
FILL a n b -- Fill n bytes at addr a with val b.
|
||||
HERE -- a Push HERE's address
|
||||
H@ -- a HERE @
|
||||
|
10
blk/404
10
blk/404
@ -4,9 +4,11 @@
|
||||
DUP NOT IF DROP 0x0c RAM+ @ THEN ( 0c == C<* )
|
||||
EXECUTE
|
||||
;
|
||||
|
||||
: , HERE @ ! HERE @ 2+ HERE ! ;
|
||||
|
||||
: C, HERE @ C! HERE @ 1+ HERE ! ;
|
||||
|
||||
|
||||
: BIT@ ( bit addr -- f ) C@ SWAP RSHIFT 0x01 AND ;
|
||||
: BIT! ( f bit addr -- )
|
||||
SWAP 0x01 SWAP LSHIFT ROT ( addr mask f )
|
||||
IF OVER C@ OR
|
||||
ELSE 0xff XOR OVER C@ AND THEN ( addr flg )
|
||||
SWAP C! ;
|
||||
|
4
blk/568
4
blk/568
@ -7,3 +7,7 @@ CREATE _atbl
|
||||
0x20 C, 'Y' C, 'T' C, 'O' C, 'J' C, 'E' C, 'B' C, 0 C,
|
||||
0 C, 'X' C, 'S' C, 'N' C, 'I' C, 'D' C, 'A' C, 0x80 C,
|
||||
0 C, 0 C, 0 C, 0 C, 0 C, 0x81 ( 2nd ) C, 0 C, 0x7f C,
|
||||
: _2nd@ 0 [ KBD_MEM LITN ] BIT@ ;
|
||||
: _2nd! 0 [ KBD_MEM LITN ] BIT! ;
|
||||
: _alock@ 1 [ KBD_MEM LITN ] BIT@ ;
|
||||
: _alock^ _alock@ NOT 1 [ KBD_MEM LITN ] BIT! ;
|
||||
|
2
blk/569
2
blk/569
@ -4,7 +4,7 @@
|
||||
DROP
|
||||
1+ DUP 7 = IF DROP 0 THEN ( inc gid )
|
||||
1 OVER LSHIFT 0xff -^ ( group dmask ) _get
|
||||
DUP 0xff = NOT UNTIL
|
||||
DUP 0xff = NOT UNTIL _wait
|
||||
( gid dmask )
|
||||
0xff XOR ( dpos ) 0 ( dindex )
|
||||
BEGIN 1+ 2DUP RSHIFT NOT UNTIL 1-
|
||||
|
18
blk/570
18
blk/570
@ -1,6 +1,14 @@
|
||||
: _tbl^ ( swap input tbl )
|
||||
_atbl = IF _dtbl ELSE _atbl THEN ;
|
||||
: (key)
|
||||
_dtbl 0 ( dummy ) BEGIN ( tbl 0 )
|
||||
DROP DUP ( tbl ) _gti + C@
|
||||
DUP 0x80 = IF ( alpha ) 2DROP _atbl 0 THEN
|
||||
DUP UNTIL ( tbl c -- loop if null ) SWAP DROP
|
||||
_wait ;
|
||||
0 _2nd! 0 ( lastchr ) BEGIN
|
||||
_alock@ IF _atbl ELSE _dtbl THEN
|
||||
OVER 0x80 ( alpha ) =
|
||||
IF _tbl^ _2nd@ IF _alock^ THEN THEN
|
||||
SWAP 0x81 = _2nd!
|
||||
_gti + C@
|
||||
DUP 0 0x80 >< UNTIL ( loop if not in range )
|
||||
( lowercase? )
|
||||
_2nd@ IF DUP 'A' 'Z' =><= IF 0x20 OR THEN THEN
|
||||
;
|
||||
: KBD$ 0 [ KBD_MEM LITN ] C! ;
|
||||
|
BIN
emul/forth.bin
BIN
emul/forth.bin
Binary file not shown.
@ -8,11 +8,24 @@ screen. With a tiny font, the best we can get is a 24x10 console.
|
||||
|
||||
There is, however, a built-in USB controller that might prove very handy.
|
||||
|
||||
[Further reading](../../doc/ti8x.md)
|
||||
I haven't opened one up yet, but apparently, they have limited scavenging value
|
||||
because its z80 CPU is packaged in a TI-specific chip. Due to its sturdy design,
|
||||
and its ample RAM and flash, we could imagine it becoming a valuable piece of
|
||||
equipment if found intact.
|
||||
|
||||
The best pre-collapse ressource about it is
|
||||
[WikiTI](http://wikiti.brandonw.net/index.php).
|
||||
|
||||
As it is now, with its tiny screen and cumbersome keyboard, Collapse OS is
|
||||
not really usable on the TI-84+. One could imagine a scenario where one has a
|
||||
terminal and uses the TI-84+ through the link for its large amount of flash and
|
||||
RAM. But using it standalone? Nah, not even post-collapse.
|
||||
|
||||
Therefore, this recipe is more of a "look, I run!" demo.
|
||||
|
||||
## Recipe
|
||||
|
||||
This recipe gets the Collapse OS BASIC shell to run on the TI-84+, using its LCD
|
||||
This recipe gets the Collapse OS interpreter to run on the TI-84+, using its LCD
|
||||
screen as output and its builtin keyboard as input.
|
||||
|
||||
## Gathering parts
|
||||
@ -25,7 +38,7 @@ screen as output and its builtin keyboard as input.
|
||||
|
||||
## Build the ROM
|
||||
|
||||
Running `make` will result in `os.rom` being created.
|
||||
Running `make` will result in `stage1.rom` being created.
|
||||
|
||||
## Emulate
|
||||
|
||||
@ -38,6 +51,30 @@ Collapse OS prompt will appear. See `emul/hw/ti/README.md` for details.
|
||||
|
||||
## Upload to the calculator
|
||||
|
||||
### Background notes
|
||||
|
||||
Getting software to run on it is a bit tricky because it needs to be signed
|
||||
with TI-issued private keys. Those keys have long been found and are included
|
||||
in `keys/`. With the help of the
|
||||
[mktiupgrade](https://github.com/KnightOS/mktiupgrade), an upgrade file can be
|
||||
prepared and then sent through the USB port with the help of
|
||||
[tilp](http://lpg.ticalc.org/prj_tilp/).
|
||||
|
||||
That, however, requires a modern computing environment. As of now, there is no
|
||||
way of installing Collapse OS on a TI-8X+ calculator from another Collapse OS
|
||||
system.
|
||||
|
||||
Because it is not on the roadmap to implement complex cryptography in Collapse
|
||||
OS, the plan is to build a series of pre-signed bootloader images. The
|
||||
bootloader would then receive data through either the Link jack or the USB port
|
||||
and write that to flash (I haven't verified that yet, but I hope that data
|
||||
written to flash this way isn't verified cryptographically by the calculator).
|
||||
|
||||
As modern computing fades away, those pre-signed binaries would become opaque,
|
||||
but at least, would allow bootstrapping from post-modern computers.
|
||||
|
||||
### Instructions
|
||||
|
||||
**WARNING: the instructions below will wipe all the contents of your calculator,
|
||||
including TI-OS.**
|
||||
|
||||
|
@ -1,116 +0,0 @@
|
||||
.equ RAMSTART 0x8000
|
||||
.equ RAMEND 0xbfff
|
||||
.equ PORT_INT_MASK 0x03
|
||||
.equ INT_MASK_ON 0x00
|
||||
.equ PORT_INT_TRIG 0x04
|
||||
.equ INT_TRIG_ON 0x00
|
||||
.equ PORT_BANKB 0x07
|
||||
|
||||
jp boot
|
||||
|
||||
.fill 0x18-$
|
||||
jp boot ; reboot
|
||||
|
||||
.fill 0x38-$
|
||||
jp handleInterrupt
|
||||
|
||||
.fill 0x53-$
|
||||
jp boot
|
||||
; 0x0056
|
||||
.db 0xFF, 0xA5, 0xFF
|
||||
|
||||
.fill 0x64-$
|
||||
|
||||
.inc "err.h"
|
||||
.inc "ascii.h"
|
||||
.inc "core.asm"
|
||||
.inc "str.asm"
|
||||
.equ FNT_WIDTH 3
|
||||
.equ FNT_HEIGHT 5
|
||||
.inc "fnt/mgm.asm"
|
||||
.equ LCD_RAMSTART RAMSTART
|
||||
.inc "ti/lcd.asm"
|
||||
.equ KBD_RAMSTART LCD_RAMEND
|
||||
.inc "ti/kbd.asm"
|
||||
.equ STDIO_RAMSTART KBD_RAMEND
|
||||
.equ STDIO_GETC kbdGetC
|
||||
.equ STDIO_PUTC lcdPutC
|
||||
.inc "stdio.asm"
|
||||
|
||||
; *** BASIC ***
|
||||
|
||||
; RAM space used in different routines for short term processing.
|
||||
.equ SCRATCHPAD_SIZE STDIO_BUFSIZE
|
||||
.equ SCRATCHPAD STDIO_RAMEND
|
||||
.inc "lib/util.asm"
|
||||
.inc "lib/ari.asm"
|
||||
.inc "lib/parse.asm"
|
||||
.inc "lib/fmt.asm"
|
||||
.equ EXPR_PARSE parseLiteralOrVar
|
||||
.inc "lib/expr.asm"
|
||||
.inc "basic/util.asm"
|
||||
.inc "basic/parse.asm"
|
||||
.inc "basic/tok.asm"
|
||||
.equ VAR_RAMSTART SCRATCHPAD+SCRATCHPAD_SIZE
|
||||
.inc "basic/var.asm"
|
||||
.equ BUF_RAMSTART VAR_RAMEND
|
||||
.inc "basic/buf.asm"
|
||||
.equ BAS_RAMSTART BUF_RAMEND
|
||||
.inc "basic/main.asm"
|
||||
|
||||
.out BAS_RAMEND
|
||||
boot:
|
||||
di
|
||||
ld sp, RAMEND
|
||||
im 1
|
||||
|
||||
; enable ON key interrupt
|
||||
in a, (PORT_INT_MASK)
|
||||
set INT_MASK_ON, a
|
||||
out (PORT_INT_MASK), a
|
||||
ld a, 0x80
|
||||
out (PORT_BANKB), a
|
||||
|
||||
ei
|
||||
|
||||
call lcdOff
|
||||
|
||||
; sleep until we press ON
|
||||
halt
|
||||
|
||||
main:
|
||||
; Fun fact: if I place this line just above basStart like I would
|
||||
; normally do, my TI-84+ refuses to validate the binary. But placed
|
||||
; here, validation works fine.
|
||||
call basInit
|
||||
call kbdInit
|
||||
call lcdInit
|
||||
xor a
|
||||
call lcdSetCol
|
||||
jp basStart
|
||||
|
||||
handleInterrupt:
|
||||
di
|
||||
push af
|
||||
|
||||
; did we push the ON button?
|
||||
in a, (PORT_INT_TRIG)
|
||||
bit INT_TRIG_ON, a
|
||||
jp z, .done ; no? we're done
|
||||
|
||||
; yes? acknowledge and boot
|
||||
in a, (PORT_INT_MASK)
|
||||
res INT_MASK_ON, a ; acknowledge interrupt
|
||||
out (PORT_INT_MASK), a
|
||||
|
||||
pop af
|
||||
ei
|
||||
jp main
|
||||
|
||||
.done:
|
||||
pop af
|
||||
ei
|
||||
reti
|
||||
|
||||
FNT_DATA:
|
||||
.bin "fnt/3x5.bin"
|
@ -1,2 +0,0 @@
|
||||
; RAMSTART + kernel usage + safety buffer
|
||||
.equ USER_RAMSTART 0x8040
|
@ -1,8 +1,10 @@
|
||||
0x8000 CONSTANT RAMSTART
|
||||
0xb000 CONSTANT RS_ADDR
|
||||
RAMSTART 0x70 + CONSTANT LCD_MEM
|
||||
RAMSTART 0x72 + CONSTANT KBD_MEM
|
||||
0x01 CONSTANT KBD_PORT
|
||||
212 LOAD ( z80 assembler )
|
||||
: ZFILL, ( u ) 0 DO 0 A, LOOP ;
|
||||
262 LOAD ( xcomp )
|
||||
522 LOAD ( font compiler )
|
||||
: CODE XCODE ;
|
||||
@ -11,8 +13,55 @@ RAMSTART 0x70 + CONSTANT LCD_MEM
|
||||
: CREATE XCREATE ; ( for KBD tbls )
|
||||
: : [ ' X: , ] ;
|
||||
|
||||
( TI-84+ requires specific code at specific offsets which
|
||||
come in conflict with Collapse OS' stable ABI. We thus
|
||||
offset the binary by 0x100, which is our minimum possible
|
||||
increment and fill the TI stuff with the code below. )
|
||||
|
||||
0x5a JPnn, 0x15 ZFILL, ( 0x18 )
|
||||
0x5a JPnn, ( reboot ) 0x1d ZFILL, ( 0x38 )
|
||||
( handleInterrupt )
|
||||
DI,
|
||||
AF PUSHqq,
|
||||
( did we push the ON button? )
|
||||
0x04 ( PORT_INT_TRIG ) INAn,
|
||||
0 ( INT_TRIG_ON ) A BITbr,
|
||||
IFNZ,
|
||||
( yes? acknowledge and boot )
|
||||
0x03 ( PORT_INT_MASK ) INAn,
|
||||
0x00 ( INT_MASK_ON ) A RESbr, ( ack interrupt )
|
||||
0x03 ( PORT_INT_MASK ) OUTnA,
|
||||
AF POPqq,
|
||||
EI,
|
||||
0x100 JPnn,
|
||||
THEN,
|
||||
AF POPqq,
|
||||
EI,
|
||||
RETI,
|
||||
|
||||
0x03 ZFILL, ( 0x53 )
|
||||
0x5a JPnn, ( 0x56 ) 0xff A, 0xa5 A, 0xff A, ( 0x5a )
|
||||
( boot )
|
||||
DI,
|
||||
(im1)
|
||||
( enable the ON key interrupt )
|
||||
0x03 ( PORT_INT_MASK ) INAn,
|
||||
0x00 ( INT_MASK_ON ) A SETbr,
|
||||
0x03 ( PORT_INT_MASK ) OUTnA,
|
||||
A 0x80 LDrn,
|
||||
0x07 ( PORT_BANKB ) OUTnA,
|
||||
EI,
|
||||
( LCD off )
|
||||
A 0x02 ( LCD_CMD_DISABLE ) LDrn,
|
||||
0x10 ( LCD_PORT_CMD ) OUTnA,
|
||||
HALT,
|
||||
|
||||
0x95 ZFILL, ( 0x100 )
|
||||
( All set, carry on! )
|
||||
|
||||
CURRENT @ XCURRENT !
|
||||
|
||||
0x100 BIN( !
|
||||
282 LOAD ( boot.z80 )
|
||||
393 LOAD ( icore low )
|
||||
555 557 LOADR ( LCD low )
|
||||
@ -25,6 +74,6 @@ PC ORG @ 8 + !
|
||||
422 437 XPACKR ( core )
|
||||
558 560 XPACKR ( LCD high )
|
||||
438 451 XPACKR ( print fmt readln )
|
||||
," : _ LCD$ (ok) RDLN$ ; _ "
|
||||
ORG @ 256 /MOD 2 PC! 2 PC!
|
||||
," : _ LCD$ KBD$ (ok) RDLN$ ; _ "
|
||||
ORG @ 0x100 - 256 /MOD 2 PC! 2 PC!
|
||||
H@ 256 /MOD 2 PC! 2 PC!
|
||||
|
Loading…
Reference in New Issue
Block a user