Prog8 language and compiler topic

All aspects of programming on the Commander X16.
User avatar
desertfish
Posts: 1096
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: 1096
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: 1096
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: 1096
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: 1096
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: 1096
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)
Post Reply