Page 2 of 2
Re: GUI in text mode?
Posted: Wed Apr 12, 2023 10:59 pm
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
Re: GUI in text mode?
Posted: Thu Apr 13, 2023 8:26 am
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.
Re: GUI in text mode?
Posted: Thu Apr 13, 2023 10:21 am
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.
Re: GUI in text mode?
Posted: Thu Apr 13, 2023 12:04 pm
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](./download/file.php?id=1295&sid=2f5952f081abc6bebe647316f6ec7578)
- Screenshot from 2023-04-13 13-58-57.png (11.48 KiB) Viewed 3143 times