GUI in text mode?

All aspects of programming on the Commander X16.
TomXP411
Posts: 1806
Joined: Tue May 19, 2020 8:49 pm

Re: GUI in text mode?

Post by TomXP411 »

Dacobi wrote: Wed Apr 12, 2023 6:13 pm
Which C compiler are you using? The conio library should already include gotoxy and color commands.
I'm using cc65. I was just hoping that writing directly to VERA would speed things up compared to the conio functions, but I haven't tested yet.
The conio functions do talk directly to the hardware, when possible, or they are are wrappers for the system calls, for things that aren't exactly hardware related (like setting the cursor position). That's what conio is for: to write to the screen as fast as possible. So if a conio function exists, it's probably going to be as fast as anything you can implement in your own code. And since conio will change and update with changes to the system, it's better to rely on the library functions than roll your own, if you don't need to.

For reference, here's the gotoxy() function from the cx16 library:

https://github.com/cc65/cc65/blob/maste ... 6/gotoxy.s
Dacobi
Posts: 292
Joined: Sun Dec 19, 2021 1:44 am
Location: Samsø, Denmark
Contact:

Re: GUI in text mode?

Post by Dacobi »

The conio functions do talk directly to the hardware, when possible, or they are are wrappers for the system calls, for things that aren't exactly hardware related
I was hoping I could write a function that was faster than cputc, maybe with color change built-in.
The reason is I was trying to code kind of a plasma effect in text mode, with conio functions, and it was very slow.
I've still only tested with cprintf, so maybe cputc is fast enough.
(Edit) or maybe the slowdown is from my sin/cos function, but it's just a table lookup.
TomXP411
Posts: 1806
Joined: Tue May 19, 2020 8:49 pm

Re: GUI in text mode?

Post by TomXP411 »

cprintf is a lot slower than cputc or cputs, and if you can use cputc or cputs, you should.

Don't forget that you can examine the source code for the libraries on the cc65 github page, so you can decide for yourself whether you can improve on the library code.
Dacobi
Posts: 292
Joined: Sun Dec 19, 2021 1:44 am
Location: Samsø, Denmark
Contact:

Re: GUI in text mode?

Post by Dacobi »

cprintf is a lot slower than cputc or cputs, and if you can use cputc or cputs, you should.
I switched to using cputc, but it didn't really help.
The code is just setting bg/fg color to sin(x)+cos(y) and cputc any char.
Still takes about a second to print the screen.

(Edit) It is my getsin/cos function that slows things down.
I have the tables as int, between -255/255.

I got the palette working though.
Screenshot from 2023-04-13 13-58-57.png
Screenshot from 2023-04-13 13-58-57.png (11.48 KiB) Viewed 3140 times
Post Reply