100 Commits
Author SHA1 Message Date
Colin Leroy-Mira e01a608863 Mention where decompressors stats come from 2025-12-01 13:30:26 +01:00
Colin Leroy-Mira 9390e5c2ce Apple2: factorize MLI pathname setting (up to -22 bytes) 2025-11-02 21:24:59 +01:00
Colin Leroy-Mira 850accee3a Apple2: -8 bytes on rename 2025-11-02 21:24:59 +01:00
Colin Leroy-Mira 280f296952 Apple2: mutualize mli filename push (-0 to -18 bytes) 2025-11-02 21:24:59 +01:00
Colin Leroy-Mira 3b8531a422 Apple2: -5 bytes on open() 2025-11-02 21:24:59 +01:00
Colin Leroy-Mira 707e317bb8 Apple2: spare 10 bytes on I/O 2025-11-02 21:24:59 +01:00
Colin Leroy-Mira 25c1223f02 Apple2: spare 2 bytes on read 2025-11-02 21:24:59 +01:00
Colin Leroy-Mira d6dd0fa865 Document decompressors 2025-10-26 18:58:15 +01:00
Colin Leroy-Mira f3e43cc5c5 Add a 9% faster ZX02 decompressor 2025-10-26 18:53:26 +01:00
Colin Leroy-Mira 2220c6ec8d Add --warn-align-waste option to ca65, ld65, cl65 2025-10-26 16:06:08 +01:00
Colin Leroy-Mira 28442e60b8 Emit warnings for wasted bytes when aligning 2025-10-19 15:00:13 +02:00
Colin Leroy-Mira 357f64e4e3 Address Oliver's comments 2025-08-26 15:11:15 +02:00
Colin Leroy-Mira 86bcf32580 Apple2: Add file_set_type() and file_set_auxtype()
MLI wrapper to be able to update existing ProDOS
files' type and auxtype.
2025-08-26 15:11:15 +02:00
Colin Leroy-Mira 1f6cca2140 Coding style 2025-07-27 00:02:48 +02:00
Colin Leroy-Mira a0b705fd41 Remove code after inserting new one 2025-07-27 00:02:48 +02:00
Colin Leroy-Mira 0647cb1112 Merge jsr pushax/j?? popax into nothing or RTS 2025-07-27 00:02:48 +02:00
Colin Leroy-Mira 4c2cc24e77 Optimize jsr ldax0sp/incsp2 2025-07-27 00:02:18 +02:00
Colin Leroy-Mira aa936b6d12 Fix copyright 2025-07-26 23:59:02 +02:00
Colin Leroy-Miraandkugelfuhr 6d96a952fd Stricter check for incax[1-8]
Thanks to @kugelfuhr

Co-authored-by: kugelfuhr <98353208+kugelfuhr@users.noreply.github.com>
2025-07-20 18:48:58 +02:00
Colin Leroy-Mira fa1b6ed4f7 Address issues 2025-07-20 16:39:24 +02:00
Colin Leroy-Mira 095ee0b27c Merge branch 'master' into fix-pr-2778 2025-07-20 16:28:49 +02:00
Colin Leroy-Mira 8a793796d7 Coding style 2025-07-20 16:14:35 +02:00
Colin Leroy-Mira 8ba1cef550 Merge branch 'master' into Opt-ldptr1 2025-07-20 16:08:01 +02:00
Colin Leroy-Mira 2b2c082efb Fix bug in PR #2778
Don't replace incaxy like incax[1-8].
2025-07-20 14:36:30 +02:00
Colin Leroy-Mira 17b8645360 Optimize ldax?sp/sta/stx to ldptr1?sp 2025-07-20 12:24:24 +02:00
Colin Leroy-Mira 20a9db757d Optimize multiple incax* and incax*/ldaxi
- Group multiple calls to incax* and decax* into a single one
- Replace incaxN/jsr ldaxi with ldy #N+1/jsr ldaxidx

Fixes #2055
2025-07-06 20:37:01 +02:00
Colin Leroy-Mira facf7b2a0c Add basic test for incsp optimisation 2025-07-06 18:35:21 +02:00
Colin Leroy-Mira 87e5775efb Merge branch 'master' into much-smaller-strndup 2025-07-06 13:36:58 +02:00
Colin Leroy-Mira fe86149203 Further optimize inc/decsp
The optimizer can now merge incsp+decsp together, and merge
jsr incsp/decsp + jmp incsp/decsp together. Drop the code
altogether if both instructions cancel each other out.

Fixes #2748
2025-07-06 13:30:33 +02:00
Colin Leroy-Mira fb7afcfee9 Add strndup ENOMEM test 2025-07-05 12:31:26 +02:00
Colin Leroy-Mira 6604c5ce92 Make strndup smaller, safer, faster
First implementation was doing:
- strdup (without checking result!)
- strlen
- terminate
- realloc

New one does:
- malloc to shortest +1
- strncpy
- terminate
2025-07-05 12:11:40 +02:00
Colin Leroy-Mira 90e1ac374b Add strndup
char* __fastcall__ strndup (const char* S, size_t maxlen);
2025-07-03 23:46:28 +02:00
Colin Leroy-Mira fcbc253bf9 Add strlen and strnlen unit tests 2025-07-03 23:43:04 +02:00
Colin Leroy-Mira a028ac4140 Apple2: Fix permanently disabled IRQ
Regression introduced in 990d65e:
Pushing status, initializing IRQ handler (which enables IRQ)
then pulling status re-disables IRQ.
2025-06-26 21:52:15 +02:00
Colin Leroy-Mira ec0595ad28 Remove useless code
LOSCR is a valid and safe softswitch on any Apple II.
Thanks Oliver S!
2025-06-19 14:07:43 -04:00
Colin Leroy-Mira 990d65e4e4 Apple2: Setup IRQ/RST vectors in LC if needed
Programs running under DOS3.3 need to setup correct
reset and IRQ vectors in the language card.
2025-06-15 14:12:01 -04:00
Colin Leroy-Mira e3f9a5f052 Make sure pid and counter don't interfere 2025-06-14 13:02:28 +02:00
Colin Leroy-Mira 215f51a230 Fix temporary filenames again.
Outputting temp files in the output directory means we have
to distinguish source files in different source directories
that happen to have the same name.
2025-06-13 20:26:00 +02:00
Colin Leroy-Mira 149b2b69ef Use new CPU macro to optimize ntohs on 65c02 2025-06-12 19:33:54 +02:00
Colin Leroy-Mira ffd667c2c9 Fix temporary file name creation.
Use the original name as template for readability in
the map file, and use the process PID instead of platform-dependant
or deprecated random filename functions to make unique temporary
filenames. Also, create these temporary files in the output
directory.
2025-06-12 18:00:10 +02:00
Colin Leroy-Mira 0122307399 Apple2: Dynamic IIe check on a2_lo_tgi 2025-06-01 12:53:36 +02:00
Colin Leroy-Mira a9ab23ad51 Make waitvsync available on apple2 2025-06-01 12:53:36 +02:00
Colin Leroy-Mira d3ef3e1b62 Apple2: Don't depend on apple2enh definition for characters
Up, Down and Del, as well as Open-Apple, exist on
non-enhanced Apple //e.
2025-05-31 19:43:53 +02:00
Colin Leroy-Mira c75c305c59 Apple2: Fix inconsistency (use bit like everywhere else) 2025-05-31 15:43:23 +02:00
Colin Leroy-Mira d03529067a Apple2: don't define _allow_lowercase and uppercasemask on APPLE2ENH 2025-05-31 15:42:02 +02:00
Colin Leroy-Mira 89daccaa43 Apple2: automatically enable lowercase starting from //e 2025-05-31 15:42:02 +02:00
Colin Leroy-Mira f8c51ffd3d Spare a few bytes 2025-05-31 12:04:47 +02:00
Colin Leroy-Mira e444f4c40e Apple2: Safely check for 80-columns card
Check the Pascal ID bytes for an 80-columns card
to avoid blindly jumping into a $C300 that could be
totally unrelated.
2025-05-27 23:38:56 +02:00
Colin Leroy-Mira 816666615b Apple2: Make 80-columns support dynamic on apple2 target
Add a machinetype identifier to help us quickly identify
Apple //e (bit 7) and //e enhanced (bit 6).

Use it in conio functions for 80-columns code instead of
relying entirely on the __APPLE2ENH__ target.

Move videomode() to the apple2 target, and have it return
an error if 80-columns hardware is not available - this
is a lie for now, it is considered available on //e enhanced,
which may not be true, and not available on //e, which
may also be not true. An ulterior patch will make that
check correctly.

Adapt the box/line drawing characters so that one can use
MouseText on the apple2 target if it is available, by
defining DYN_DRAW_BOX. No change by default: MouseText is
considered available on apple2enh and not available on
apple2.
2025-05-27 19:03:20 +02:00
Colin Leroy-Mira cd92e4f0af Apple2: Set mousecard IRQ rate when possible 2025-05-26 14:58:13 +02:00
Colin Leroy-Mira cfbfaa559c Add ZX02 and LZSA (1,2) decompressors 2025-05-13 21:26:47 +02:00
Colin Leroy-Mira 2085646e57 Apple2: implement get_tv()
get_tv() will return TV_NTSC or TV_PAL for any Apple II model
with a way of checking vblank. For Apple ][ and ][+ it will
return TV_OTHER and let the user figure it out in another way.
2025-04-28 11:58:53 +02:00
Colin Leroy-Mira caa66aea95 Add decompress_lz4 C implementation as comment
For reference.
2025-04-07 21:01:05 +02:00
Colin Leroy-Mira fb63a839bf Optimize LZ4 decompressor
Use a walking out pointer instead of &out[written]. This
simplifies the code by 27 bytes and spares 15% cycles.
Tested with both the unit test and code uncompressing
10kB of data.

Renamed the labels for legibility.
2025-03-14 16:33:13 +01:00
Colin Leroy-Mira c8eb6e2dd5 Apple II: Document BLTU alternative 2025-03-09 16:19:42 +01:00
Colin Leroy-Mira 020fe4028a Fix RANGE ERROR STOPPED AT 8214
On a 48k Apple II, the BLTU2 call throws an error,
even when there is nothing to copy in the LC segment.

Add an alternative LC copy, based on memcpy, to an
extra file that the user can link in as with iobuf-0800.

This memcpy-based version allows our programs to run on
Integer ROM apple2. It costs 21 bytes in binary size,
plus memcpy (60 bytes in binary size + RAM use) if it
wasn't already linked in.
2025-03-06 15:55:10 +01:00
Colin Leroy-Mira 21345bd6da Fix headers 2025-01-01 14:32:07 +01:00
Colin Leroy-Mira adfb42bfa6 Rewrite rewind in assembly 2025-01-01 14:32:07 +01:00
Colin Leroy-Mira 5531320b51 Fix test_fread return value on error 2025-01-01 14:32:07 +01:00
Colin Leroy-Mira 50cccc2c3a Add lseek to sim6502 paravirt 2025-01-01 14:32:03 +01:00
Colin Leroy-Mira 852b622c43 Apple2: Don't forcefully re-enable IRQ
Avoid enabling IRQ after disabling them in driver code, remember
previous state instead (in case user had them disabled already).
2024-12-09 19:01:00 +01:00
Colin Leroy-Mira 21030c22a0 Apple2: Rewrite rewinddir() in assembly 2024-11-17 11:03:58 +01:00
Colin Leroy-Mira f663ee428d Apple2: Rewrite readdir() and closedir() to assembly 2024-11-17 11:03:58 +01:00
Colin Leroy-Mira 700c01fa8b Rename dir_file_count to dir_entry_count 2024-11-15 19:25:40 +01:00
Colin Leroy-Mira 40d9f3eed5 Apple2: Provide a way to get directory file count
The information is available in the directory key block.
Providing it to the user as soon as opendir() is done
can save them costly code.
2024-11-15 19:25:40 +01:00
Colin Leroy-Mira 819a314508 Apple2: Rewrite opendir in assembly
58 bytes size gain
2024-11-09 18:17:30 +01:00
Colin Leroy-Mira 55d3a6ea39 Optimize stpcpy's size and speed 2024-09-07 21:24:53 +02:00
Colin Leroy-Mira 622793e343 Apple II: Move _exit out of STARTUP segment 2024-08-25 22:14:45 +02:00
Colin Leroy-Mira 793aa48a49 Add doc 2024-04-19 08:13:41 +02:00
Colin Leroy-Mira a823d90082 Separated versions 2024-04-19 07:57:47 +02:00
Colin Leroy-Mira 71d82ab5d9 Use common naming scheme for tolowerdirect 2024-03-22 17:19:26 +01:00
Colin Leroy-Mira 0c681b42ef Factorize to save 20 bytes 2024-03-19 18:07:17 +01:00
Colin Leroy-Mira b5d259bafb Implement strcasestr as part of strstr 2024-03-18 19:52:04 +01:00
Colin Leroy-Mira 82165c1a77 Implement strcasestr 2024-03-18 19:51:50 +01:00
Colin Leroy-Mira 86317711e0 IIgs SCC: Rework branches to X-indexed variables
and general cleanup/commenting
2024-02-23 01:20:47 +01:00
Colin Leroy-Mira 8b71fafb84 IIgs SCC: Allow choosing 115200bps as the card allows it
Of course, that won't work full speed with the standard
IRQ-based RX. But that will allow users to setup the port
at this speed without duplicating the setup part of the
code. Up to them to add hooks to disable IRQs and read
directly in a tight asm loop.
2024-02-23 01:20:47 +01:00
Colin Leroy-Mira 3fd78208ba Disable IRQ if opening at 115200 bps 2024-02-19 19:31:47 +01:00
Colin Leroy-Mira 7a12399b39 Allow choosing 115200bps as the card allows it
Of course, that won't work full speed with the
standard IRQ-based RX. But that will allow users
to setup the port at this speed without duplicating
the setup part of the code. Up to them to add hooks
to disable IRQs and read directly in a tight asm
loop.
2024-02-19 19:31:47 +01:00
Colin Leroy-Mira 1fab179cb4 a BIT of 65C02 optimisations
Use BIT immediate instead of AND when reloading A is required
afterwards.
Add an fread unit test as the optimisation touches fread.
Sprinkle a few zero page indexed while we're at it.
2024-02-02 19:45:49 +01:00
Colin Leroy-Mira c4c6967e4a Enable Windows tests on pull requests 2024-02-02 19:45:17 +01:00
Colin Leroy-Mira 1e300bf768 Add test case for issue #2395 2024-02-01 22:06:56 +01:00
Colin Leroy-Mira ce606bb19e Fix tests... 2024-01-31 08:40:36 +01:00
Colin Leroy-Mira afd8ee627e Remove useless branching code in fgets 2024-01-30 19:52:48 +01:00
Colin Leroy-Mira 2b97735d5d Factorize file pointer check 2024-01-30 19:40:28 +01:00
Colin Leroy-Mira 1a5a7d67a7 Rewrite fputc in assembly
-36 bytes, -12% cycles
2024-01-30 17:19:13 +01:00
Colin Leroy-Mira ba36071022 Rewrite fputs in assembly
-28 bytes, -1% cycles
2024-01-30 17:12:52 +01:00
Colin Leroy-Mira 7594af553a Fix #2388
Reopen stdin in binary mode instead of closing/opening
2024-01-30 09:39:44 +01:00
Colin Leroy-Mira 7d7cf2d1e0 Implement aslax7/shlax7/asrax7/shrax7 2024-01-29 07:59:11 +01:00
Colin Leroy-Mira 0dd7b0c3a5 Implement __sysremove for sim65
This will allow using unlink()/remove() in sim65 programs
Use it to unlink fgets' test output file
2024-01-28 13:58:57 +01:00
Colin Leroy-Mira aa6f850b8d Rewrite gets in assembler
+19 bytes if used alone, because it pulls in fgets, but as code is
factorized, -128 bytes in programs using both fgets and gets.
2024-01-26 20:29:17 +01:00
Colin Leroy-Mira a8b870555e Rewrite realloc in asm
-80 bytes, -39% cycles
2024-01-26 20:25:59 +01:00
Colin Leroy-Mira 476591e8b7 Rewrite fgetc in asm
-82 bytes, -20% cycles
2024-01-25 09:13:39 +01:00
Colin Leroy-Mira f7388cfb79 add fgets/fgetc test 2024-01-25 09:13:35 +01:00
Colin Leroy-Mira f0b5b02966 Swap in LC before destructors, ROM after 2024-01-24 12:28:57 +01:00
Colin Leroy-Mira b87df9e1c6 Optimize -36 bytes out of posix_memalign
And add a unit test
2024-01-24 10:23:53 +01:00
Colin Leroy-Mira 1f820d0ae8 Rewrite fgets in asm
-104 bytes, -1% cycles
2024-01-24 10:16:26 +01:00
Colin Leroy-Mira 5d49fde788 add a return -1 helper 2024-01-24 09:58:09 +01:00
Colin Leroy-Mira 3e01ac9b04 Fix malloc and realloc overflow
If user requests a size >= 65532, adding the heap admin size
overflows size. Fixes #2358.
2024-01-24 09:54:54 +01:00
Colin Leroy-Mira 2ba176372e Add beep for apple2 2024-01-23 23:04:50 +01:00
Colin Leroy-Mira 01ee903cdf Fixup gmtime/localtime/mktime tests with all cases 2024-01-22 16:38:39 +01:00