some missing functions in OSDK

Since we do not have native C compilers on the Oric, this forum will be mostly be used by people using CC65 or the OSDK. But any general C related post will be welcome !
Post Reply
User avatar
waskol
Flight Lieutenant
Posts: 389
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

some missing functions in OSDK

Post by waskol » Tue Aug 28, 2018 7:22 pm

I found them on the oric.org forum, they needed to be addapted in order to compile with osdk, but it was not too difficult :
ATOF.S (ALPHA TO FLOAT)
ATOI.S (ALPHA TO INTEGER)
FTOA.S (FLOAT TO ALPHA)
RND.S (RND de l'ORIC)
SCRN.S (SCRN de l'ORIC)
PLOA.S (PLOT ATTRIBUT de l'ORIC)
PLOC.S (PLOT CHAR de l'ORIC)
PLOTS.S (PLOT STRING de l'ORIC)
POP.S (POP de l'ORIC)
WAIT.S (WAIT de l'ORIC)

and append the library.ndk file with those lines :

Code: Select all

-atoi.s
        _atoi
-ftoa.s
        _ftoa
-atof.s
        _atof
-plota.s
        _plota
-plotc.s
        _plotc
-plots.s
        _plots
-wait.s
        _wait
-rnd.s
        _rnd
-scrn.s
        _scrn
-pop.s
        _pop
-plot.s
        _plot
Attachments
lib.zip
(3.47 KiB) Downloaded 10 times

User avatar
waskol
Flight Lieutenant
Posts: 389
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Re: some missing functions in OSDK

Post by waskol » Wed Aug 29, 2018 9:36 pm

Forget it, debug explained me why it was sooooo stupid.
and i understood how it was possible to sort all of that out without those extra dumb things ! :oops:

User avatar
ibisum
Squad Leader
Posts: 1013
Joined: Fri Apr 03, 2009 8:56 am

Re: some missing functions in OSDK

Post by ibisum » Thu Aug 30, 2018 10:19 am

So tell us then!? :)

User avatar
waskol
Flight Lieutenant
Posts: 389
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Re: some missing functions in OSDK

Post by waskol » Thu Aug 30, 2018 11:29 am

ok, here are the explanations (in french, from Debug) :
- Ce ne sont pas des routines assembleur, en gros c'est le code du compilateur C après compilation, donc ca rame, et ca prend de la place.
- Elles sont redondantes, pas besoin d'avoir quatre versions de PLOT dont le code est a 90% identique (calcul de l'endroit ou on affiche)
- SCRN devrait aussi partager 90% du code de PLOT vu que ca fait la meme chose mais dans l'autre sens.
- La fonction POP est une hérésie sans non, celle la ne sera jamais dans le OSDK.
- Il y a deja une fonction random
- WAIT ne marchera que sur Oric ATMOS (appel de la ROM)
- scanf contient déja le code pour convertir des chaines de caractères vers format float ou entier, donc ATOF et ATOI devraient utiliser ca.
- printf contient déja le code pour convertir un float vers format ASCII, donc pareil.

Le but du OSDK n'est pas d'etre exhaustif et de permettre de faire tourner n'importe quel programme C standard sur l'Oric. Si c'est ce que les gens veulent faire, il y a CC65 qui fait ca très bien.

Le but du OSDK est de fournir une solution relativement optimale pour faire des programmes Oric aussi bons que possible, ce qui implique pas mal de contraintes, dont le fait de ne pas rajouter de code non optimisé.
So, how can be possible to sort all of that out without those functions.
- pop :
Totally useless in c (and in Basic too !)
- plot and scrn :
thank you debug :

Code: Select all

#define plot(X,Y,C) poke(0xBB80+(X)+(Y)*40,C)
#define scrn(X,Y) peek(0xBB80+(X)+(Y)*40)
- plot a string :
- either you are rewriting a function for yourself :

Code: Select all

void plots(char x_pos,char y_pos, const char *ptr_message)
{
	int unsigned start_adr=0xBB80+x_pos+y_pos*40;
	int unsigned len=strlen(ptr_message);
	int unsigned i;
	for (i=0;i<len;i++) poke(start_adr+i,ptr_message[i]);	
}

or you can use the AdvancePrint function (in the Hello world advanced sample), if you want something really fast.
- wait :

Code: Select all

#include <time.h>
  void wait(unsigned int wait_cs)
 {
	clock_t TIME0;
  
	TIME0 = clock();
	do;
	while ( (clock()-TIME0)<wait_cs );
 }
wiich should work but it does not...
or if you rely on an atmos :

Code: Select all

void wait(unsigned int wait_cs)
 {
 	//we use TIMER3 at adress #276-#277
	doke(0x0276,wait_cs);
	while ( deek(0x0276)>0){};
}

Post Reply