Commit Graph

118 Commits

Author SHA1 Message Date
Virgil Dupras 17cc28e211 recipes/ti84: use a 3x5 font instead of a 5x7 one
This allow a lot more characters to fit on that tiny screen...

ref #41
2019-11-11 13:26:24 -05:00
Virgil Dupras 30d6fdb16b ti/lcd: use brand new support for IX in SRL and RR 2019-11-10 22:07:44 -05:00
Virgil Dupras c4658591bd ti/lcd: allow for fonts smaller than 5 pixels
That's a lot of code for such a small change, but there's a big difference
between 5 pixels and 4 pixels: 4 pixels requires compositing.
2019-11-09 22:55:15 -05:00
Virgil Dupras 6d9f96aee6 ti/lcd: add support for backspace
Also, fix visual glitch on line wrap.
2019-11-09 14:37:52 -05:00
Virgil Dupras a4190f9984 recipes/ti84: document usage
ref #41
2019-11-09 14:20:01 -05:00
Virgil Dupras 2026113480 ti/kbd: lowercase letters by default, 2nd to upcase 2019-11-09 13:38:35 -05:00
Virgil Dupras 9c37471780 ti/kbd: improve debouncing
Previously, on real hardware (emulator behaved fine), we would routinely
get repeat keys unless pressing the button very fast. This commit solves that.
2019-11-09 13:22:01 -05:00
Virgil Dupras 418af5f626 ti/kbd: make Alpha and 2nd toggle
Previously, when being in A-Lock mode, activating Alpha wouldn't make
us go temporarily in digit mode, as is expected.
2019-11-09 13:12:36 -05:00
Virgil Dupras 67f689260f ti/lcd: Add scrolling through z-offset 2019-11-09 08:25:10 -05:00
Virgil Dupras 6a70a0e5e6 ti/lcd: wrap rows on overflow 2019-11-09 08:09:01 -05:00
Virgil Dupras b27a71cb88 ti/kbd: fix space character 2019-11-09 08:01:03 -05:00
Virgil Dupras 6c1b1f2b79 ti/lcd: wrap to next line when overflowing 2019-11-08 22:55:56 -05:00
Virgil Dupras bb2e528b65 ti/lcd: clear screen on init
LCD RAM persists between reboots, makingit necessary to clear it.

ref #41
2019-11-08 21:54:03 -05:00
Virgil Dupras c896b77143 ti/kbd: implement A-Lock
ref #41
2019-11-08 20:27:43 -05:00
Virgil Dupras 8d5c26f299 ti/kbd: add alpha support
no a-lock or lowercase yet.

ref #41
2019-11-08 15:45:45 -05:00
Virgil Dupras ca8b315e9d ti/kbd: widen char detection
no alpha yet.

ref #41
2019-11-08 14:58:29 -05:00
Virgil Dupras dca6ce4e8e ti/kbd: begin GetC implementation
For now, only digits are scanned. Lifted from my "tiseg7" example.

ref #41
2019-11-08 14:04:56 -05:00
Virgil Dupras 6a4bddc493 ti/lcd: ensure that variables are initialized 2019-11-08 11:45:37 -05:00
Virgil Dupras c57f2d6973 fonts/5x7: add lowercase letters 2019-11-07 22:27:12 -05:00
Virgil Dupras fda9c9826e ti/lcd: add linefeed support
There's no scrolling yet...

ref #41
2019-11-07 20:53:15 -05:00
Virgil Dupras a13a94bbc7 fix typos 2019-11-07 12:13:00 -05:00
Virgil Dupras ca84b5dac8 recipes/ti84: first step
This was mostly lifted from my "tihello" example, but it required significant
adjustments.

This commit also introduces a font management system. A lot of fonts are
available online, but sources aren't always clear so to avoid copyright
landmines, I re-created my first 5x7 font from scratch.

As it is now, this resulting ROM gets "Collapse OS>" to be displayed on the
LCD screen. Much work still left to do.

ref #41
2019-11-07 11:52:29 -05:00
Virgil Dupras 3ef964e74d acia: make GetC blocking 2019-11-04 14:44:43 -05:00
Virgil Dupras 41338a4b23 stdio: add "Accepted characters" comment section
ref #64
2019-11-04 10:12:17 -05:00
Virgil Dupras 27149338e4 stdio: fix typo 2019-11-04 10:04:09 -05:00
Virgil Dupras 2a55bfd375 stdio: remove a layer of indirection in GetC/PutC
We use zasm's ability to use labels in .equ directive.

We didn't do it before because for a while, we were in between scas
and zasm (scas was used in automated tests) so we needed to use the
lowest common denominator: zasm doesn't have macros and scas can't
use labels in .equ directives.

This forced us to add this layer of indirection. But now that we are
completely cut from scas' dependency, we can use this nice zasm's
ability.
2019-11-04 09:55:12 -05:00
Virgil Dupras 2a513e6f57 stdio: make stdioGetC and stdioReadline blocking
ref #64.

Also, fix a bug in the shell where it would write outside the buffer's
bounds when given a completely filled buffer without a space character
in it.
2019-11-03 20:32:27 -05:00
Virgil Dupras 16bf8e28c0 Remove SHELL_LOOPHOOK
It was a bad idea and having sms/pad interact directly with sms/vdp
is much simpler.

ref #64
2019-11-03 19:13:01 -05:00
Virgil Dupras b745f49186 Rename blockdev's API routines to GetB/PutB
The goal is to avoid mixing those routines with "character devices"
(acia, vpd, kbd) which aren't block devices and have routines that
have different expectations.

This is a first step to fixing #64.
2019-10-30 16:59:35 -04:00
Clanmaster21 38333e9e07 Decimal parse optimisations (#45)
* Optimised parsing functions and other minor optimisations

UnsetZ has been reduced by a byte, and between 17 and 28 cycles saved based on branching. Since branching is based on a being 0, it shouldn't have to branch very often and so be 28 cycles saved most the time. Including the initial call, the old version was 60 cycles, so this should be nearly twice as fast. 
fmtHex has been reduced by 4 bytes and between 3 and 8 cycles based on branching.
fmtHexPair had a redundant "and" removed, saving two bytes and seven cycles.
parseHex has been reduced by 7 bytes. Due to so much branching, it's hard to say if it's faster, but it should be since it's fewer operations and now conditional returns are used which are a cycle faster than conditional jumps. I think there's more to improve here, but I haven't come up with anything yet.

* Major parsing optimisations

Totally reworked both parseDecimal and parseDecimalDigit
parseDecimalDigit no longer exists, as it could be replaced by an inline alternative in the 4 places it appeared. This saves one byte overall, as the inline version is 4 bytes, 1 byte more than a call, and removing the function saved 5 bytes. It has been reduced from between 52 and 35 cycles (35 on error, so we'd expect 52 cycles to be more common unless someone's really bad at programming) to 14 cycles, so 2-3 times faster.
parseDecimal has been reduced by a byte, and now the main loop is just about twice as fast, but with increased overhead. To put this into perspective, if we ignore error cases:
For decimals of length 1 it'll be 1.20x faster, for decimals of length 2, 1.41x faster, for length 3, 1.51x faster, for length 4, 1.57x faster, and for length 5 and above, at least 1.48x faster (even faster if there's leading zeroes or not the worst case scenario).
I believe there is still room for improvement, since the first iteration can be nearly replaced with "ld l, c" since 0*10=0, but when I tried this I could either add a zero check into the main loop, adding around 40 cycles and 10 bytes, or add 20 bytes to the overhead, and I don't think either of those options are worth it.

* Inlined parseDecimalDigit

See previous commit, and /lib/parse.asm, for details

* Fixed tabs and spacing

* Fixed tabs and spacing

* Better explanation and layout

* Corrected error in comments, and a new parseHex

5 bytes saved in parseHex, again hard to say what that does to speed, the shortest possible speed is probably a little slower but I think non-error cases should be around 9 cycles faster for decimal and 18 cycles faster for hex as there's now only two conditional returns and no compliment carries.

* Fixed the new parseHex

I accidentally did `add 0xe9` without specifying `a`

* Commented the use of daa

I made the comments surrounding my use of daa much clearer, so it isn't quite so mystical what's being done here.

* Removed skip leading zeroes, added skip first multiply

Now instead of skipping leading zeroes, the first digit is loaded directly into hl without first multiplying by 10. This means the first loop is skipped in the overhead, making the method 2-3 times faster overall, and is now faster for the more common fewer digit cases too. The number of bytes is exactly the same, and the inner loop is slightly faster too thanks to no longer needing to load a into c.
To be more precise about the speed increase over the current code, for decimals of length 1 it'll be 3.18x faster, for decimals of length 2, 2.50x faster, for length 3, 2.31x faster, for length 4, 2.22x faster, and for length 5 and above, at least 2.03x faster. In terms of cycles, this is around 100+(132*length) cycles saved per decimal.

* Fixed erroring out for all number >0x1999

I fixed the errors for numbers >0x1999, sadly it is now 6 bytes bigger, so 5 bytes larger than the original, but the speed increases should still hold.

* Fixed more errors, clearer choice of constants

* Clearer choice of constants

* Moved and indented comment about fmtHex's method

* Marked inlined parseDecimalDigit uses

* Renamed .error, removed trailing whitespace, more verbose comments.
2019-10-24 07:58:32 -04:00
Clanmaster21 cca3157c66 addHL and subHL affect flags, and are smaller (#30)
* addHL and subHL affect flags, and are smaller

Most importantly, addHL and subHL now affect the flags as you would expect from a 16 bit addition/subtraction. This seems like it'd be preferred behaviour, however I realise any code relying on it not affecting flags would break. One byte saved in addHL, and two bytes saved in subHL. Due to the branching nature of the original code, it's difficult to compare speeds, subHL is either 1 or 6 cycles faster depending on branching, and addHL is between -1 and 3 cycles faster. If the chance of a carry is 50%, addHL is expected to be a cycle faster, but for a chance of carry below 25% (so a < 0x40) this will be up to a cycle slower.

* Update core.asm

* Reworked one use of addHL

By essentially inlining both addHL and cpHLDE, 100 cycles are saved, but due to the registers not needing preserving, a byte is saved too.

* Corrected spelling error in comment

* Reworked second use of addHL

43 cycles saved, and no more addHL in critical loops. No bytes saved or used.

* Fixed tabs and spacing, and made a comment clearer.

* Clearer comments

* Adopted push/pop notation
2019-10-17 16:45:27 -04:00
Clanmaster21 9fb1467ee5 cpHLDE and writeHLinDE improvements (#33)
Pretty major improvements to both of these, cpHLDE is now 5 bytes shorter and between 9 and 12 cycles faster due to branching, and writeHLinDE is now 2 bytes shorter and 21 cycles faster.
2019-10-16 20:39:38 -04:00
Clanmaster21 6281e2036f Optimised intoXX functions (#19)
* Optimised intoXX functions

Rewrote intoXX functions to mainly rely on intoHL, as the HL instructions are smaller and faster. Also removed some redundant push and pop instructions. I edited the given unit tests to test these, and they seem to work as expected.

* Doesn't use self-modifying code

The number of bytes is the same as my previous attempt, with 11 more cycles in intoHL, so although I don't feel as clever this time it's still a good optimisation. I found an equivalent method for intoDE, however relying on intoHL still allows for  `ex (sp), hl` to be used in intoIX, which is smaller and faster.

* Update core.asm

* Tried harder to follow coding convention

Added tabs between mnemonics and operands, and replaced a new line I accidentally removed.
2019-10-10 14:44:23 -04:00
luz.paz 6a635fddd9 Fix misc. source comment typos
Found via `codespell -q 3 -S ./tools -L splitted`
2019-10-09 11:12:08 -04:00
Virgil Dupras f4b6c7637d zasm: rename #inc to .inc
scas, it's not needed any more.
2019-10-06 14:32:23 -04:00
Virgil Dupras 22f9b4f07e kbd: add keypad codes to keycode table 2019-07-25 14:22:17 -04:00
Virgil Dupras 4f6c230dc8 mmap: add MMAP_LEN parameter 2019-07-23 23:00:32 -04:00
Virgil Dupras 985d56ca5a core: preserve A in cpHLDE 2019-07-23 22:59:10 -04:00
Virgil Dupras 518f12b07f sms/vdp: clear 2 lines forward when doing LF
It allows to see much more easily where the action happens on the screen.
2019-07-22 11:03:44 -04:00
Virgil Dupras f43241a5a0 kbd: support shifted characters 2019-07-21 17:30:50 -04:00
Virgil Dupras 52e5f5b5bf kbd: simplify code 2019-07-21 16:58:16 -04:00
Virgil Dupras 77d805ea0f shell: allow cmds to be shorter than 4 chars 2019-07-21 15:57:55 -04:00
Virgil Dupras 01031a780a ed: Add 'w' command 2019-07-21 11:40:26 -04:00
Virgil Dupras 57e7b3ca05 recipes/sms/kbd: PS/2 keyboard adapter for the SMS! 2019-07-20 12:42:55 -04:00
Virgil Dupras 23354eba94 stdio: fix broken ReadC logic
Looping inside ReadC broke the shell's hook logic. We have to
return immediately when nothing is typed.
2019-07-19 14:44:47 -04:00
Virgil Dupras 253674ea05 Fix broken tests
Also, make tests run in a *BSD environment
2019-07-19 14:24:35 -04:00
Virgil Dupras eefadc3917 ed: add support for 'a' and 'i' 2019-07-14 17:35:21 -04:00
Virgil Dupras 797cbdcc95 blockdev: protect IX in routines
Sure, it's a bit slower, but it prevents a lot of hard to debug
problems. I don't have to want to remember "don't use IX if you
have any blk* calls". Let's optimize I/O later.
2019-07-14 12:17:13 -04:00
Virgil Dupras 8af1cf468c ed: add 'd' cmd 2019-07-14 10:32:28 -04:00
Virgil Dupras 3861670bcc shell: don't parse empty cmds 2019-07-13 15:34:43 -04:00