Prog8 language and compiler topic

All aspects of programming on the Commander X16.
User avatar
desertfish
Posts: 1123
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Important Prog8 version 10.4 released

Post by desertfish »

:idea: Prog8 version 10.4 has been released!

https://github.com/irmen/prog8/releases/tag/v10.4

Breaking changes:
  • moved non X16 specific variables and vector definitions from cx16 to cbm namespace. This makes them consistent with the other cbm targets (c64, pet32 etc). Most notably perhaps, cx16.CINV (the IRQ vector) has been renamed to cbm.CINV
  • sprites.get_data_ptr() signature changed: now properly returns the 2 values
  • removed various builtin functions: sort, reverse, any, all. The last 2 now are available as regular functions in the new anyall library module.
  • diskio.f_readline() now also returns I/O status as secondary return value in A
  • corrected cx16.fetch() signature
Other:
  • added kata: string encoding (Katakana)
  • added string.rfind() function to search for a character starting from the end of the string
  • added new cx16 polling sample streaming example (not using AFLOW irq). Look in examples/cx16/pcmaudio/
  • added "queens" example (queens on chessboard problem solver / benchmark)
  • added cx16.rom_version() routine
  • fixed atan2 routine
  • fixed a problem in gfx2 4 color mode
  • performance of gfx2.fill() routine greatly improved in both 256 and 4 color modes
  • improved checks for negative array indexing
  • fixed syslib problems for raw output
  • added experimental buffers library module that provides some buffer data structure routines (subject to change!)
  • multiple code generation optimizations, also use certain 65C02 instructions more for more efficient code
  • various bugfixes.
Thanks to various contributors on the X16 discord!
User avatar
desertfish
Posts: 1123
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Important Prog8 version 10.4.1 released

Post by desertfish »

:idea: Prog8 version 10.4.1 has been released: https://github.com/irmen/prog8/releases/tag/v10.4.1

This is a patch release that brings a bunch of optimizations and small tweaks.

Breaking Changes:
  • sprite.hide() behavior change: no longer moves sprite off-screen but changes the priority to disabled.
  • (subtle) the compile time const calculations have been tweaked a bit to avoid precision loss in some cases. It could mean that your code suddenly needs an extra typecast here and there (compiler will complain)
Other changes:
  • compiler option -nostrictbool has been removed. All code using bools now has to adhere to the stricter type checks (that have been the default for quite some time already)
  • subroutines do no longer have to end with a newline, so you can now write certain oneliners if you really want
  • graphics module on the X16 now uses the new rom R48 routines to draw circles and ovals
  • added new example program cx16/life.p8 (conway's game of life)
  • X16: added cx16.mouse_present() routine to check if a mouse is connected or not
  • X16: added emudbg.cpu_cycles() and emudbg.reset_cpu_cycles() which allow for some detailed performance counters when running on the X16 emulator
  • X16: added new rom R48 extapi definition cx16.EXTAPI_kbd_leds to control the keyboard leds
  • X16: added new gfx_lores module that contains heavily optimized graphics routines for 320*240 256color (8bpp) screen mode. (much faster than gfx2)
  • X16 and C64: added floats.time() routine to get the value of the jiffy clock as a single float value.
  • all the disc graphics routines (that draw filled circles) have been optimized to no longer draw some parts multiple times.
  • it's now actually possible to multi-assign multiple return status flags from asmsubs.
  • the compiler now actually uses @zp, @requirezp etc tags you put on subroutine parameters. Previously, those were silently ignored.
  • several code gen improvements
  • several bugfixes.
Once again, thanks to the various people in the X16 discord that contributed or tested stuff!

If you'd like to buy me a hot coffee or spicy pizza, to keep this project going, you can do so at https://ko-fi.com/irmen Thanks a lot!
User avatar
desertfish
Posts: 1123
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: Prog8 language and compiler topic

Post by desertfish »

There's a known issue with certain asm routines such as floats.ceil() that generate invalid code. This has been fixed in the master branch already, but was found too late to be part of the 10.4.1 release, unfortunately.
User avatar
desertfish
Posts: 1123
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Important Prog8 version 10.4.2 released

Post by desertfish »

:arrow: Prog8 version 10.4.2 has been released: https://github.com/irmen/prog8/releases/tag/v10.4.2

It contains a couple of important bug fixes.
There are also a few new library modules and a few new examples.

This release fixes some bugs and improves some things, and adds some new library modules and exampoles, but no major language changes.

breaking changes
  • removed the broken `verafx.mult` routine (verafx doesn't support unsigned multiplications. The muls routine is still there, that one works fine)
  • added `verafx.mult16` for just the 16 bit unsigned results that worked fine.
  • string assignments got somewhat stricter to avoid problematic cases. If your code doesn't compile anymore, you should use `string.copy` explicitly now to set a new value to a string.
other changes
  • fixed assembly optimization bug that removed a RTS sometimes. This broke `floats.ceil` and some other routines.
  • fixed "raw" output to also properly initialize variables.
  • fixed C64 floating point sign problem
  • added experimental `compression` library, it provides RLE compression and decompression routines. (the RLE algorithm supported is Byterun1/Packbits, which is used in Amiga IFF ILBM images among others)
  • cx16: added `audio` module with subroutines to simplify calling the Audio routines in the kernal. The 'audioroutines' example has been updated to use this.
  • cx16: kernal bank 0 is once again activated at startup to speed up kernal calls
  • cx16: added `callfar2` builtin function that allows you to set A,X,Y and Carry parameters instead of only AY.
  • cx16: added color fade routines to the `palette` module
  • cx16: added a port of the c64's "balloonflight" example. Added 'starszoom' example.
  • added `sys.sizeof_byte` etc etc constants that are the memory sizes of the given datatypes
  • many code optimizations
  • several error message improvements.
  • documentation improvements.
  • added 'fractal-tree' example.
Thanks to the people in the Prog8 channel on the X16 discord for their contributions.
User avatar
desertfish
Posts: 1123
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Important prog8 version 10.5 released

Post by desertfish »

:!: Prog8 version 10.5 has been released: https://github.com/irmen/prog8/releases/tag/v10.5

Documentation at https://prog8.readthedocs.io/en/latest/

This is a substantial release with many new things and various things that are not backwards compatible, so please read the release notes carefully:

Breaking changes:
  • the compiler is now named 'prog8c' and the jar file accordingly 'prog8-10.5-all.jar'
  • ``gfx2`` module is gone, it's split into ``gfx_lores`` and ``gfx_hires4`` optimized for a single resolution each.
    the ``width`` and ``height`` symbols were renamed to ``WIDTH`` and ``HEIGHT`` (constants)
    and the screen_mode routine is now called ``graphics_mode``.
  • arrays can no longer be initialized with a single numerical value, it is now required to write out the full initialization array. Or omit it as before to get an array of all zeros. However there is a new syntax to create array literals with repeated values, see below at New Stuff
  • array to array assignments is no longer supported (other than initialization of variable declaration).
    Just use an explicit sys.memcopy(src, dest, sizeof(dest)) or assign array elements individually.
  • removed block level memory alignment via ``%option align`` you now have to use the new ``@align`` tags on individual variables
  • asmsubs no longer get an RTS instruction inserted at the end if it is missing. Make sure you correctly return from assembly routines.
  • the ``math`` module is no longer automatically imported in your program. If you use it you'll need to add %import math
  • ``romsub`` keyword renamed into ``extsub`` (because it's not only for ROM routines)
  • on the C64, the BASIC ROM at $a000-$bfff is now banked out by default. Prog8 programs have a whopping ~50 Kb of contiguous RAM at their disposal ($0801 - $cfff) without having to do memory banking by themselves.
  • on the C128, the BASIC ROM at $4000-$bfff is now banked out by default. Prog8 programs can now use ~41 Kb of contiguous RAM ($1c00-$bfff) without having to do memory banking by themselves.
  • program bootstrap code has been moved from the end to the beginning of the program. This shifts up the actual address of the start() routine.
New stuff:
  • automatic support for calling routines in banked memory, via ``@bank`` tag on extsub definitions (formerly romsub). This makes Prog8 the first language on the Commander X16 at least, where you no longer have to manually switch banks when calling routines in another memory bank. This is supported on the X16, C64 and the C128.
  • added routines for manual memory banking on the C64 ``c64.banks`` and ``c64.getbanks`` including an example program
  • added routines for manual memory banking on the C128 ``c128.banks`` and ``c128.getbanks``
  • ``defer`` statement for delayed execution (useful for resource cleanups for example). Inspired by the defer statement from Zig, Go, or Swift.
  • if-expression (prog8's alternative for a ternary operator): ``result = if x>10 "yes" else "no"`` It's like an if statement but it is an expression. The if and else parts are also expressions.
  • per-variable memory alignment via ``@alignword`` ``@alignpage`` and ``@align64``
  • new directive ``%align <interval>`` inserts a memory alignment command for the assembler at that precise place
  • new directive ``%memtop <address>`` changes the expected max memory location the program is going to use. Can be used to "reserve" a bunch of memory at the end of the available space.
  • ``alias`` statement that aliases a symbol (possibly from another module) by another name locally. Can shorten/clarify code.
  • added ``sys.memcmp`` memory comparison routine (like strcmp, but doesn't stop at 0 byte)
  • the way block merging is done using ``%option merge`` has been overhauled. You can now monkeypatch existing code if you merge in subroutines with an exactly matching signature including the names of the parameters.
  • added a few new graphics routines in the ``gfx_lores`` and ``gfx_hires4`` modules (formerly ``gfx2``). gfx_lores now has a draw mode selection and can draw in EOR mode, useful for non destructive drawing
  • added ``diskio.exists`` to check if a file is already present
  • added linear interpolation routines ``math.lerp`` and ``floats.lerp`` and ``floats.lerp_fast``
  • replaced the old ZSOUND example by the new ZSMKIT example that plays .zsm music on the Commander X16.
  • floats: added ``AYINT2`` as a safe wrapper around ``AYINT`` (used to convert floats to integers). The new routine no longer depends on internal kernal variable locations and should always be used over AYINT.
  • added experimental ``neo`` compiler target (for the Neo6502). Still pretty bare bones but functional
  • variables can now be marked ``@dirty`` to omit initialization of their value. This saves code, but leaves their initial value undefined which is a dangerous footgun, so beware when using this that you properly assign a value to them yourself
  • array literals with repeated values can now be created using the similar syntax as what was already possible for string literals, type the base array and add ``* <repeats>``. For example ``[42] * 99`` creates an array of 99 times the value 42. That base array can consist of multiple values.
Other changes:

- optimizations and bug fixes, as usual.
User avatar
desertfish
Posts: 1123
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

version 10.5.1 released

Post by desertfish »

:!: Prog8 Version 10.5.1 has been released https://github.com/irmen/prog8/releases/tag/v10.5.1

documentation is here https://prog8.readthedocs.io/en/latest/

Changes:
  • gfx_hires4 module is now named gfx_hires to be consistent with the gfx_lores module
  • added sprites.reset() routine to remove sprites from the screen
  • progstart() was added to complement progend()
  • repeat now supports 65536 iterations
  • defer can now also be used inside if-statements (the semantics don't change though)
  • %memtop now specifies the first address NOT to use, to reflect the semantics of the memtop kernal call
  • memtop now automatically adjusts when you use %address beyond the default
  • documentation improvements
  • assembly optimization regression fixed that was caused by wrong label prefixing
  • fix several compiler crashes
  • math.mul16_last_upper() is fixed again
  • internal diskio library restructuring (shouldn't be noticeable for user code)
User avatar
desertfish
Posts: 1123
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Prog8 version 11.0 has been released

Post by desertfish »

This is Prog8 version **11.0** - just in time for a nice Christmas present!

https://github.com/irmen/prog8/releases/tag/v11.0

documentation is here https://prog8.readthedocs.io/

It is a new major compiler version because some fundamental things have changed and many new features have been added since version 10.


# Breaking changes

- the `string` module has been renamed to `strings` to be more consistent with others
- removed the `anyall` module. It was inefficient and didn't work correctly
- `romsub` keyword has been removed, `extsub` is now the only recognized way
- the `-addmissingrts` compiler flag has been removed. No sudden RTS instructions will be inserted in your code. You have to take care that your assembly routines contain one to properly return to their caller.
- removed `txt.VERA_TEXTMATRIX_BANK` and `txt.VERA_TEXTMATRIX_ADDR`, it's now just `txt.VERA_TEXTMATRIX` (a long const, see below at new language features)
- the sort order of blocks has been changed: blocks with addresses are now sorted *last*
- word arrays are now split by default. To store them in the old sequential memory layout, you can use `@nosplit`.
- the `-splitarrays` compiler option was changed to `-dontsplitarrays` and the purpose was inverted accordingly.
- `cx16.set_screen_mode` no longer returns anything. No need to use void anymore. You can still use the actual kernal routine if you are interested in the return status values.
- `math.crc32` now returns the crc32 value according to the ISO-HDLC standard, which is what zlib/pkzip also uses
- `sys.sizeof_xxx` are renamed to `sys.SIZEOF_XXX` for consistency


# New language features

- you can now define `const long` numbers (that can hold values larger than a word). You can use them in compile time expressions. But there are no long variables yet so the result of such expressions that need to be placed in a variable still has to fit in a byte or word.
- new `msw` and `lsw` builtin functions (similar to the existing lsb and msb) that return the most and least significant words of a value, respectively. Handy with const long values to be able to put them into word variables.
The `msw` result can also be used as the ram/rom bank byte! (as long as the address put in is within 24 bits)
- the `extsub` address can now be an expression, handy to define jump tables with offsets. Combine this with the `@bank` support for extra smooth external library routine integration.
- normal subroutines can now also take their arguments in R0-R15 'registers' similarly as asmsubs already could. This is a footgun however! Use wisely!
- `palette.set_monochrome()` has been removed
- added a start color index parameter to several routines in the `palette` module so you can now modify other parts of the color palette instead of only from color 0 onwards
- boolean variables, including boolean arrays, can now be memory mapped too.
- `goto` can now jump to a calculated address using any expression instead of just a constant number or identifier
- new operators `&<` and `&>` to get the address of the LSB and MSB sub-arrays of a split word array, respectively.


# New or improved library functions

- the zsmkit music player example has been extended with the new zsmkit V2.4 library version. This version is much easier to integrate in prog8 programs
- added several float limits contants such as floats.EPSILON, floats.E
- added sys.MIN_FLOAT, sys.MAX_FLOAT, and the MIN/MAX values for the integer types as well
- added `floats.interpolate` and `math.interpolate` to complement the existing LERP routines. Added `interpolation` example that shows how to use this
- added several decompression routines to the `compression` library: for RLE, ZX0 and TSCrunch compressed data.
- improved `buffers` library and now documented
- added `sorting` library to sort bytes, words, and string arrays.
- all flood fill graphics routines (in monogfx, gfx_lores, gfx_hires) now no longer fail to fill certain areas because their out of stack memory problem is fixed (by using the much larger stack from the buffers library)
- in `diskio`, the IO channels are now always reset back to their defaults (screen/keyboard) so that you don't have to do this yourself when you want to read or write stuff to the screen while a file is open.
- the `palette` module has been optimized to be a lot faster and smaller
- added `palette.set_rgb_nosplit()` and `set_rgb_be_nosplit()` to support passing of `@nosplit` color arrays.
(the existing routines were modified to work on `@split` arrays which are now the default storage format for word arrays)
- added `sprits.pos_batch_nosplit` to allow passing `@nosplit` x/y arrays. The existing pos_batch routine now expects `@split` word arrays because that is the default
- added `diskio.get_loadaddress` to retrieve the load address of a PRG file (= the first 2 bytes)
- added `math.crc32_end_result` to more naturally retrieve the resulting low and high words of the crc32 result.

# Other changes

- a problem with diskio was fixed that triggered a bug in the Vice C64 emulator when running on host fs where half of the data disappeared
- value range checking has been improved
- documentation has been overhauled, redundant syntax chapter merged with the rest
- new compiler options `-plain` to remove ansi escapes from the output, and `-ignorefootguns` to well... ignore the footgun problems
- new `coroutines` example that shows possible multitasking
- various code generation improvements to create smaller and faster code
- big internal compiler change to make the type system more versatile for future changes
- bugfixes
mortarm
Posts: 320
Joined: Tue May 16, 2023 6:21 pm

Re: Prog8 language and compiler topic

Post by mortarm »

What's a "footgun"?
User avatar
ahenry3068
Posts: 1194
Joined: Tue Apr 04, 2023 9:57 pm

Re: Prog8 language and compiler topic

Post by ahenry3068 »

mortarm wrote: Fri Dec 27, 2024 10:03 pm What's a "footgun"?
Something you Shoot yourself in the Foot with. Shooting yourself in the foot is a figure of speech for making a kind of stupid mistake.
mortarm
Posts: 320
Joined: Tue May 16, 2023 6:21 pm

Re: Prog8 language and compiler topic

Post by mortarm »

ahenry3068 wrote: Fri Dec 27, 2024 11:19 pm Something you Shoot yourself in the Foot with. Shooting yourself in the foot is a figure of speech for making a kind of stupid mistake.
Somehow, I expected an answer of a higher caliber. :)
Post Reply