Compare commits

...

5 Commits

Author SHA1 Message Date
Virgil Dupras
24e588019b Add words RSHIFT and LSHIFT 2020-05-07 15:41:43 -04:00
Virgil Dupras
4e98ef11bd ti-84+: wip
I need RSHIFT and LSHIFT first...
2020-05-07 15:08:42 -04:00
Virgil Dupras
f2f3474698 Begin copying fonts (and compiler) to blk 2020-05-07 12:09:52 -04:00
Virgil Dupras
be66d7b4a2 editor: implement E 2020-05-07 08:44:17 -04:00
Virgil Dupras
204a9c69f8 editor: fix PSP leak in F 2020-05-07 08:38:57 -04:00
30 changed files with 226 additions and 21 deletions

View File

@ -8,8 +8,8 @@ MASTER INDEX
280 Z80 boot code 350 ACIA driver 280 Z80 boot code 350 ACIA driver
370 SD Card driver 390 Inner core 370 SD Card driver 390 Inner core
420 Core words 480 AT28 Driver 420 Core words 480 AT28 Driver
490 TRS-80 Recipe 490 TRS-80 Recipe 520 Fonts
550 TI-84+ Recipe

View File

@ -10,7 +10,7 @@ MOD a b -- c a % b -> c
AND a b -- c a & b -> c AND a b -- c a & b -> c
OR a b -- c a | b -> c OR a b -- c a | b -> c
XOR a b -- c a ^ b -> c XOR a b -- c a ^ b -> c
LSHIFT a u -- c a << u -> c
RSHIFT a u -- c a >> u -> c
Shortcuts: 1+ 2+ 1- 2- Shortcuts: 1+ 2+ 1- 2-

View File

@ -2,8 +2,8 @@ T ( n -- ): select line n for editing.
P xxx: put typed line on selected line. P xxx: put typed line on selected line.
U xxx: insert typed line on selected line. U xxx: insert typed line on selected line.
F xxx: find typed string in block. F xxx: find typed string in block.
I xxx: insert typed string at cursor I xxx: insert typed string at cursor.
E: Delete previously found string.

View File

@ -1,5 +1,5 @@
50 LOAD+ ( B152, extras ) 50 LOAD+ ( B152, extras )
1 6 LOADR+ 1 7 LOADR+
: BROWSE : BROWSE
0 ACC ! L 0 ACC ! L

View File

@ -7,6 +7,6 @@
OVER BLK) = OR ( a1 a2 f1|f2 ) OVER BLK) = OR ( a1 a2 f1|f2 )
UNTIL UNTIL
DUP BLK) < IF BLK( - FBUF + -^ EDPOS ! THEN DUP BLK) < IF BLK( - FBUF + -^ EDPOS ! THEN
EDPOS @ 64 / _pln EDPOS @ 64 / _pln DROP
; ;

10
blk/108
View File

@ -1,9 +1,9 @@
: _ilen ( length of str in IBUF ) : _blen ( buf -- length of str in buf )
IBUF BEGIN C@+ EOL? UNTIL IBUF - 1- ; DUP BEGIN C@+ EOL? UNTIL -^ 1- ;
: _rbufsz ( size of linebuf to the right of curpos )
EDPOS @ 64 MOD 63 -^ ;
: _I : _I
IBUF _type EDPOS @ 64 MOD ( cno ) IBUF _type _rbufsz IBUF _blen 2DUP > IF
63 -^ _ilen ( rbuffsize ilen )
2DUP > IF
SWAP OVER - ( ilen chars-to-move ) SWAP OVER - ( ilen chars-to-move )
SWAP EDPOS @ _cpos 2DUP + ( ctm ilen a a+ilen ) SWAP EDPOS @ _cpos 2DUP + ( ctm ilen a a+ilen )
3 PICK MOVE- ( ctm ilen ) 3 PICK MOVE- ( ctm ilen )

9
blk/109 Normal file
View File

@ -0,0 +1,9 @@
: E
FBUF _blen EDPOS @ _cpos 2DUP + ( l a1 a1+l )
SWAP _rbufsz MOVE ( l )
( get to next line - l )
DUP EDPOS @ 0xffc0 AND 0x40 + -^ _cpos ( l a )
SWAP 0 FILL
EDPOS @ 64 / _pln
;

View File

@ -6,7 +6,7 @@
( A, spits an assembled byte, A,, spits an assembled word ( A, spits an assembled byte, A,, spits an assembled word
Both increase PC. To debug, change C, to .X ) Both increase PC. To debug, change C, to .X )
: A, C, ; : A,, SPLITB A, A, ; : A, C, ; : A,, SPLITB A, A, ;
: <<3 8 * ; : <<4 16 * ; : <<3 3 LSHIFT ; : <<4 4 LSHIFT ;
( As a general rule, IX and IY are equivalent to spitting an ( As a general rule, IX and IY are equivalent to spitting an
extra 0xdd / 0xfd and then spit the equivalent of HL ) extra 0xdd / 0xfd and then spit the equivalent of HL )
: IX 0xdd A, HL ; : IY 0xfd A, HL ; : IX 0xdd A, HL ; : IY 0xfd A, HL ;

View File

@ -1 +1 @@
1 51 LOADR+ 1 53 LOADR+

12
blk/334 Normal file
View File

@ -0,0 +1,12 @@
CODE RSHIFT ( n u -- n )
BC POPqq, ( u )
HL POPqq, ( n )
chkPS,
B C LDrr,
B INCr, B DECr, IFNZ,
BEGIN,
H SRLr, L RRr,
DJNZ, AGAIN,
THEN,
HL PUSHqq,
;CODE

13
blk/335 Normal file
View File

@ -0,0 +1,13 @@
CODE LSHIFT ( n u -- n )
BC POPqq, ( u )
HL POPqq, ( n )
chkPS,
B C LDrr,
B INCr, B DECr, IFNZ,
BEGIN,
L SLAr, H RLr,
DJNZ, AGAIN,
THEN,
HL PUSHqq,
;CODE

View File

@ -9,8 +9,8 @@
: SDCMDR7 : SDCMDR7
_sdcSel _sdcSel
_cmd ( r ) _cmd ( r )
_idle 256 * _idle + ( r arg1 ) _idle 8 LSHIFT _idle + ( r arg1 )
_idle 256 * _idle + ( r arg1 arg2 ) _idle 8 LSHIFT _idle + ( r arg1 arg2 )
_sdcDesel _sdcDesel
; ;

View File

@ -10,6 +10,6 @@
SWAP 1+ ( crc a+1 ) SWAP 1+ ( crc a+1 )
LOOP LOOP
DROP ( crc1 ) DROP ( crc1 )
_idle 256 * _idle + ( crc2 ) _idle 8 LSHIFT _idle + ( crc2 )
_wait DROP _sdcDesel _wait DROP _sdcDesel
= NOT IF _err THEN ; = NOT IF _err THEN ;

View File

@ -3,14 +3,14 @@
( 4 256b sectors per block, 10 sec per cyl, 40 cyl max ) ( 4 256b sectors per block, 10 sec per cyl, 40 cyl max )
10 /MOD ( sec cyl ) 10 /MOD ( sec cyl )
DUP 39 > IF _err THEN DUP 39 > IF _err THEN
256 * + ( cylsec ) 8 LSHIFT + ( cylsec )
; ;
: FD@! ( wref blk -- ) : FD@! ( wref blk -- )
1 @DCSTAT NOT IF _err THEN 1 @DCSTAT NOT IF _err THEN
4 * ( wr sec ) 2 LSHIFT ( 4 * -- wr sec )
4 0 DO ( wr sec ) 4 0 DO ( wr sec )
DUP I + _cylsec ( wr sec cs ) DUP I + _cylsec ( wr sec cs )
I 256 * BLK( + ( wr sec cs addr ) I 8 LSHIFT BLK( + ( wr sec cs addr )
1 ROT ROT ( wr sec drv cs addr ) 1 ROT ROT ( wr sec drv cs addr )
4 PICK EXECUTE NOT IF _err THEN 4 PICK EXECUTE NOT IF _err THEN
LOOP 2DROP ; LOOP 2DROP ;

13
blk/520 Normal file
View File

@ -0,0 +1,13 @@
Fonts
Fonts are kept in "source" form in the following blocks and
then compiled to binary bitmasks by the following code. In
source form, fonts are a simple sequence of '.' and 'X'. '.'
means empty, 'X' means filled. Glyphs are entered one after the
other, starting at 0x21 and ending at 0x7e. To be space
efficient in blocks, we align glyphs horizontally in the blocks
to fit as many character as we can. For example, a 5x7 font
would mean that we would have 12x2 glyphs per block.
521 Font compiler 530 3x5 font
532 5x7 font 536 7x7 font

6
blk/521 Normal file
View File

@ -0,0 +1,6 @@
( Converts "dot-X" fonts to binary "glyph rows". One byte for
each row. In a 5x7 font, each glyph thus use 7 bytes.
Resulting bytes are aligned to the left of the byte.
Therefore, for a 5-bit wide char, "X.X.X" translates to
0b10101000. Left-aligned bytes are easier to work with when
compositing glyphs. )

16
blk/522 Normal file
View File

@ -0,0 +1,16 @@
: _g ( given a top-left of dot-X in BLK(, spit 5 bin lines )
5 0 DO
0 3 0 DO ( a r )
2 *
OVER J 64 * I + + C@ 'X' = IF 1+ THEN
LOOP 32 * C, LOOP DROP ;
: _l ( spit a line of u glyphs )
( u ) 0 DO ( a )
DUP I 3 * + _g
LOOP DROP ;
: CPFNT3x5
0 , 0 , 0 C, ( space char )
530 LOAD BLK( 21 _l 192 + 21 _l 192 + 21 _l ( 63 )
531 LOAD BLK( 21 _l 192 + 10 _l ( 94! )
;

16
blk/530 Normal file
View File

@ -0,0 +1,16 @@
.X.X.XX.X.XXX...X..X...XX...X...............X.X..X.XX.XX.X.XXXX
.X.X.XXXXXX...XX.X.X..X..X.XXX.X............XX.XXX...X..XX.XX..
.X........XX.X..X.....X..X..X.XXX...XXX....X.X.X.X..X.XX.XXXXX.
......XXXXX.X..X.X....X..X.X.X.X..X.......X..X.X.X.X....X..X..X
.X....X.X.X...X.XX.....XX........X......X.X...X.XXXXXXXX...XXX.
.XXXXXXXXXXX........X...X..XX..X..X.XX..XXXX.XXXXXX.XXX.XXXXXXX
X....XX.XX.X.X..X..X.XXX.X...XXXXX.XX.XX..X.XX..X..X..X.X.X...X
XXX.X.XXXXXX......X.......X.X.XXXXXXXX.X..X.XXX.XX.X.XXXX.X...X
X.XX..X.X..X.X..X..X.XXX.X....X..X.XX.XX..X.XX..X..X.XX.X.X...X
XXXX..XXXXX....X....X...X...X..XXX.XXX..XXXX.XXXX...XXX.XXXXXX.
X.XX..X.XXX.XXXXX.XXXXX..XXXXXX.XX.XX.XX.XX.XXXXXXXX..XXX.X....
XX.X..XXXX.XX.XX.XX.XX.XX...X.X.XX.XX.XX.XX.X..XX..X....XX.X...
X..X..XXXX.XX.XXX.X.XXX..X..X.X.XX.XXXX.X..X..X.X...X...X......
XX.X..X.XX.XX.XX..XXXX.X..X.X.X.XX.XXXXX.X.X.X..X....X..X......
X.XXXXX.XX.XXXXX...XXX.XXX..X.XXX.X.X.XX.X.X.XXXXXX..XXXX...XXX
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_

11
blk/531 Normal file
View File

@ -0,0 +1,11 @@
X.....X.......X....XX...X...X...XX..XX.......................X.
.X.XX.X...XX..X.X.X...X.X........X.X.X.X.XXX..X.XX..XX.XX.XXXXX
.....XXX.X...XXX.XXX.X.XXX..X...XXX..X.XXXX.XX.XX.XX.XX..XX..X.
...XXXX.XX..X.XXX.X...XXX.X.X...XX.X.X.X.XX.XX.XXX..XXX....X.X.
...XXXXX..XX.XX.XXX..XX.X.X.X.XX.X.X.XXX.XX.X.X.X....XX..XX..XX
...................XX.X.XX.....................................
X.XX.XX.XX.XX.XXXX.X..X..X..XX
X.XX.XX.X.X..X..XXX...X...XXX.
X.XX.XXXX.X..X.XX..X..X..X....
XXX.X.X.XX.X.X.XXX.XX.X.XX....
`abcdefghijklmnopqrstuvwxyz{|}~

17
blk/532 Normal file
View File

@ -0,0 +1,17 @@
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................

6
blk/550 Normal file
View File

@ -0,0 +1,6 @@
TI-84+ Recipe
Support code for the TI-84+ recipe. Contains drivers for the
keyboard and LCD.
551 LCD

16
blk/551 Normal file
View File

@ -0,0 +1,16 @@
TI-84+ LCD driver
Implement (emit) on TI-84+ (for now)'s LCD screen. Load with
"555 LOAD".
The screen is 96x64 pixels. The 64 rows are addressed directly
with CMD_ROW but columns are addressed in chunks of 6 or 8 bits
(there are two modes).
In 6-bit mode, there are 16 visible columns. In 8-bit mode,
there are 12.
Note that "X-increment" and "Y-increment" work in the opposite
way than what most people expect. Y moves left and right, X
moves up and down.
(cont.)

16
blk/552 Normal file
View File

@ -0,0 +1,16 @@
# Z-Offset
This LCD has a "Z-Offset" parameter, allowing to offset rows on
the screen however we wish. This is handy because it allows us
to scroll more efficiently. Instead of having to copy the LCD
ram around at each linefeed (or instead of having to maintain
an in-memory buffer), we can use this feature.
The Z-Offet goes upwards, with wrapping. For example, if we
have an 8 pixels high line at row 0 and if our offset is 8,
that line will go up 8 pixels, wrapping itself to the bottom of
the screen.
The principle is this: The active line is always the bottom
one. Therefore, when active row is 0, Z is FNT_HEIGHT+1, when
row is 1, Z is (FNT_HEIGHT+1)*2, When row is 8, Z is 0. (cont.)

16
blk/553 Normal file
View File

@ -0,0 +1,16 @@
# 6/8 bit columns and smaller fonts
If your glyphs, including padding, are 6 or 8 pixels wide,
you're in luck because pushing them to the LCD can be done in a
very efficient manner. Unfortunately, this makes the LCD
unsuitable for a Collapse OS shell: 6 pixels per glyph gives us
only 16 characters per line, which is hardly usable.
This is why we have this buffering system. How it works is that
we're always in 8-bit mode and we hold the whole area (8 pixels
wide by FNT_HEIGHT high) in memory. When we want to put a glyph
to screen, we first read the contents of that area, then add
our new glyph, offsetted and masked, to that buffer, then push
the buffer back to the LCD. If the glyph is split, move to the
next area and finish the job.
(cont.)

3
blk/554 Normal file
View File

@ -0,0 +1,3 @@
That being said, it's important to define clearly what CURX and
CURY variable mean. Those variable keep track of the current
position *in pixels*, in both axes.

16
blk/555 Normal file
View File

@ -0,0 +1,16 @@
( Required config: TI_MEM )
: TI_MEM+ [ TI_MEM LITN ] + ;
: LCD_PORT_CMD 0x10 ;
: LCD_PORT_DATA 0x11 ;
: FNT_WIDTH 3 ;
: FNT_HEIGHT 5 ;
( Current Y position on the LCD, that is, where we're going to
spit our next glyph. )
: LCD_CURY 0 TI_MEM+ ;
: LCD_CURX 1 TI_MEM+ ;
( two pixel buffers that are 8 pixels wide (1b) by FNT_HEIGHT
pixels high. This is where we compose our resulting pixels
blocks when spitting a glyph. )
: LCD_BUF 2 TI_MEM+ ;
1 2 LOADR+

11
blk/556 Normal file
View File

@ -0,0 +1,11 @@
: _wait ( Wait until the lcd is ready to receive a command )
( When 7th bit is cleared, we can send a new command )
BEGIN LCD_PORT_CMD PC@ 0x80 AND NOT UNTIL ;
: _cmd LCD_PORT_CMD PC! _wait ;
: _data! LCD_PORT_DATA PC! _wait ;
: _data@ LCD_PORT_DATA PC@ _wait ;
: LCDOFF 0x02 ( CMD_DISABLE ) _cmd ;
: _col! ( col -- )
0x20 ( CMD_COL ) + _cmd ;
: _row! ( row -- )
0x80 ( CMD_ROW ) + _cmd ;

3
blk/557 Normal file
View File

@ -0,0 +1,3 @@
( Load a "glyph line" from buffer, left part being in MSB and
right part being in LSB. )
: _gl@

5
blk/558 Normal file
View File

@ -0,0 +1,5 @@
: _glyph> ( a -- )
LCD_CURY C@ _row! LCD_CURX C@ 8 /MOD _col! ( a coff )
0x05 ( XINC ) _cmd _data@ DROP
FNT_HEIGHT 0 DO LOOP

Binary file not shown.