1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-01 23:30:56 +11:00
Commit Graph

138 Commits

Author SHA1 Message Date
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
Virgil Dupras
951dd2206d apps/ed: add the concept of "current line" 2019-07-13 15:28:44 -04:00
Virgil Dupras
921a109749 stdio: little tweaks 2019-07-13 09:28:35 -04:00
Virgil Dupras
e01ee170cb stdio: add stdioReadC
A routine to conveniently read lines from TTY. Extracted from
shell. Will be used in other places.
2019-07-13 09:19:01 -04:00
Virgil Dupras
ade9b96d14 sms/pad: make B jump to the next selection "class" 2019-07-02 16:18:00 -04:00
Virgil Dupras
162e503291 sms/vdp: properly protect AF on PutC 2019-07-02 15:54:07 -04:00
Virgil Dupras
f41508725d sms/pad: handle return properly
That is, send current chr selection, and then, send LF.
2019-07-02 15:23:28 -04:00
Virgil Dupras
9c87734499 sms/vdp: clear cursor before CR or BS
This avoids having "ghost" chr selection sticking around.
2019-07-02 15:22:14 -04:00
Virgil Dupras
2679172edf sms/vdp: implement "chrsel" hook
This allows for outputting a character selection before it's given
through GetC. That allows a pad-oriented character selection scheme.
2019-07-02 13:14:02 -04:00
Virgil Dupras
74de1c92cf sms/pad: implement character selection mechanism
Still a bit rough around the edges, but still, works rather well.
2019-07-02 13:12:52 -04:00
Virgil Dupras
748d7347c8 shell: add "loop hook"
This hook is called during every iteration, allowing regular screen
refresh when video is involved.
2019-07-02 13:11:37 -04:00
Virgil Dupras
404dbd0ddd sms/vdp: handle CR and LF 2019-07-02 11:14:16 -04:00
Virgil Dupras
2da4a3a87b sms/vdp: new module allowing PutC to spit chars in the VDP 2019-07-02 10:48:38 -04:00
Virgil Dupras
c5a0a6ff54 sms/pad: easily detect change in button config 2019-07-02 10:47:59 -04:00
Virgil Dupras
9eb80d5eac sms/pad: new module to manage Megadrive controller in SMS 2019-07-02 09:02:19 -04:00
Virgil Dupras
b7cda6ed14 shell: improve reliability
Make ASCII_BS (sent when driven through kbd) make the same thing as
ASCII_DEL. Also, don't crash on filling the buffer.
2019-06-30 13:25:14 -04:00
Virgil Dupras
ad31c7f7f5 kbd: make letters lowercase
We'll make them uppercase when we'll add support for shift.
2019-06-30 13:24:35 -04:00
Virgil Dupras
cd7743b3ae kbd: give the device a little breathing room in tight loops 2019-06-30 12:12:42 -04:00
Virgil Dupras
e44ebb08b2 recipes/rc2014/ps2: drive a shell with ps/2 kbd! 2019-06-29 14:26:03 -04:00
Virgil Dupras
9fb77054c0 Update docs w.r.t. its relationship with scas 2019-06-19 13:34:06 -04:00
Virgil Dupras
69fc2e3bf2 sdc: make sdcReadBlk return error on max retries
It previously returned success!
2019-06-19 13:22:07 -04:00
Virgil Dupras
66fbd20e21 sdc: tidy up 2019-06-19 09:24:16 -04:00
Virgil Dupras
d9ae82c81e sdc: enable CRC checks on blk write 2019-06-19 09:00:50 -04:00
Virgil Dupras
2ac16d4750 sdc: check CRC during sdcReadBlk
When there's a mismatch, retry up to a certain number of times.

This makes random problem related to assembling big kernels go away! But
it also make SD card reading much slower...
2019-06-18 22:03:48 -04:00
Virgil Dupras
cac9acca67 sdc: make some space in memory for buffer CRC 2019-06-18 15:21:58 -04:00
Virgil Dupras
34db493496 sdc: implement CRC7 computation on cmds
For now, this achieves nothing else than wasting cycles, but this is the
first step in enabling CRC verifications (CMD59).

I think that this is where my random problems with assembling large
kernels from SDC come from: bad data that isn't detected. If that
happens when PGM loads programs in memory, then anything can happen.

`sdct`, when ran often enough, will error out or corrupt away (go
crazy)...
2019-06-18 14:45:55 -04:00
Virgil Dupras
914c6d5abc Update comments 2019-06-17 13:42:53 -04:00
Virgil Dupras
00778f73e1 blockdev: fix bug recently introduced in load cmd
It would always load one byte less than told... This time it's right on
the money :)
2019-06-17 09:54:30 -04:00
Virgil Dupras
8cf9904f33 blockdev: fix load command over-loading a byte
Calling `load` would always read one more byte than specified. Also,
make `0` mean `0x100`.
2019-06-17 08:19:03 -04:00
Virgil Dupras
bd2877e012 shell: make arg in peek/poke mandatory
Also, make `0` mean `0x100`.
2019-06-17 08:18:28 -04:00
Virgil Dupras
7c23e5a9ef acia: protect DE during aciaInt
I don't know why I haven't noticed it wasn't protected. It must have
been behind many random problems I've been having...
2019-06-16 19:29:58 -04:00
Virgil Dupras
3e7d181d3c zasm: properly raise error on bas ioPutC calls 2019-06-15 20:01:17 -04:00
Virgil Dupras
4327153ffd zasm: fix include EOF detection
That was an interesting bug. It didn't cause a problem in emulation, but
in an RC2014 on an SD card, an include that didn't end with two newlines
would cause an infinite loop.
2019-06-15 15:50:27 -04:00
Virgil Dupras
92a04f4627 sdc: support 24-bit addressing
Needed if we want to compile the kernel and zasm from within a SD card.
I didn't go straight for 32-bit because it was significantly more
complex and 24-bit give us 16M. Enough to go on for a while...
2019-06-15 13:41:20 -04:00
Virgil Dupras
605c631dc0 shell: add support for backspace
It doesn't sound like much, but that backspace key is often useful...
2019-06-14 22:14:09 -04:00
Virgil Dupras
14cc2fb785 parse: fix option word default value
Previously, an optional word argument would only have its first byte set
to zero.
2019-06-14 21:10:18 -04:00
Virgil Dupras
145b48efb7 Add apps/sdct
A new app to stress test the SD card driver. Also, accompanying this
commit, changes solidifying the SD card driver so that stress tests
actually pass :)
2019-06-10 15:54:15 -04:00
Virgil Dupras
495d69c1cb sdc: make writing more solid
By not waiting until the SD card wan't busy any more after a write, we
exposed ourselves to errors if another operation was attempted right
after it.
2019-06-07 14:59:53 -04:00
Virgil Dupras
e046081900 sdc: add second buffer 2019-06-06 22:16:57 -04:00
Virgil Dupras
db24e21276 sdc: add layer of indirection to buffer system
Also, lay out the plan for adding a second buffer.
2019-06-06 15:57:32 -04:00
Virgil Dupras
fb99f4ad91 fs: grow file size on fsPutC, if appropriate 2019-06-05 16:34:14 -04:00
Virgil Dupras
fc81bce70f Fix error handling when writing to files in emulated shell 2019-06-05 16:13:15 -04:00
Virgil Dupras
2483ee699d fs: fix broken fopn on id > 0 2019-06-05 15:40:56 -04:00
Virgil Dupras
a7ce9f6fc6 pgm: adapt to recent blkdev change
With fsGetC becoming a "random address" API, it broke pgm. This commit
fixes it. To avoid adding the weight of a blkdev in pgm, I manage the
read offset directly in pgm.
2019-06-05 14:45:38 -04:00
Virgil Dupras
c18d42f08b fs: further adjust to previous blkdev refactoring
Previous refacoring broke all seek/tell within fs. fs handles now lost
the responsibility to keep track of current position. It's blkdev's job.
2019-06-04 20:45:01 -04:00
Virgil Dupras
ae028e3a86 blockdev: make implementors "random access"
This huge refactoring remove the Seek and Tell routine from blockdev
implementation requirements and change GetC and PutC's API so that they
take an address to read and write (through HL/DE) at each call.

The "PTR" approach in blockdev implementation was very redundant from
device to device and it made more sense to generalize. It's possible
that future device aren't "random access", but we'll be able to add more
device types later.

Another important change in this commit is that the "blockdev handle" is
now opaque. Previously, consumers of the API would happily call routines
directly from one of the 4 offsets. We can't do that any more. This
makes the API more solid for future improvements.

This change forced me to change a lot of things in fs, but overall,
things are now simpler. No more `FS_PTR`: the "device handle" now holds
the active pointer.

Lots, lots of changes, but it also feels a lot cleaner and solid.
2019-06-04 15:36:20 -04:00
Virgil Dupras
63473cc2e3 blockdev: make selection structure opaque
I'm about to change that structure and I don't want fs to be messed up
by this. I'm proceeding step by step...
2019-06-04 09:56:36 -04:00
Virgil Dupras
c85ed474d7 blockdev: remove _blkCall
The ability to specify "0" routines in blkdev table is not used anymore
now that stdio is a separate subsystem.

Also, I'm preparing a blockdev refactoring and this complicates my work.
2019-06-04 09:23:10 -04:00
Virgil Dupras
839ba91312 mmap: make zasm-friendly 2019-06-03 11:14:29 -04:00
Virgil Dupras
bed7032ee5 pgm: have its own file handle 2019-06-03 09:25:17 -04:00
Virgil Dupras
a48a91c8da pgm: properly pass shell args in HL 2019-06-03 08:56:39 -04:00
Virgil Dupras
21c677a950 Make parseArgs not expect a leading space 2019-06-02 14:46:07 -04:00
Virgil Dupras
f8bd8eeaaf Make userspace parse args the same way the shell does 2019-06-02 14:05:20 -04:00
Virgil Dupras
95f1a8ddaf blkdev: make load command stop and the end of the stream
This allows us to reliably and easily load a file until the end of it.
2019-06-02 11:18:06 -04:00
Virgil Dupras
73c3fc7947 shell/stdio: decouple from blkdev (again)
Move load/save to blkdev_cmds and add a new "poke" builtin shell cmd
that is the mirror of "peek" and strictly uses stdio (no blkdev
involved).

This allows us to slim the minimal OS size but, more importantly, change
the behavior of "load" so that we don't expect GetC to block until Z is
set. This way, using "load X" with X being larger than the blkdev size
won't block forever.

This also brings our RC2014 minimal kernel below the 1K mark again.
2019-06-02 11:06:38 -04:00
Virgil Dupras
5e5c7e6592 sdc: add sdcPutC
Wriiiiiite!
2019-06-01 19:53:42 -04:00
Virgil Dupras
3bc7cec03a sdc: allow the read of 0xff
That took an embarrasingly large amount of time to debug for something,
in the end, so obvious...
2019-05-31 21:33:42 -04:00
Virgil Dupras
2e8af376e3 pgm: new kernel module
The pgm module implements a shell hook so that when an unknown command
is typed, we look into the mounted filesystem and look for a file with
the same name as the command. If we find one, we load it in memory and
run it.
2019-05-31 14:54:15 -04:00
Virgil Dupras
7c191fd978 fs: standardize file handle routine argument to IX
Using HL/DE was awkward and error-prone.
2019-05-31 14:28:06 -04:00
Virgil Dupras
83771b538f fs: check for file size bounds in GetC 2019-05-31 11:12:29 -04:00
Virgil Dupras
a641a94853 sdc: make sector swapping more robust
It would previously only work when GetC-ing our way into a new sector.
Seeking into one would not work. Now it's much more robust and this
paves the way for write support.
2019-05-30 14:55:38 -04:00
Virgil Dupras
83e375936c shell: make seek cmd init DE to 0
So that blkdev not supporting 32-bit aren't messed up.
2019-05-30 14:54:28 -04:00
Virgil Dupras
328f44814e Make blockdev pointers 32 bits
This allows us to break through the 64K limit for includes CFS in zasm,
a limit we were dangerously close to breaking. In fact, this commit
makes us go over that limit. Right in time!
2019-05-28 19:42:35 -04:00
Virgil Dupras
312e95479e sdc: fix bug preventing us from reading beyond first sector 2019-05-28 13:12:08 -04:00
Virgil Dupras
8cfe834edb recipes/rc2014/sdcard: use "sdci" and blockdev rather than user prog 2019-05-28 11:01:17 -04:00
Virgil Dupras
d2c6e21c64 Fix broken shell
When I zasm-ified the shell a couple of dozens of commits ago, I
inverted push and pops...
2019-05-20 07:38:15 -04:00
Virgil Dupras
c586c0d63c Make the shell emulator be built by zasm 2019-05-20 07:29:19 -04:00
Virgil Dupras
bc1496a7e3 zasm emul: bring back kernel/user distinction
It was a bad idea to remove it. Now that I'm introducing the concept of
a per-app glue file, it becomes much easier to build emulated zasm as a
userspace app.
2019-05-19 12:57:59 -04:00
Virgil Dupras
7fad3b0c90 Move /parts/z80 to /kernel
Let go of that "meta os" thing. it's not as meta as I made it sound
like. It's a kernel.
2019-05-19 11:19:41 -04:00