Jump to content
desertfish

Prog8 language and compiler topic

Recommended Posts

In the spirit of “eat your own dog food”

im finding those issues and tweaks (still am, currently) because I’m attempting to write some actually useful programs with it now. The text-elite game was one of the larger ones before, and currently I’m building an image file viewer.   I even ran into a bug in one of the kernel functions that puts pixels on the screen so it is already pretty useful even if in the end nobody is going to use my image file format 🙂

if possible I also want to convert those image viewers that I mentioned in the koala demo topic. It would be pretty awesome if I can not only show those c64 koala picture, but also those nice Amiga IFF ILBM image files created by DeluxePaint 🙂   And perhaps even other image formats. I want to see where the limits of this 8 bit system lie.  Undoubtedly I’m also going to find more issues in Prog8 so no boredom for me

Edited by desertfish

Share this post


Link to post
Share on other sites

@desertfish awesome work! I sometimes wonder how you are able to dedicate so much time on your project! I have been away for a month or so due to graduate studies but I'm finally done for the semester and can now do some fun work on my compiler!

Share this post


Link to post
Share on other sites

Query

Prog8 has a built-in function  mkword(msb, lsb)   which creates a 16 bit word value from two bytes

In older versions the 2 bytes were in little endian order, analogous to how the word value would be stored in actual memory, so the lsb was first and then the msb.
A couple of releases ago however I swapped the arguments around because I then thought  it would be more readable like so:   mkword($80, $22)  =  $8022    (in memory:  $22 $80).
 
However it somehow doesn't feel right. I'm considering swapping the arguments again back to the old behavior so that would be like this again:    mkword($22, $80)  =  $8022.    (in memory: $22 $80)
 
What do you guys think?

 

Edited by desertfish

Share this post


Link to post
Share on other sites

Hiya @desertfish
 

How does the -emu flag work .. ? It looks like its trying to start the emulator but nothing happens .

EDIT! : Oh .. I see.. it needs to be in the path and then wants to load the rom files from 

Starting Commander X16 emulator x16emu...
Cannot open /usr/share/x16-rom/rom.bin!

Never mind .. I just added a line into the build batch file :

java -jar d:\dev\commanderx16\prog8compiler.jar -target cx16 -emu test.p8
x16emu -prg test.prg -run

 

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

PS D:\Dev\Projects\prog8\cx16\test> .\build.bat

D:\Dev\Projects\prog8\cx16\test>java -jar d:\dev\commanderx16\prog8compiler.jar -target cx16 -emu test.p8

Prog8 compiler v5.3 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

Compiler target: cx16. Parsing...
importing 'test'
importing 'textio' (library)
importing 'syslib' (library)
importing 'conv' (library)
importing 'floats' (library)
importing 'math' (library)
importing 'prog8_lib' (library)
Processing for target cx16...
Optimizing...
Generating assembly code...

Creating prg for target cx16.
64tass Turbo Assembler Macro V1.55.2200
64TASS comes with ABSOLUTELY NO WARRANTY; This is free software, and you
are welcome to redistribute it under certain conditions; See LICENSE!

Assembling file:   .\test.asm
Error messages:    None
Warning messages:  None
Passes:            5
Memory range:      $0801-$0c3a   $043a

Total compilation+assemble time: 0.406 sec.

Starting Commander X16 emulator x16emu...
PS D:\Dev\Projects\prog8\cx16\test>

Edited by Bones

Share this post


Link to post
Share on other sites

Hello @Bones!  Ah, I use Linux and while the compiler itself is portable, it seems that for starting the emulator I hardcoded some paths.   I'll see if I can make this more OS-friendly in a future versoin, but it's low prio.   Yes the emulator executable has to be in your PATH because it's not up to the compiler to figure out where it is installed (could be anywhere).

You can omit the -emu argument if you're starting the emulator yourself of course, it's just there for convenience so that you don't have to manually start it after a successful compile.

 

edit: seems like the -rom argument to launch the emulator is no longer necesarray on Linux too, so the next version of prog8 will have it removed. I think this should allow you to launch the emulator on windows then too with the -emu argument.

Edited by desertfish
  • Thanks 1

Share this post


Link to post
Share on other sites
16 hours ago, desertfish said:

Prog8 has a built-in function mkword(msb, lsb) which creates a 16-bit word value from two bytes.

In older versions, the 2 bytes were in little-endian order, analogous to how the word value would be stored in actual memory, so the LSB was first and then the MSB.
A couple of releases ago however, I swapped the arguments around because I then thought it would be more readable, like so:  mkword($80, $22)  =  $8022  (in memory: $22 $80).
 
However, it somehow doesn't feel right. I'm considering swapping the arguments again back to the old behavior, so that it would be like this again:  mkword($22, $80)  =  $8022  (in memory: $22 $80).

Prog8 should insulate us from the very low-level, nitty-gritty details like that.  We shouldn't care how the word is built; we should write the arguments in the order that we use when we think about 16-bit numbers.  The same is true when we make 24-bit values.  It will avoid a source of mistakes when we write programs.

Share this post


Link to post
Share on other sites
38 minutes ago, Greg King said:

the order that we use when we think about 16-bit numbers

So you're arguing to leave it as it is now, in the "natural" order.  I can agree with that.     (Notice that there's also lsb() and msb() functions that extract those bytes from a word, the reverse operation from mkword().  In a sense, they also already abstract the exact underlying byte order.)

Share this post


Link to post
Share on other sites

Released Prog8 5.4

- added the multi-format image file viewer example for cx16
- removed the rom path argument for launching the x16emu with -emu, should now work again on non-linux platforms
- improved several things in the diskio module, such as functions for incremental file loading
- implemented workaround subroutine for the FB_set_pixels bug (and made a PR for the ROM to fix it there too) commanderx16/x16-rom#179
- some other miscellaneous bugfixes and improvements. See the releases page on github.

 

Wow, it's been quite a ride to arrive at this version. I'm pretty happy with how everything turned out, but am now going to take a break and not work on Prog8 itself for a while.   I think I now want to actually create things with it, rather than creating tools to make things.   I really hope others will pick it up as well even if only to try it out for a bit.  Feedback is invaluable and very much appreciated 🤗

Edited by desertfish

Share this post


Link to post
Share on other sites

For the next version I'm trying to add the 16 virtual CommanderX16 registers r0 - r15 to the language itself (or rather, the subroutine declaration syntax), so we don't have to do this anymore:

cx16.r0 = x1
cx16.r1 = y1
cx16.r2 = x2
cx16.r3 = y2
cx16.GRAPH_draw_line()

but instead can just write this:

cx16.GRAPH_draw_line(x1, y1, x2, y2)

 

The funny thing is, that this will also make those R0-R15 'registers' available on the C64 compiler target. So you can also make asm-subroutines there that can take additional parameters, instead of being restricted to just the A, X and Y register.  Pretty nice. 
(on the C64 these 'virtual' registers are not allocated in the zero page as on the Cx16, because there's no room for them there. So they will be slightly less efficient when used)

Edited by desertfish

Share this post


Link to post
Share on other sites

I've just made a BETA release of Prog8 6.0 available.

It contains a huge pile of improvements and changes, among which:

  • restructured part of the library modules, may break old code
  • moved many built in functions that should just be subroutines, to the library module "sys" or "string", may break old code
  • commanderX16 virtual registers cx16.r0 .. r15 available (for both cx16 and c64 compiler targets)
  • added new library modules and routines such as gfx2 and new diskio stuff

I've been using this version to create the multi-file-format imageviewer demo with color cycling, the highres bitmap graphics demo, and recently the W.I.P. file-based assembler.
It's still a beta release so things might still change, but I wanted to shove it out the door because it works very well for me at this time and the list of changes and improvements is getting pretty huge so it would be a waste to not let others use it as well already.

  • Like 2

Share this post


Link to post
Share on other sites

I've just made the release of Prog8 6.0 available (it's no longer beta).

As always the documentation is here and the git repository is here.

This is a big new release with many improvements and changes (some backwards-incompatible). Hence a new major version number 6.

The most important improvements and changes are:

  • commanderX16 virtual registers cx16.r0 .. r15 directly accessible (for both cx16 and c64 compiler targets!)
  • used 65c02 (commanderx16) specific optimized code in many more places
  • much more efficient code generated for most pointer indexing operations. For some programs this means prog8 now outperforms CC65 by a significant margin
  • graphics drawing code is a lot faster. Especially on the c64, straight lines, circles and discs
     
  • added new library modules and routines such as gfx2 and new diskio stuff
  • added several new builtin functions: target(), offsetof(), memory()
  • the string to number conversion routines in conv module are now more robust and return the parsed length.
  • improved several compiler errors and warnings
  • moved the cx16 imageviewer and file based assembler out of this repo into their own git repositories
  • restructured part of the library modules, may break old code
  • moved many built in functions that should just be subroutines, to the library module "sys" or "string", may break old code
  • added some new handy functions to several library modules such as txt, conv, sys, diskio, cx16
  • many bugfixes and other tweaks
  • Like 1

Share this post


Link to post
Share on other sites

Prog8 6.1 was just released. As always the documentation is here and the git repository is here.

Changes:

- some changes in gfx2 module to make screen mode numbering more intuitive
- gfx2 can now draw in highres 4 color mode as well
- fixed bug in repeat()
- fixed bug in mkword()
- fixed bug in signed word shift right
- fixed argument register clobber bug in certain asmsubs
- tehtriz example ported to CommanderX16
- added amiga desktop mockup draw example
- added peekw() and pokew() functions
- textelite game now has a star chart and nicer table printing
- some small for loop and other optimizations
- code restructuring to make all ast related code into its own separate module

  • Like 1

Share this post


Link to post
Share on other sites

Not at all, I think 🙂     Currently the code is 99% compatible with the Commodore-64 and as such it only uses regular PETSCII characters to draw everything.   How did you draw these blocks in your screenshot?

  • Like 1

Share this post


Link to post
Share on other sites

Ok that requires me to add some extended functions to prog8's textio library.   Currently it only can do a C-64 compatible text output, i.e. setting a character in a single color at a location on screen.  I'll have to add a background color option somehow

edit: right, that wasn't so hard.  Thanks for the suggestion, this looks good!!

image.png.6dbaf27cd43b88d9fa879ef6d9227e5c.png

 

Edited by desertfish
new boxes!
  • Like 3

Share this post


Link to post
Share on other sites

Prog8 6.2 was just released. As always the documentation is here and the git repository is here.

Changes:

- like the R0..R15 virtual registers, the carry status bit Pc does no longer have to be specified as the last parameter but you can put it anywhere. The compiler will sort it.
- simplified the set_irq routines
- added irq handling routines for the commander x16
- added commanderx16 rasterbars irq example
- added cx16 vtui-library example, improved graphics on cx16 port of tehtriz and added sounds to it
- added animal guessing game example
- duplicate string literals are optimized better
- slightly optimized the gfx2 module pixel position calculations
- commanderX16 compiler target improvements
- source code restructurings to reduce internal dependencies
- bugfixes
- documentation fixes

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Please review our Terms of Use