tweaks, bump version 11.0

This commit is contained in:
Irmen de Jong 2024-12-22 03:47:35 +01:00
parent c3dc74788a
commit c0ae35b3a3
19 changed files with 313 additions and 178 deletions

View File

@ -337,8 +337,10 @@ class AsmGen6502Internal (
lastSourceLineNumber = node.position.line
val srcComment = "\t; source: ${node.position.file}:${node.position.line}"
val line = ImportFileSystem.retrieveSourceLine(node.position)
out("$srcComment $line", false)
if(node.position.line>0) {
val line = ImportFileSystem.retrieveSourceLine(node.position)
out("$srcComment $line", false)
}
}
internal fun out(str: String, splitlines: Boolean = true) {

View File

@ -668,13 +668,17 @@ io_error:
; NOTE: data is read into the current Ram bank if you're reading into banked ram.
; if you require loading into another ram bank, you have to set that
; yourself using cx16.rambank(bank) before calling load().
; NOTE: if the file is loaded in a hiram bank, and fills the bank exactly to the end ($bfff),
; the return address will still be one higher. Which means, because the Kernal
; load routine is bank-aware, it will return $a000 and will have switched to the next hiram bank!
; So you'll have to reset the ram bank with cx16.rambank() to switch back to the bank that the data was put in.
sub load(uword filenameptr, uword address_override) -> uword {
return internal_load_routine(filenameptr, address_override, false)
}
; Identical to load(), but DOES INCLUDE the first 2 bytes in the file.
; No program header is assumed in the file. Everything is loaded.
; See comments on load() for more details.
; See comments on load() for more details. Including the banking behavior on the X16.
sub load_raw(uword filenameptr, uword startaddress) -> uword {
return internal_load_routine(filenameptr, startaddress, true)
}
@ -746,7 +750,7 @@ io_error:
void cbm.OPEN() ; open 12,8,12,"filename"
cx16.r0 = 0
if_cc {
cbm.CHKIN(READ_IO_CHANNEL)
void cbm.CHKIN(READ_IO_CHANNEL)
cx16.r0L = cbm.CHRIN()
cx16.r0H = cbm.CHRIN()
if cbm.READST()!=0

View File

@ -660,7 +660,7 @@ io_error:
void cbm.OPEN() ; open 12,8,12,"filename"
cx16.r0 = 0
if_cc {
cbm.CHKIN(READ_IO_CHANNEL)
void cbm.CHKIN(READ_IO_CHANNEL)
cx16.r0L = cbm.CHRIN()
cx16.r0H = cbm.CHRIN()
if cbm.READST()!=0

View File

@ -310,4 +310,14 @@ diskio {
return false
}
sub get_loadaddress(str filename) -> uword {
; get the load adress from a PRG file (usually $0801 but it can be different)
if f_open(filename) {
uword address
f_read(&address, 2)
f_close()
return address
}
return 0
}
}

View File

@ -1,23 +1,11 @@
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
Prerelease version from git commit 7a647300 in branch nextversion
Prog8 compiler v11.0 by Irmen de Jong (irmen@razorvine.net)
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
Compiling program import-all-atari.p8
Compiler target: atari
LIBRARY MODULE NAME: anyall
---------------------------
anyall {
all (uword arrayptr, uword num_elements) -> bool
allw (uword arrayptr, uword num_elements) -> bool
any (uword arrayptr, uword num_elements) -> bool
anyw (uword arrayptr, uword num_elements) -> bool
}
LIBRARY MODULE NAME: buffers
----------------------------
@ -26,11 +14,29 @@ smallringbuffer {
ubyte fill
ubyte head
ubyte tail
free () -> ubyte
get () -> ubyte
getw () -> uword
init ()
put (ubyte value) -> bool
putw (uword value) -> bool
isempty () -> bool
isfull () -> bool
put (ubyte value)
putw (uword value)
size () -> ubyte
}
stack {
uword buffer_ptr
uword sp
free () -> uword
init ()
isempty () -> bool
isfull () -> bool
pop () -> ubyte
popw () -> uword
push (ubyte value)
pushw (uword value)
size () -> uword
}
ringbuffer {
@ -38,13 +44,17 @@ ringbuffer {
uword fill
uword head
uword tail
free () -> uword
get () -> ubyte
getw () -> uword
inc_head ()
inc_tail ()
init ()
put (ubyte value) -> bool
putw (uword value) -> bool
isempty () -> bool
isfull () -> bool
put (ubyte value)
putw (uword value)
size () -> uword
}
@ -54,6 +64,9 @@ LIBRARY MODULE NAME: compression
compression {
decode_rle (uword compressed @AY, uword target @R0, uword maxsize @R1) -> clobbers (X) -> uword @AY
decode_rle_srcfunc (uword source_function @AY, uword target @R0, uword maxsize @R1) -> clobbers (X) -> uword @AY
decode_tscrunch (uword compressed @R0, uword target @R1) -> clobbers (A,X,Y)
decode_tscrunch_inplace (uword compressed @R0) -> clobbers (A,X,Y)
decode_zx0 (uword compressed @R0, uword target @R1) -> clobbers (A,X,Y)
encode_rle (uword data, uword size, uword target, bool is_last_block) -> uword
encode_rle_outfunc (uword data, uword size, uword output_function, bool is_last_block)
}
@ -93,7 +106,7 @@ LIBRARY MODULE NAME: cx16logo
-----------------------------
cx16logo {
uword[] logo_lines
@nosplit uword[] logo_lines
logo ()
logo_at (ubyte column, ubyte row)
}
@ -121,6 +134,7 @@ math {
direction (ubyte x1, ubyte y1, ubyte x2, ubyte y2) -> ubyte
direction_qd (ubyte quadrant @A, ubyte xdelta @X, ubyte ydelta @Y) -> ubyte @A
direction_sc (byte x1, byte y1, byte x2, byte y2) -> ubyte
interpolate (ubyte v, ubyte inputMin, ubyte inputMax, ubyte outputMin, ubyte outputMax) -> ubyte
lerp (ubyte v0, ubyte v1, ubyte t) -> ubyte
lerpw (uword v0, uword v1, uword t) -> uword
log2 (ubyte value @A) -> ubyte @Y

View File

@ -1,23 +1,11 @@
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
Prerelease version from git commit 7a647300 in branch nextversion
Prog8 compiler v11.0 by Irmen de Jong (irmen@razorvine.net)
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
Compiling program import-all-c128.p8
Compiler target: c128
LIBRARY MODULE NAME: anyall
---------------------------
anyall {
all (uword arrayptr, uword num_elements) -> bool
allw (uword arrayptr, uword num_elements) -> bool
any (uword arrayptr, uword num_elements) -> bool
anyw (uword arrayptr, uword num_elements) -> bool
}
LIBRARY MODULE NAME: buffers
----------------------------
@ -26,11 +14,29 @@ smallringbuffer {
ubyte fill
ubyte head
ubyte tail
free () -> ubyte
get () -> ubyte
getw () -> uword
init ()
put (ubyte value) -> bool
putw (uword value) -> bool
isempty () -> bool
isfull () -> bool
put (ubyte value)
putw (uword value)
size () -> ubyte
}
stack {
uword buffer_ptr
uword sp
free () -> uword
init ()
isempty () -> bool
isfull () -> bool
pop () -> ubyte
popw () -> uword
push (ubyte value)
pushw (uword value)
size () -> uword
}
ringbuffer {
@ -38,13 +44,17 @@ ringbuffer {
uword fill
uword head
uword tail
free () -> uword
get () -> ubyte
getw () -> uword
inc_head ()
inc_tail ()
init ()
put (ubyte value) -> bool
putw (uword value) -> bool
isempty () -> bool
isfull () -> bool
put (ubyte value)
putw (uword value)
size () -> uword
}
@ -54,6 +64,9 @@ LIBRARY MODULE NAME: compression
compression {
decode_rle (uword compressed @AY, uword target @R0, uword maxsize @R1) -> clobbers (X) -> uword @AY
decode_rle_srcfunc (uword source_function @AY, uword target @R0, uword maxsize @R1) -> clobbers (X) -> uword @AY
decode_tscrunch (uword compressed @R0, uword target @R1) -> clobbers (A,X,Y)
decode_tscrunch_inplace (uword compressed @R0) -> clobbers (A,X,Y)
decode_zx0 (uword compressed @R0, uword target @R1) -> clobbers (A,X,Y)
encode_rle (uword data, uword size, uword target, bool is_last_block) -> uword
encode_rle_outfunc (uword data, uword size, uword output_function, bool is_last_block)
}
@ -93,7 +106,7 @@ LIBRARY MODULE NAME: cx16logo
-----------------------------
cx16logo {
uword[] logo_lines
@nosplit uword[] logo_lines
logo ()
logo_at (ubyte column, ubyte row)
}
@ -121,6 +134,7 @@ math {
direction (ubyte x1, ubyte y1, ubyte x2, ubyte y2) -> ubyte
direction_qd (ubyte quadrant @A, ubyte xdelta @X, ubyte ydelta @Y) -> ubyte @A
direction_sc (byte x1, byte y1, byte x2, byte y2) -> ubyte
interpolate (ubyte v, ubyte inputMin, ubyte inputMax, ubyte outputMin, ubyte outputMax) -> ubyte
lerp (ubyte v0, ubyte v1, ubyte t) -> ubyte
lerpw (uword v0, uword v1, uword t) -> uword
log2 (ubyte value @A) -> ubyte @Y
@ -164,6 +178,7 @@ diskio {
f_read_all (uword bufferpointer) -> uword
f_readline (uword bufptr @AY) -> clobbers (X) -> ubyte @Y, ubyte @A
f_write (uword bufferpointer, uword num_bytes) -> bool
get_loadaddress (str filename) -> uword
lf_end_list ()
lf_next_entry () -> bool
lf_start_list (uword pattern_ptr) -> bool
@ -431,7 +446,7 @@ c64 {
&ubyte SPRPTR7
&ubyte SPSPCL
&ubyte[] SPXY
&uword[] SPXYW
&@nosplit uword[] SPXYW
&ubyte SR1
&ubyte SR2
&ubyte SR3
@ -447,6 +462,7 @@ c128 {
&ubyte VM3
&ubyte VM4
JSRFAR () = $ff6e
SETBNK (ubyte databank @A, ubyte filenamebank @X) = $ff68
banks (ubyte banks @A)
disable_basic () -> clobbers (A)
getbanks () -> ubyte @A

View File

@ -1,23 +1,11 @@
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
Prerelease version from git commit 7a647300 in branch nextversion
Prog8 compiler v11.0 by Irmen de Jong (irmen@razorvine.net)
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
Compiling program import-all-c64.p8
Compiler target: c64
LIBRARY MODULE NAME: anyall
---------------------------
anyall {
all (uword arrayptr, uword num_elements) -> bool
allw (uword arrayptr, uword num_elements) -> bool
any (uword arrayptr, uword num_elements) -> bool
anyw (uword arrayptr, uword num_elements) -> bool
}
LIBRARY MODULE NAME: buffers
----------------------------
@ -26,11 +14,29 @@ smallringbuffer {
ubyte fill
ubyte head
ubyte tail
free () -> ubyte
get () -> ubyte
getw () -> uword
init ()
put (ubyte value) -> bool
putw (uword value) -> bool
isempty () -> bool
isfull () -> bool
put (ubyte value)
putw (uword value)
size () -> ubyte
}
stack {
uword buffer_ptr
uword sp
free () -> uword
init ()
isempty () -> bool
isfull () -> bool
pop () -> ubyte
popw () -> uword
push (ubyte value)
pushw (uword value)
size () -> uword
}
ringbuffer {
@ -38,13 +44,17 @@ ringbuffer {
uword fill
uword head
uword tail
free () -> uword
get () -> ubyte
getw () -> uword
inc_head ()
inc_tail ()
init ()
put (ubyte value) -> bool
putw (uword value) -> bool
isempty () -> bool
isfull () -> bool
put (ubyte value)
putw (uword value)
size () -> uword
}
@ -54,6 +64,9 @@ LIBRARY MODULE NAME: compression
compression {
decode_rle (uword compressed @AY, uword target @R0, uword maxsize @R1) -> clobbers (X) -> uword @AY
decode_rle_srcfunc (uword source_function @AY, uword target @R0, uword maxsize @R1) -> clobbers (X) -> uword @AY
decode_tscrunch (uword compressed @R0, uword target @R1) -> clobbers (A,X,Y)
decode_tscrunch_inplace (uword compressed @R0) -> clobbers (A,X,Y)
decode_zx0 (uword compressed @R0, uword target @R1) -> clobbers (A,X,Y)
encode_rle (uword data, uword size, uword target, bool is_last_block) -> uword
encode_rle_outfunc (uword data, uword size, uword output_function, bool is_last_block)
}
@ -93,7 +106,7 @@ LIBRARY MODULE NAME: cx16logo
-----------------------------
cx16logo {
uword[] logo_lines
@nosplit uword[] logo_lines
logo ()
logo_at (ubyte column, ubyte row)
}
@ -173,6 +186,7 @@ floats {
csc (float value) -> float
deg (float angle) -> float
floor (float value) -> float
interpolate (float v, float inputMin, float inputMax, float outputMin, float outputMax) -> float
lerp (float v0, float v1, float t) -> float
lerp_fast (float v0, float v1, float t) -> float
ln (float value) -> float
@ -244,6 +258,7 @@ math {
direction (ubyte x1, ubyte y1, ubyte x2, ubyte y2) -> ubyte
direction_qd (ubyte quadrant @A, ubyte xdelta @X, ubyte ydelta @Y) -> ubyte @A
direction_sc (byte x1, byte y1, byte x2, byte y2) -> ubyte
interpolate (ubyte v, ubyte inputMin, ubyte inputMax, ubyte outputMin, ubyte outputMax) -> ubyte
lerp (ubyte v0, ubyte v1, ubyte t) -> ubyte
lerpw (uword v0, uword v1, uword t) -> uword
log2 (ubyte value @A) -> ubyte @Y
@ -287,6 +302,7 @@ diskio {
f_read_all (uword bufferpointer) -> uword
f_readline (uword bufptr @AY) -> clobbers (X) -> ubyte @Y, ubyte @A
f_write (uword bufferpointer, uword num_bytes) -> bool
get_loadaddress (str filename) -> uword
lf_end_list ()
lf_next_entry () -> bool
lf_start_list (uword pattern_ptr) -> bool
@ -559,7 +575,7 @@ c64 {
&ubyte SPRPTR7
&ubyte SPSPCL
&ubyte[] SPXY
&uword[] SPXYW
&@nosplit uword[] SPXYW
&ubyte SR1
&ubyte SR2
&ubyte SR3

View File

@ -1,23 +1,11 @@
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
Prerelease version from git commit 7a647300 in branch nextversion
Prog8 compiler v11.0 by Irmen de Jong (irmen@razorvine.net)
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
Compiling program import-all-cx16.p8
Compiler target: cx16
LIBRARY MODULE NAME: anyall
---------------------------
anyall {
all (uword arrayptr, uword num_elements) -> bool
allw (uword arrayptr, uword num_elements) -> bool
any (uword arrayptr, uword num_elements) -> bool
anyw (uword arrayptr, uword num_elements) -> bool
}
LIBRARY MODULE NAME: bmx
------------------------
@ -65,25 +53,45 @@ smallringbuffer {
ubyte fill
ubyte head
ubyte tail
free () -> ubyte
get () -> ubyte
getw () -> uword
init ()
put (ubyte value) -> bool
putw (uword value) -> bool
isempty () -> bool
isfull () -> bool
put (ubyte value)
putw (uword value)
size () -> ubyte
}
stack {
ubyte bank
uword sp
free () -> uword
init (ubyte rambank)
isempty () -> bool
isfull () -> bool
pop () -> ubyte
popw () -> uword
push (ubyte value)
pushw (uword value)
size () -> uword
}
ringbuffer {
uword buffer_ptr
uword fill
uword head
uword tail
uword fill, head, tail
ubyte bank
free () -> uword
get () -> ubyte
getw () -> uword
inc_head ()
inc_tail ()
init ()
put (ubyte value) -> bool
putw (uword value) -> bool
init (ubyte rambank)
isempty () -> bool
isfull () -> bool
put (ubyte value)
putw (uword value)
size () -> uword
}
@ -93,6 +101,10 @@ LIBRARY MODULE NAME: compression
compression {
decode_rle (uword compressed @AY, uword target @R0, uword maxsize @R1) -> clobbers (X) -> uword @AY
decode_rle_srcfunc (uword source_function @AY, uword target @R0, uword maxsize @R1) -> clobbers (X) -> uword @AY
decode_rle_vram (uword compressed @R0, ubyte vbank @X, uword vaddr @AY)
decode_tscrunch (uword compressed @R0, uword target @R1) -> clobbers (A,X,Y)
decode_tscrunch_inplace (uword compressed @R0) -> clobbers (A,X,Y)
decode_zx0 (uword compressed @R0, uword target @R1) -> clobbers (A,X,Y)
encode_rle (uword data, uword size, uword target, bool is_last_block) -> uword
encode_rle_outfunc (uword data, uword size, uword output_function, bool is_last_block)
}
@ -132,7 +144,7 @@ LIBRARY MODULE NAME: cx16logo
-----------------------------
cx16logo {
uword[] logo_lines
@nosplit uword[] logo_lines
logo ()
logo_at (ubyte column, ubyte row)
}
@ -171,6 +183,7 @@ diskio {
f_tell () -> uword @R0, uword @R1, uword @R2, uword @R3
f_write (uword bufferpointer, uword num_bytes) -> bool
fastmode (ubyte mode) -> bool
get_loadaddress (str filename) -> uword
internal_f_open_w (str filename, bool open_for_seeks) -> bool
internal_f_tell ()
internal_load_routine (uword filenameptr, uword address_override, bool headerless) -> uword
@ -308,6 +321,7 @@ floats {
csc (float value) -> float
deg (float angle) -> float
floor (float value) -> float
interpolate (float v, float inputMin, float inputMax, float outputMin, float outputMax) -> float
lerp (float v0, float v1, float t) -> float
lerp_fast (float v0, float v1, float t) -> float
ln (float value) -> float
@ -345,7 +359,7 @@ gfx_hires {
clear_screen (ubyte color)
cs_innerloop640 (ubyte color @A) -> clobbers (Y)
disc (uword xcenter, uword ycenter, ubyte radius, ubyte color)
fill (uword x, uword y, ubyte new_color)
fill (uword x, uword y, ubyte new_color, ubyte stack_rambank)
fillrect (uword xx, uword yy, uword rwidth, uword rheight, ubyte color)
graphics_mode ()
horizontal_line (uword xx, uword yy, uword length, ubyte color)
@ -385,7 +399,7 @@ gfx_lores {
clear_screen (ubyte color)
disc (uword xcenter, ubyte ycenter, ubyte radius, ubyte color)
drawmode_eor (bool enabled)
fill (uword x, ubyte y, ubyte new_color)
fill (uword x, ubyte y, ubyte new_color, ubyte stack_rambank)
fillrect (uword xx, ubyte yy, uword rwidth, ubyte rheight, ubyte color)
graphics_mode ()
horizontal_line (uword xx, ubyte yy, uword length, ubyte color)
@ -459,6 +473,7 @@ math {
direction (ubyte x1, ubyte y1, ubyte x2, ubyte y2) -> ubyte
direction_qd (ubyte quadrant @A, ubyte xdelta @X, ubyte ydelta @Y) -> ubyte @A
direction_sc (byte x1, byte y1, byte x2, byte y2) -> ubyte
interpolate (ubyte v, ubyte inputMin, ubyte inputMax, ubyte outputMin, ubyte outputMax) -> ubyte
lerp (ubyte v0, ubyte v1, ubyte t) -> ubyte
lerpw (uword v0, uword v1, uword t) -> uword
log2 (ubyte value @A) -> ubyte @Y
@ -493,7 +508,7 @@ monogfx {
cs_innerloop640 (bool draw @A) -> clobbers (Y)
disc (uword xcenter, uword ycenter, ubyte radius, bool draw)
drawmode (ubyte dm)
fill (uword x, uword y, bool draw)
fill (uword x, uword y, bool draw, ubyte stack_rambank)
fillrect (uword xx, uword yy, uword rwidth, uword rheight, bool draw)
hires ()
horizontal_line (uword xx, uword yy, uword length, bool draw)
@ -519,7 +534,6 @@ LIBRARY MODULE NAME: palette
----------------------------
palette {
uword vera_palette_ptr
channel8to4 (ubyte channelvalue) -> ubyte
color8to4 (uword colorpointer) -> uword
fade_step (ubyte index, uword target_rgb) -> bool
@ -532,11 +546,12 @@ palette {
set_c64pepto ()
set_color (ubyte index, uword color)
set_default16 ()
set_grayscale ()
set_monochrome (uword screencolorRGB, uword drawcolorRGB)
set_rgb (uword palette_words_ptr, uword num_colors)
set_rgb8 (uword palette_bytes_ptr, uword num_colors)
set_rgb_be (uword palette_ptr, uword num_colors)
set_grayscale (ubyte startindex)
set_rgb (uword palette_words_ptr, uword num_colors, ubyte startindex)
set_rgb8 (uword palette_bytes_ptr, uword num_colors, ubyte startindex)
set_rgb_be (uword palette_ptr, uword num_colors, ubyte startindex)
set_rgb_be_nosplit (uword palette_ptr, uword num_colors, ubyte startindex)
set_rgb_nosplit (uword palette_words_ptr, uword num_colors, ubyte startindex)
}
@ -555,7 +570,7 @@ psg {
ubyte[] envelope_releases
ubyte[] envelope_states
ubyte[] envelope_sustains
@split uword[] envelope_volumes
uword[] envelope_volumes
envelope (ubyte voice_num, ubyte maxvolume, ubyte attack, ubyte sustain, ubyte release)
envelopes_irq () -> bool
freq (ubyte voice_num, uword vera_freq)
@ -592,6 +607,7 @@ sprites {
movey (ubyte spritenum, word dy)
pos (ubyte spritenum, word xpos, word ypos)
pos_batch (ubyte first_spritenum, ubyte num_sprites, uword xpositions_ptr, uword ypositions_ptr)
pos_batch_nosplit (ubyte first_spritenum, ubyte num_sprites, uword xpositions_ptr, uword ypositions_ptr)
reset (ubyte spritenum_start, ubyte count)
set_mousepointer_hand ()
set_mousepointer_image (uword data, bool compressed)
@ -1093,7 +1109,7 @@ cx16 {
set_led_state (bool on)
set_line_irq_handler (uword rasterline @R0, uword address @AY) -> clobbers (A,Y)
set_program_args (uword args_ptr, ubyte args_size)
set_screen_mode (ubyte mode @A) -> clobbers (A,X,Y) -> bool @Pc
set_screen_mode (ubyte mode @A) -> clobbers (A,X,Y)
set_sprcol_irq_handler (uword address @AY) -> clobbers (A)
set_vsync_irq_handler (uword address @AY) -> clobbers (A)
sprite_set_image (uword pixels @R0, uword mask @R1, ubyte bpp @R2, ubyte number @A, ubyte width @X, ubyte height @Y, bool apply_mask @Pc) -> clobbers (A,X,Y) -> bool @Pc = $fef0

View File

@ -1,23 +1,11 @@
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
Prerelease version from git commit 7a647300 in branch nextversion
Prog8 compiler v11.0 by Irmen de Jong (irmen@razorvine.net)
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
Compiling program import-all-neo.p8
Compiler target: neo
LIBRARY MODULE NAME: anyall
---------------------------
anyall {
all (uword arrayptr, uword num_elements) -> bool
allw (uword arrayptr, uword num_elements) -> bool
any (uword arrayptr, uword num_elements) -> bool
anyw (uword arrayptr, uword num_elements) -> bool
}
LIBRARY MODULE NAME: buffers
----------------------------
@ -26,11 +14,29 @@ smallringbuffer {
ubyte fill
ubyte head
ubyte tail
free () -> ubyte
get () -> ubyte
getw () -> uword
init ()
put (ubyte value) -> bool
putw (uword value) -> bool
isempty () -> bool
isfull () -> bool
put (ubyte value)
putw (uword value)
size () -> ubyte
}
stack {
uword buffer_ptr
uword sp
free () -> uword
init ()
isempty () -> bool
isfull () -> bool
pop () -> ubyte
popw () -> uword
push (ubyte value)
pushw (uword value)
size () -> uword
}
ringbuffer {
@ -38,13 +44,17 @@ ringbuffer {
uword fill
uword head
uword tail
free () -> uword
get () -> ubyte
getw () -> uword
inc_head ()
inc_tail ()
init ()
put (ubyte value) -> bool
putw (uword value) -> bool
isempty () -> bool
isfull () -> bool
put (ubyte value)
putw (uword value)
size () -> uword
}
@ -54,6 +64,9 @@ LIBRARY MODULE NAME: compression
compression {
decode_rle (uword compressed @AY, uword target @R0, uword maxsize @R1) -> clobbers (X) -> uword @AY
decode_rle_srcfunc (uword source_function @AY, uword target @R0, uword maxsize @R1) -> clobbers (X) -> uword @AY
decode_tscrunch (uword compressed @R0, uword target @R1) -> clobbers (A,X,Y)
decode_tscrunch_inplace (uword compressed @R0) -> clobbers (A,X,Y)
decode_zx0 (uword compressed @R0, uword target @R1) -> clobbers (A,X,Y)
encode_rle (uword data, uword size, uword target, bool is_last_block) -> uword
encode_rle_outfunc (uword data, uword size, uword output_function, bool is_last_block)
}
@ -111,6 +124,7 @@ math {
direction (ubyte x1, ubyte y1, ubyte x2, ubyte y2) -> ubyte
direction_qd (ubyte quadrant @A, ubyte xdelta @X, ubyte ydelta @Y) -> ubyte @A
direction_sc (byte x1, byte y1, byte x2, byte y2) -> ubyte
interpolate (ubyte v, ubyte inputMin, ubyte inputMax, ubyte outputMin, ubyte outputMax) -> ubyte
lerp (ubyte v0, ubyte v1, ubyte t) -> ubyte
lerpw (uword v0, uword v1, uword t) -> uword
log2 (ubyte value @A) -> ubyte @Y

View File

@ -1,23 +1,11 @@
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
Prerelease version from git commit 7a647300 in branch nextversion
Prog8 compiler v11.0 by Irmen de Jong (irmen@razorvine.net)
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
Compiling program import-all-pet32.p8
Compiler target: pet32
LIBRARY MODULE NAME: anyall
---------------------------
anyall {
all (uword arrayptr, uword num_elements) -> bool
allw (uword arrayptr, uword num_elements) -> bool
any (uword arrayptr, uword num_elements) -> bool
anyw (uword arrayptr, uword num_elements) -> bool
}
LIBRARY MODULE NAME: buffers
----------------------------
@ -26,11 +14,29 @@ smallringbuffer {
ubyte fill
ubyte head
ubyte tail
free () -> ubyte
get () -> ubyte
getw () -> uword
init ()
put (ubyte value) -> bool
putw (uword value) -> bool
isempty () -> bool
isfull () -> bool
put (ubyte value)
putw (uword value)
size () -> ubyte
}
stack {
uword buffer_ptr
uword sp
free () -> uword
init ()
isempty () -> bool
isfull () -> bool
pop () -> ubyte
popw () -> uword
push (ubyte value)
pushw (uword value)
size () -> uword
}
ringbuffer {
@ -38,13 +44,17 @@ ringbuffer {
uword fill
uword head
uword tail
free () -> uword
get () -> ubyte
getw () -> uword
inc_head ()
inc_tail ()
init ()
put (ubyte value) -> bool
putw (uword value) -> bool
isempty () -> bool
isfull () -> bool
put (ubyte value)
putw (uword value)
size () -> uword
}
@ -54,6 +64,9 @@ LIBRARY MODULE NAME: compression
compression {
decode_rle (uword compressed @AY, uword target @R0, uword maxsize @R1) -> clobbers (X) -> uword @AY
decode_rle_srcfunc (uword source_function @AY, uword target @R0, uword maxsize @R1) -> clobbers (X) -> uword @AY
decode_tscrunch (uword compressed @R0, uword target @R1) -> clobbers (A,X,Y)
decode_tscrunch_inplace (uword compressed @R0) -> clobbers (A,X,Y)
decode_zx0 (uword compressed @R0, uword target @R1) -> clobbers (A,X,Y)
encode_rle (uword data, uword size, uword target, bool is_last_block) -> uword
encode_rle_outfunc (uword data, uword size, uword output_function, bool is_last_block)
}
@ -93,7 +106,7 @@ LIBRARY MODULE NAME: cx16logo
-----------------------------
cx16logo {
uword[] logo_lines
@nosplit uword[] logo_lines
logo ()
logo_at (ubyte column, ubyte row)
}
@ -121,6 +134,7 @@ math {
direction (ubyte x1, ubyte y1, ubyte x2, ubyte y2) -> ubyte
direction_qd (ubyte quadrant @A, ubyte xdelta @X, ubyte ydelta @Y) -> ubyte @A
direction_sc (byte x1, byte y1, byte x2, byte y2) -> ubyte
interpolate (ubyte v, ubyte inputMin, ubyte inputMax, ubyte outputMin, ubyte outputMax) -> ubyte
lerp (ubyte v0, ubyte v1, ubyte t) -> ubyte
lerpw (uword v0, uword v1, uword t) -> uword
log2 (ubyte value @A) -> ubyte @Y

View File

@ -1,23 +1,11 @@
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
Prerelease version from git commit 7a647300 in branch nextversion
Prog8 compiler v11.0 by Irmen de Jong (irmen@razorvine.net)
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
Compiling program import-all-virtual.p8
Compiler target: virtual
LIBRARY MODULE NAME: anyall
---------------------------
anyall {
all (uword arrayptr, uword num_elements) -> bool
allw (uword arrayptr, uword num_elements) -> bool
any (uword arrayptr, uword num_elements) -> bool
anyw (uword arrayptr, uword num_elements) -> bool
}
LIBRARY MODULE NAME: buffers
----------------------------
@ -26,11 +14,29 @@ smallringbuffer {
ubyte fill
ubyte head
ubyte tail
free () -> ubyte
get () -> ubyte
getw () -> uword
init ()
put (ubyte value) -> bool
putw (uword value) -> bool
isempty () -> bool
isfull () -> bool
put (ubyte value)
putw (uword value)
size () -> ubyte
}
stack {
uword buffer_ptr
uword sp
free () -> uword
init ()
isempty () -> bool
isfull () -> bool
pop () -> ubyte
popw () -> uword
push (ubyte value)
pushw (uword value)
size () -> uword
}
ringbuffer {
@ -38,13 +44,17 @@ ringbuffer {
uword fill
uword head
uword tail
free () -> uword
get () -> ubyte
getw () -> uword
inc_head ()
inc_tail ()
init ()
put (ubyte value) -> bool
putw (uword value) -> bool
isempty () -> bool
isfull () -> bool
put (ubyte value)
putw (uword value)
size () -> uword
}
@ -89,7 +99,7 @@ LIBRARY MODULE NAME: cx16logo
-----------------------------
cx16logo {
uword[] logo_lines
@nosplit uword[] logo_lines
logo ()
logo_at (ubyte column, ubyte row)
}
@ -158,6 +168,7 @@ floats {
csc (float value) -> float
deg (float angle) -> float
floor (float value) -> float
interpolate (float v, float inputMin, float inputMax, float outputMin, float outputMax) -> float
lerp (float v0, float v1, float t) -> float
lerp_fast (float v0, float v1, float t) -> float
ln (float value) -> float
@ -203,6 +214,7 @@ math {
direction (ubyte x1, ubyte y1, ubyte x2, ubyte y2) -> ubyte
direction_qd (ubyte quadrant, ubyte xdelta, ubyte ydelta) -> ubyte
direction_sc (byte x1, byte y1, byte x2, byte y2) -> ubyte
interpolate (ubyte v, ubyte inputMin, ubyte inputMax, ubyte outputMin, ubyte outputMax) -> ubyte
lerp (ubyte v0, ubyte v1, ubyte t) -> ubyte
lerpw (uword v0, uword v1, uword t) -> uword
log2 (ubyte value) -> ubyte

View File

@ -63,7 +63,7 @@ Subroutines
-----------
- Subroutines can be nested. Inner subroutines can directly access variables from their parent.
- Subroutine parameters are just local variables in the subroutine. (you can access them directly as such via their scoped name, if you want)
- There is no call stack. So subroutine parameters are overwritten when called again. Thus recursion is not easily possible, but you can do it with manual stack manipulations.
- There is no call stack for subroutine arguments: subroutine parameters are overwritten when called again. Thus recursion is not easily possible, but you can do it with manual stack manipulations.
There are a couple of example programs that show how to solve this in different ways, among which are fractal-tree.p8, maze.p8 and queens.p8
- There is no function overloading (except for a couple of builtin functions).
- Some subroutine types can return multiple return values, and you can multi-assign those in a single statement.
@ -72,7 +72,9 @@ Subroutines
This reduces the memory needed for variables. A convenient way to do this is by using nested subroutines - these can easily access the
variables declared in their parent subroutine(s).
- Everything in prog8 is publicly accessible from everywhere else (via fully scoped names) - there is no notion of private or public symbol accessibility.
- Because there is no callstack for subroutine arguments, it becomes very easy to manipulate the return address that *does* get pushed on the stack by the cpu.
With only a little bit of code it is possible to implement a simple cooperative multitasking system that runs multiple tasks simultaneously. See the "coroutines" example.
Each task is a subroutine and it simply has its state stored in its statically allocated variables so it can resume after a yield, without doing anything special.
Pointers
--------

View File

@ -321,7 +321,7 @@ API is slightly experimental and may change in a future version.
It has extremely fast decompression (approaching RLE speeds),
better compression as RLE, but slightly worse compression ration than LZSA.
See https://github.com/tonysavon/TSCrunch for the compression format and compressor tool.
**NOTE:** for speed reasons this decompressor is NOT bank-aware and NOT I/O register aware;
**NOTE:** for speed reasons this decompressor is *not* bank-aware and *not* I/O register aware;
it only outputs to a memory buffer somewhere in the active 64 Kb address range.
``decode_tscrunch_inplace (uword compressed)``
@ -330,7 +330,7 @@ API is slightly experimental and may change in a future version.
It has extremely fast decompression (approaching RLE speeds),
better compression as RLE, but slightly worse compression ration than LZSA.
See https://github.com/tonysavon/TSCrunch for the compression format and compressor tool.
**NOTE:** for speed reasons this decompressor is NOT bank-aware and NOT I/O register aware;
**NOTE:** for speed reasons this decompressor is *not* bank-aware and *not* I/O register aware;
it only outputs to a memory buffer somewhere in the active 64 Kb address range.
.. note::
@ -354,7 +354,7 @@ API is slightly experimental and may change in a future version.
See https://github.com/einar-saukas/ZX0 for the compression format
See https://github.com/emmanuel-marty/salvador for the compressor tool.
**NOTE:** You have to use it with the "-classic" option to produce a data format that this decoder can handle!
**NOTE:** for speed reasons this decompressor is NOT bank-aware and NOT I/O register aware;
**NOTE:** for speed reasons this decompressor is *not* bank-aware and *not* I/O register aware;
it only outputs to a memory buffer somewhere in the active 64 Kb address range.

View File

@ -1,19 +1,8 @@
TODO
====
- diskio: if loading a hiram bank exactly fills the bank, then end adress is reset to $a000 still and the bank is increased by 1. that should probably not happen
- DONE: make word arrays split by default and add new @nosplit tag to make an array use the old linear storage format
- DONE: &splitarray will give you the start address of the lsb-array (which is immediately followed by the msb-array)
- DONE: add &< and &> operators to get the address of the lsb-array and msb-array, respectively. (&< is just syntactic sugar for &)
- DONE: invert -splitarrays command line option: -dontsplitarrays and remove "splitarrays" %option switch
- DONE: added sprites.pos_batch_nosplit when the x/y arrays are linear instead of split word arrays
- DONE: add palette.set_rgb_nosplit() and set_rbg_be_nosplit() for linear instead of split word arrays
- DONE: removed anyall module (unoptimized and didn't work on split arrays)
- DONE: @split does now always splits a word array even when the dontsplit option is enabled (and @nosplit does the inverse)
- bump version and renegerate symbol dumps
- write something in the docs about how to optimize your program on the x16 using the -dumpvars option,
the emulator's memory profiler + the profiler.py script to find hotspots for routines and variables that could be placed into zeropage
- announce prog8 on the 6502.org site?
...
@ -22,20 +11,26 @@ TODO
Future Things and Ideas
^^^^^^^^^^^^^^^^^^^^^^^
- Improve the SublimeText syntax file for prog8, you can also install this for 'bat': https://github.com/sharkdp/bat?tab=readme-ov-file#adding-new-syntaxes--language-definitions
- Compiling Libraries: improve ability to create library files in prog8; for instance there's still stuff injected into the start of the start() routine AND there is separate setup logic going on before calling it.
Make up our mind! Maybe all setup does need to be put into start() ? because the program cannot function correctly when the variables aren't initialized properly bss is not cleared etc. etc.
Add a -library $xxxx command line option (and/or some directive) to preselect every setting that is required to make a library at $xxxx rather than a normal loadable and runnable program?
Need to add some way to generate a stable jump table at a given address.
Need library to not call init_system AND init_system_phase2 not either.
Library must not include prog8_program_start stuff either.
- [problematic due to using 64tass:] better support for building library programs, where unused .proc are NOT deleted from the assembly.
Perhaps replace all uses of .proc/.pend/.endproc by .block/.bend will fix that with a compiler flag?
But all library code written in asm uses .proc already..... (textual search/replace when writing the actual asm?)
Once new codegen is written that is based on the IR, this point is mostly moot anyway as that will have its own dead code removal on the IR level.
- Change scoping rules for qualified symbols so that they don't always start from the root but behave like other programming languages (look in local scope first)
- Fix missing cases where regular & has to return the start of the split array in memory whatever byte comes first. Search TODO("address of split word array")
- Add a syntax to access specific bits in a variable, to avoid manually shifts&ands, something like variable[4:8] ? (or something else this may be too similar to regular array indexing)
- something to reduce the need to use fully qualified names all the time. 'with' ? Or 'using <prefix>'?
- Improve register load order in subroutine call args assignments:
in certain situations, the "wrong" order of evaluation of function call arguments is done which results
in certain situations (need examples!), the "wrong" order of evaluation of function call arguments is done which results
in overwriting registers that already got their value, which requires a lot of stack juggling (especially on plain 6502 cpu!)
Maybe this routine can be made more intelligent. See usesOtherRegistersWhileEvaluating() and argumentsViaRegisters().
- Improve the SublimeText syntax file for prog8, you can also install this for 'bat': https://github.com/sharkdp/bat?tab=readme-ov-file#adding-new-syntaxes--language-definitions
- Does it make codegen easier if everything is an expression? Start with the PtProgram ast , get rid of the statements there -> expressions that have Void data type
- Can we support signed % (remainder) somehow?
- instead of copy-pasting inline asmsubs, make them into a 64tass macro and use that instead.
@ -44,10 +39,6 @@ Future Things and Ideas
- make a form of "manual generics" possible like: varsub routine(T arg)->T where T is expanded to a specific type
(this is already done hardcoded for several of the builtin functions)
- [much work:] more support for (64tass) SEGMENTS ?
- [problematic due to using 64tass:] better support for building library programs, where unused .proc are NOT deleted from the assembly.
Perhaps replace all uses of .proc/.pend/.endproc by .block/.bend will fix that with a compiler flag?
But all library code written in asm uses .proc already..... (textual search/replace when writing the actual asm?)
Once new codegen is written that is based on the IR, this point is mostly moot anyway as that will have its own dead code removal on the IR level.
- Zig-like try-based error handling where the V flag could indicate error condition? and/or BRK to jump into monitor on failure? (has to set BRK vector for that) But the V flag is also set on certain normal instructions
@ -75,7 +66,7 @@ IR/VM
Libraries
---------
- monogfx: flood fill should be able to fill stippled
- monogfx: flood fill should be able to fill stippled (it could do this in the past? vm version does it?)
- Sorting module gnomesort_uw could be optimized more, rewrite in asm? Shellshort seems consistently faster even if most of the words are already sorted.
- Add split-word array sorting routines to sorting module?
- pet32 target: make syslib more complete (missing kernal routines)?

View File

@ -1,13 +1,25 @@
; Cooperative multitasking / Coroutines
; Uses stack return address juggling to cycle between the different tasks when they call yield().
;
; Uses cpu stack return address juggling to cycle between the different tasks when they call yield().
; Super simplistic implementation here to just show the core idea.
;
; To make it actually useful, we probably have to:
; - make the list of tasks dynamic;
; - allow tasks to finish, allow new tasks to be added
; - return a unique value (pointer that you had to provide when adding the task to the list?)
; from yield() that the subroutine could use to access unique state,
; because right now a single task == a single subroutine; right now you cannot re-use a subroutine to run
; the same task multiple times for different things.
%import textio
main {
sub start() {
txt.print("cooperative multitasking / coroutines")
txt.print("cooperative multitasking / coroutines\n\n")
txt.print("here are 4 subroutines that each run\nan endless loop bouncing a digit around.")
coroutines.start()
}
}

View File

@ -4,6 +4,9 @@
; This example computes the first 20 values of the Fibonacci sequence.
; Note: this program can be compiled for multiple target systems.
; Note that the fibonacci subroutine keeps is state in two outer variables
; so that every call to it is able to produce the next single number in the sequence.
main {
sub start() {
txt.print("fibonacci sequence\n")

View File

@ -1,4 +1,13 @@
%import textio
%import diskio
%zeropage basicsafe
%option no_sysinit
main {
sub start() {
cx16.r2 = diskio.get_loadaddress("test.prg")
txt.print_uwhex(cx16.r2, true)
}
}

View File

@ -3,4 +3,4 @@ org.gradle.console=rich
org.gradle.parallel=true
org.gradle.daemon=true
kotlin.code.style=official
version=10.6-SNAPSHOT
version=11.0

View File

@ -148,7 +148,7 @@ class IRFileWriter(private val irProgram: IRProgram, outfileOverride: Path?) {
if(code.sourceLinesPositions.any {it !== Position.DUMMY}) {
xml.writeStartElement("P8SRC")
val sourceTxt = StringBuilder("\n")
code.sourceLinesPositions.forEach { pos ->
code.sourceLinesPositions.filter{ pos -> pos.line>0 }.forEach { pos ->
val line = ImportFileSystem.retrieveSourceLine(pos)
sourceTxt.append("$pos $line\n")
}