Commit Graph

3337 Commits

Author SHA1 Message Date
Irmen de Jong
0247fb0d84 some ast2 var tweaks 2024-10-21 00:20:54 +02:00
Irmen de Jong
6de760885f fix defer push/pop typecasting issues 2024-10-19 21:45:49 +02:00
Irmen de Jong
9851d14fb9 added if expression: ubyte a = if b>0 44 else 55
it doesn't generate the best code yet, like regular ifs do.
2024-10-19 15:34:04 +02:00
Irmen de Jong
a40d120f2a more defer sanity checks 2024-10-18 22:32:49 +02:00
Irmen de Jong
fcdd9414d9 fix defer interfering with return value, fix prefix expression error when operand is functioncall that doesn't return a value. 2024-10-18 21:43:09 +02:00
Irmen de Jong
2a52241f1c defer is now done *after* calculating a return value 2024-10-18 20:56:27 +02:00
Irmen de Jong
d8f1822c12 fixes 2024-10-18 20:32:46 +02:00
Irmen de Jong
ce7d094adb Zig-like "defer" to clean up stuff when leaving the scope of the current routine. 2024-10-18 01:30:20 +02:00
Irmen de Jong
a0cf1889a3 omit more redundant 0-initializations ("stz's") 2024-10-17 22:51:39 +02:00
Irmen de Jong
38ef394e15 IR codegen: global vars with numeric initialization value are now also put into the VARIABLESWITHINIT section rather than requiring explicit code instructions to initialize them in INITGLOBALS.
Note that something similar, such as putting those variables inline in the program initialized with their value and all, cannot be done for the 6502 codegen: the program needs a mechanism to reset ALL variables when it runs a second time.
2024-10-16 22:15:51 +02:00
Irmen de Jong
abbf7c7cb0 compiler name change: prog8c (was p8compile)
fat jar file also changed:  prog8c-X.Y-all.jar    (was: prog8compiler-X.Y-all.jar)
2024-10-16 18:36:19 +02:00
Irmen de Jong
ca5f7ae32f global (block-level) variables that get initialized with an array index expression now get a constant value as well if possible. This reduces the number of instructions in the init globals code block 2024-10-16 02:14:19 +02:00
Irmen de Jong
65ddcf91d0 remove unused syscalls 2024-10-15 18:24:55 +02:00
Irmen de Jong
5280e1b449 err msgs 2024-10-13 21:33:13 +02:00
Irmen de Jong
e9edffa9f0 remove support for array-to-array assignments (other than initialization of variable declaration)
Just use an explicit sys.memcopy(src, dest, sizeof(dest))  or assign array members individually.
2024-10-13 20:02:43 +02:00
Irmen de Jong
aef211e5f3 stricter array literal element type handling (number,bool,address-of).
More consistent implicit address-of handling if array literals contain by-ref identifiers (such as subroutine names)
2024-10-13 17:46:41 +02:00
Irmen de Jong
66829203d8 New [x]*42 syntax to create array literals with repeated values (like "abc"*10 already exists for strings)
Should be used in place of array initializer expressions that contain only a single numeric value to initialize the whole array with. That isn't supported anymore.
2024-10-13 05:16:08 +02:00
Irmen de Jong
7a0eaf3148 Remove array initialization by single value.
New compiler and kotlin version.
2024-10-13 04:31:56 +02:00
Irmen de Jong
03412cacba added examples/cx16/balloonflight.p8 2024-10-13 00:51:07 +02:00
Irmen de Jong
fb23452383 optimize monogfx.fill() 2024-10-12 17:18:00 +02:00
Irmen de Jong
ab7dde1450 todo 2024-10-12 13:04:19 +02:00
Irmen de Jong
8d9bc2f5ff fixing all sorts of things about assigning arrays to arrays 2024-10-12 12:33:46 +02:00
Irmen de Jong
7651ccc84e fix a type error 2024-10-11 00:50:05 +02:00
Irmen de Jong
1a6b95b388 house cleaning 2024-10-10 20:46:18 +02:00
Irmen de Jong
7e38d26c33 added several color fade functions to the palette module (cx16) 2024-10-09 21:48:04 +02:00
Irmen de Jong
ed09dd4e9e improve automatic type conversions for return values, fixes #155 2024-10-09 20:04:05 +02:00
Irmen de Jong
5731b79554 don't allow problematic string and array assignments anymore, improve error messages.
In certain cases you will need to use string.copy() explicitly to overwrite strings with new strings.
2024-10-09 00:51:05 +02:00
Irmen de Jong
b2bdfe8482 fix ir rndseed() 2024-10-08 20:40:00 +02:00
Irmen de Jong
fea531be9a add sys.sizeof_bool, _ubyte, _uword constants 2024-10-07 20:45:13 +02:00
Irmen de Jong
7c69d38588 scan all asmsubs to see if another subroutine is referenced. Fixes #153 2024-10-07 20:39:49 +02:00
Irmen de Jong
a088ee56b0 function inlining can no longer get into an infinite loop. Fixes #154 2024-10-07 19:58:04 +02:00
Irmen de Jong
ae669af904 add sys.sizeof_byte, _word, _float constants
because Antlr doesn't allow the grammar to contain a sizeof(typename) rule to override the sizeof(identifier) rule
2024-10-07 19:17:37 +02:00
Irmen de Jong
d1ddf05e38 check that block address leaves room for program startup logic 2024-10-03 22:30:06 +02:00
Irmen de Jong
51279a98b3 attempt to fix forloop range datatype issues 2024-10-03 21:12:31 +02:00
Irmen de Jong
bf33a4f82d small refactor to prepare for better range dt adjustment 2024-10-02 23:28:33 +02:00
Irmen de Jong
fff0d741c3 improved parsing of "not in" operator, and [] array signature (allow space) 2024-10-02 19:06:20 +02:00
Irmen de Jong
09f3eecf56 changed cx16/rotating-stars example to starszoom instead. 2024-10-02 01:36:54 +02:00
Irmen de Jong
2bd4326ff6 added cx16/rotating-stars example 2024-10-01 23:43:50 +02:00
Irmen de Jong
c13168b60c various improvements:
fix verafx.available().
added gfx_lores.plot().
faster gfx_lores.clear_screen().
added a new Sublime Text 4 syntax highlighting file.
2024-10-01 22:18:03 +02:00
Irmen de Jong
ea3871d0c4 comment about builtin function call ast node type 2024-10-01 02:14:31 +02:00
Irmen de Jong
413b86cc4a more helpful error messages 2024-09-30 00:27:29 +02:00
Irmen de Jong
a064ade1e0 better codegen for call() function 2024-09-29 23:18:51 +02:00
Irmen de Jong
df35aa7942 added (experimental) compression library 2024-09-29 18:59:53 +02:00
Irmen de Jong
cd49c5f88d cx16: set rom bank to 0 at startup (for faster kernal API calls)
cx16: callfar() with constant address generates shorter asm
2024-09-28 20:58:29 +02:00
Irmen de Jong
1541ad2160 fix variable init order mistake in program startup
reset multiply bit at end of verafx.muls
2024-09-28 19:17:45 +02:00
Irmen de Jong
c78b7b1a24 added verafx.mult16() 2024-09-28 01:00:28 +02:00
Irmen de Jong
9c7a645e18 remove non-functional verafx.mult(). note: muls() is still there and just fine!
added documentation/source code comments to the cpu word*word multiplication routine not producing the correct upper 16 bits.
2024-09-28 00:43:05 +02:00
Irmen de Jong
3f630ab1b0 RAW output now also properly initializes variables 2024-09-27 18:46:03 +02:00
Irmen de Jong
04cb684fd4 tweak program start initialization and fix cleanup at exit for atari and pet compiler targets 2024-09-27 02:14:54 +02:00
Irmen de Jong
4c843571ea fix syntax error check for missing return statement 2024-09-26 01:52:33 +02:00
Irmen de Jong
b7ebd8c4a6 update cx16/audioroutines example to use the new audio module 2024-09-26 00:08:25 +02:00
markjreed
24e0a69480
feat: module with front-ends that jsrfar into audio ROM routines (#151) 2024-09-26 00:00:42 +02:00
Irmen de Jong
e29ff1c848 fix name redefinition check for multi-declarations 2024-09-20 19:55:32 +02:00
Irmen de Jong
46b94c17d6 comment 2024-09-20 17:33:00 +02:00
markjreed
16a2b2f566
Add 24-bit integer-to-float routine and floating-point jiffy clock reader (#150)
* feat: add routine to convert 24-bit integer from A/X/Y to float in FAC1

* fix: remove duplicate definition

* fix: shift to appropriate exponent
2024-09-20 17:28:37 +02:00
Irmen de Jong
5cda750e5e improve error message for undefined symbol in when choices 2024-09-18 23:00:03 +02:00
Irmen de Jong
4e143d45c8 fix warning 2024-09-18 22:04:25 +02:00
Irmen de Jong
2954f5f04d Add clear_screen and set_screen_mode to gfx_lores. Fix boolean draw vs color param in some monogfx routines. Elaborate some docs. 2024-09-17 22:19:47 +02:00
Irmen de Jong
0b1f30d98c no more span overdraws in graphics disc routines 2024-09-15 15:38:33 +02:00
Irmen de Jong
c7b1e8d772 fixed a variable scopedname issue where it took the fully scoped name instead of just the local name
this made 64tass not strip out that code if it was unused
2024-09-14 23:17:26 +02:00
Irmen de Jong
0d3ad80659 retain type of consts better to avoid precision loss
this also fixed a difference in const calculation where the result could differ if you were using optimzations or not.
2024-09-14 21:06:21 +02:00
Irmen de Jong
aba1a73e28 actually use any @zp etc tags on subroutine parameters 2024-09-14 17:42:13 +02:00
Irmen de Jong
dca31b2ca3 added gfx_lores module for cx16 for optimized graphics routines for lores 256c screen mode
currently contains a new line() routine
2024-09-14 15:30:39 +02:00
Irmen de Jong
0cb378ca31 added emudbg.cpu_cycles() and emudbg.reset_cpu_cycles() 2024-09-13 23:03:14 +02:00
Irmen de Jong
cf551d2cc7 tweak containment check even more 2024-09-13 00:02:26 +02:00
Irmen de Jong
6be6eb2227 tweak diskio to not always include unused subroutine internal_f_tell() in resulting program 2024-09-11 19:51:53 +02:00
Irmen de Jong
d34015eec5 fix gfx2.fill() vera CTRL corruption 2024-09-11 19:10:45 +02:00
Irmen de Jong
255c5bfaca improve containment check for few values 2024-09-11 03:24:30 +02:00
Irmen de Jong
01c6754928 get rid of problematic common-subexpression optimization 2024-09-11 01:10:42 +02:00
Irmen de Jong
4a2dcd20d1 fix the "x<2" optimization made a few commits ago to only work on unsigned 2024-09-09 23:06:36 +02:00
Irmen de Jong
4e98fb75d6 support assigning multiple return flags from asmsub in 6502 codegen 2024-09-09 22:56:40 +02:00
Irmen de Jong
7aec627f6b add optimization if x==0 or x==1 -> if x<2 2024-09-08 22:39:48 +02:00
Irmen de Jong
edc5a5a94f improve data driven unit tests to use kotest withData() 2024-09-08 16:55:08 +02:00
Irmen de Jong
c5b7edad82 added memsizer unit tests 2024-09-08 15:24:47 +02:00
Irmen de Jong
6d2a36fb2b testcase improvement 2024-09-06 22:51:26 +02:00
Irmen de Jong
28b43b3e1d added cx16.EXTAPI_kbd_leds definition (new in kernal R48) 2024-09-06 20:47:49 +02:00
Irmen de Jong
f7feaf158d added cx16.mouse_present() routine to check for presence of mouse 2024-09-06 18:21:13 +02:00
Irmen de Jong
0eac04c220 added cx16/life.p8 example (Conway's game of life) 2024-09-06 15:21:29 +02:00
Irmen de Jong
29dd758302 Fix compiler crash in for loops with just 1 iteration 2024-09-05 21:26:46 +02:00
Irmen de Jong
5c45adc7f0 graphics module on x16 now uses kernal (R48 or newer) support for drawing circles and ovals 2024-09-05 20:27:12 +02:00
Irmen de Jong
2c2ae64194 replace java Stack by kotlin ArrayDeque 2024-09-02 00:15:28 +02:00
Irmen de Jong
b36e1e3baf change sprite.hide() : now disables sprite instead of moving it offscreen.
added sprite.show() to re-enable it (with z-order 3, as all sprites have by default in this module)
added sprite.zdepth() to set a custom z-depth.
2024-09-01 20:55:43 +02:00
Irmen de Jong
2da35fec17 remove requirement to end subroutine with an EOL, so oneliners are now possible
main { sub start() { cx16.r0++ cx16.r1++ } }
2024-09-01 20:55:43 +02:00
Irmen de Jong
bdeac74cfc removed the -nostrictbool compiler option
boolean types and bytes are no longer implicitly interchangeable using this option
2024-09-01 20:53:39 +02:00
Irmen de Jong
31cf76042d scope 2024-08-25 15:28:45 +02:00
Irmen de Jong
c4c4dcf2b3 optimizing gfx2.fill() 4 color mode 2024-08-25 15:05:24 +02:00
Irmen de Jong
03145630f8 optimizing gfx2.fill() 2024-08-25 14:26:49 +02:00
Irmen de Jong
e2fcac322f optimizing gfx2.fill() 2024-08-25 13:51:01 +02:00
Irmen de Jong
beaff4d650 moved non X16 specific variables and vector definitions from cx16 to cbm namespace.
This makes the naming consistent with the other cbm-like targets (c64, pet, c128). Only the x16 specific ones remain in the cx16 namespace, such as cx16.KEYHDL

Probably the most impactful is the move of cx16.CINV to cbm.CINV
2024-08-24 20:06:50 +02:00
Irmen de Jong
e439720c9d optimized string compares 2024-08-24 14:53:18 +02:00
Irmen de Jong
48d0185ea4 increase flood fill stack size a bit 2024-08-23 20:55:30 +02:00
Irmen de Jong
e2592b4e0b fix possible gfx2 color problem in 2bpp mode 2024-08-23 19:48:23 +02:00
Irmen de Jong
2967866e3d avoid self-modifying code to be compatible with IRQ handlers 2024-08-23 17:46:23 +02:00
Irmen de Jong
b566ea5c3f added string.rfind() 2024-08-22 23:22:31 +02:00
Irmen de Jong
8f6eaeac2c half width katakana conversion 2024-08-21 18:51:34 +02:00
Irmen de Jong
b4facaeb3c add "kata" string encoding (Katakana) 2024-08-20 21:40:43 +02:00
Irmen de Jong
d12b7ccc6b fix syslib importing for raw outputs. fixes #144 2024-08-19 13:33:02 +02:00
Irmen de Jong
453e8bd0a0 update kotlin and antlr libs 2024-08-19 12:47:18 +02:00
Irmen de Jong
9204d390ae correct fetch() signature. fixes #148 2024-08-18 20:04:23 +02:00
Irmen de Jong
0ec719e429 cx16: added a polling pcm streaming example 2024-07-23 21:37:11 +02:00
Irmen de Jong
17f7b11148 tweaks cx16 sample streaming example, also added a new one 2024-07-23 02:10:05 +02:00
Irmen de Jong
966b017670 tweaks 2024-07-22 18:20:01 +02:00
Irmen de Jong
0af17cdc33 todo's for division optimizations 2024-07-21 20:32:03 +02:00
Irmen de Jong
2aae1f5e30 stricter checks for negative array indexing 2024-07-20 22:37:03 +02:00
Irmen de Jong
9046fe8d3a ringbuffer and pointer optimization todo 2024-07-16 22:59:31 +02:00
Irmen de Jong
d5adb85e5b IR: add SEC,CLC,SEI,CLI instructions for the sys function calls. 2024-07-14 21:01:19 +02:00
Irmen de Jong
69f953fd9b diskio.f_readline() now also returns I/O status as secondary return value in A 2024-07-06 22:25:01 +02:00
Irmen de Jong
484677b4b1 Get rid of any() and all() builtin functions.
Replaced by regular subroutines in the anyall module.
2024-07-06 18:49:03 +02:00
Irmen de Jong
25f25a8767 Get rid of sort() and reverse() builtin functions.
Sort() had too many gotchas and reverse() is kinda redundant you can loop in decreasing order through an array too.
2024-07-06 17:07:58 +02:00
Irmen de Jong
0c053e4a2c IR: don't confuse symbol names starting with 'r', with register names
Added start of buffer.p8 (experimental)
2024-07-04 01:39:25 +02:00
Irmen de Jong
a291164953 fix leaving Vera CTRL at 1 instead of 0, could lead to kernal text output errors etc
Fixes #143
2024-07-02 23:36:36 +02:00
Irmen de Jong
e7298f8162 fix invalid code gen for if v1==0 or v2==0 2024-07-01 23:38:25 +02:00
Irmen de Jong
ddf990296b fix subroutine inlining symbol scope error 2024-06-29 18:53:54 +02:00
Irmen de Jong
8efa89165c sprites.get_data_ptr() signature changed: now properly returns the 2 values 2024-06-27 22:22:26 +02:00
Irmen de Jong
4f8aaf9244 some tweaks and todos 2024-06-26 21:22:40 +02:00
Irmen de Jong
54bffc91ae properly generate PUSH and POP instructions for push() and pop() calls in IR.
Also switch to a fork of shadowJar to avoid Gradle deprecation errors.
2024-06-25 22:39:20 +02:00
Irmen de Jong
034f27a8dd added queens example, update kotest lib 2024-06-19 23:57:43 +02:00
Irmen de Jong
c2f6311367 todo 2024-06-17 22:41:52 +02:00
markjreed
6f00a48772
fix: atan2(anything, 0) should return ±π/2 (#141)
* fix: atan2(anything, 0) should return pi/2

* fix: if y<0, x=0 maps to 3π/2, not π/2

* fix: standard seems to be atan2(0,0) == 0
2024-06-07 23:19:45 +02:00
Irmen de Jong
b3dba67405 added cx16.rom_version() routine 2024-06-07 23:15:26 +02:00
Irmen de Jong
c9a4235669 update to kotlin 2.0, fix several code style issues 2024-06-04 01:00:46 +02:00
Irmen de Jong
8973763866 Fix line endings conversion errors on windows builds 2024-06-04 00:12:12 +02:00
Irmen de Jong
d2e010c439 added cx16.scnsiz (extapi call), describe profiler.py script 2024-05-31 21:48:29 +02:00
Irmen de Jong
15867ab423 update cx16.mouse_get() and mouse_pos() to also return scroll wheel in X 2024-05-29 23:19:53 +02:00
Irmen de Jong
af64af2397 explain integer math sin/cos routines better 2024-05-29 19:48:27 +02:00
Irmen de Jong
1feead2260 tweaks 2024-05-29 02:30:06 +02:00
Irmen de Jong
3ea0f0cbaa remove 16 bit f_tell variant. 2024-05-22 21:47:02 +02:00
Irmen de Jong
f3e3311598 added diskio.f_tell() and f_tell32() on the cx16 target 2024-05-21 23:14:25 +02:00
Irmen de Jong
fda8e61be4 give better error when using @split wrong 2024-05-20 21:51:07 +02:00
Irmen de Jong
ac1d4b4a7a mouse_pos() now returns the coordinates as unsigned words 2024-05-20 21:38:02 +02:00
Irmen de Jong
c719e274d5 java version tweaks 2024-05-18 20:25:44 +02:00
Irmen de Jong
62afd3342e void syntax check, fixes #135 2024-05-18 17:15:31 +02:00
Irmen de Jong
6e8a89e6f1 optimize const word repeat setup 2024-05-18 16:30:27 +02:00
Irmen de Jong
4a710ecdfc cleanups 2024-05-17 18:48:04 +02:00
Irmen de Jong
7915dda35f update libraries 2024-05-12 03:02:54 +02:00
Irmen de Jong
5ac9c75521 docs of new floats routines and added them to VM target too 2024-04-17 20:03:36 +02:00
markjreed
07710e0995
Feature/reciprocal tangent functions (#133)
* feat: additional trig functions

* fix: 64tass won't assemble a proc named 'sec'

* fix: indentation
2024-04-17 19:54:47 +02:00
Irmen de Jong
2675623aea fix optimization ast parent linkage problem 2024-04-16 23:27:22 +02:00
Irmen de Jong
94263c43d0 added cx16/vumeter example 2024-04-16 22:48:36 +02:00
Irmen de Jong
d8ec03874f move the pi-related constants from system specific floats module into the shared one. Clarify some stuff. 2024-04-15 19:15:44 +02:00
Irmen de Jong
5d7ddebcad fix bool to uword cast in 6502 codegen 2024-04-11 00:34:53 +02:00
Irmen de Jong
53df0eb707 cleanups 2024-04-10 22:04:03 +02:00
Irmen de Jong
42f4b06ac8 added options -bytes2float and -float2bytes to be able to do float conversions from the command line 2024-04-09 23:59:54 +02:00
Irmen de Jong
db80417bd7 fix a problem with const fold optimization in if expressions, and IR compilation of that 2024-04-09 22:09:29 +02:00
Irmen de Jong
f5d556a7f9 added missing options to doc 2024-04-09 19:30:04 +02:00
Irmen de Jong
2aae46d632 added -dumpsymbols option to print a dump of all the variables and subroutine signatures 2024-04-09 19:19:13 +02:00
Irmen de Jong
19ebc6d6b3 better error message for ambiguous multi-var initialization in vardecl 2024-04-08 22:36:00 +02:00
Irmen de Jong
f88c29e083 convert github doc links into permalinks 2024-04-08 22:12:28 +02:00
Irmen de Jong
6ed9899dc7 smarter desugaring of ubyte x,y 2024-04-07 23:36:46 +02:00
Irmen de Jong
9de7698a5c verafx.mult() and muls() now return both words of the 32 bits result. 2024-04-07 22:41:21 +02:00