Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Time is an illusion. Lunchtime doubly so." -- Ford Prefect, _Hitchhiker's Guide to the Galaxy_


devel / comp.lang.c / Re: Commandline parsing

Re: Commandline parsing

<377a9e71-7878-42dd-a91d-2cf911d3c23bn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26882&group=comp.lang.c#26882

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:7ee:b0:767:e97b:38ab with SMTP id k14-20020a05620a07ee00b00767e97b38abmr33939qkk.4.1690833478525;
Mon, 31 Jul 2023 12:57:58 -0700 (PDT)
X-Received: by 2002:a05:6870:956f:b0:1bb:7345:a595 with SMTP id
v47-20020a056870956f00b001bb7345a595mr13826103oal.1.1690833478258; Mon, 31
Jul 2023 12:57:58 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 31 Jul 2023 12:57:57 -0700 (PDT)
In-Reply-To: <7e13f4c1-d070-422f-bee2-b6eae71ad98cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.55; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.55
References: <a631f98c-5482-4e90-9a0d-8ce49e447153n@googlegroups.com>
<00a6ddfb-2660-41b0-94d7-48a1d764577an@googlegroups.com> <0f2dce28-ac19-4613-8796-21f721eb97a6n@googlegroups.com>
<ae8bdb37-39bd-400c-aa28-8056b675d501n@googlegroups.com> <706cbf3a-4e6f-4466-a139-2511f00a7e8an@googlegroups.com>
<7e13f4c1-d070-422f-bee2-b6eae71ad98cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <377a9e71-7878-42dd-a91d-2cf911d3c23bn@googlegroups.com>
Subject: Re: Commandline parsing
From: profesor...@gmail.com (fir)
Injection-Date: Mon, 31 Jul 2023 19:57:58 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 245
 by: fir - Mon, 31 Jul 2023 19:57 UTC

poniedziałek, 31 lipca 2023 o 21:38:02 UTC+2 fir napisał(a):
>
> some example that a;ready compiles https://fastupload.io/pakja4Guq471ngn/file
>
> input is in input.c output is in furia-output.exe
>
> it generally tends to be extremally simplified extended/modernized c 'variant' or how to call it
>
> rhe funny pieces
>
> void SetupLight
> SetPointLight 0 1 -1100.0 0.0 0.0 7000.0 50000.0 0.30 1.9 1.3 1.3 0.01 0.01 0.01 0.18 1.1 1.1 1.1 0.01 0.01 0.01
> SetPointLight 1 3 1100.0 500.0 500.0 7000.0 50000.0 0.30 1.3 1.9 1.3 0.01 0.01 0.01 0.18 1.1 1.1 1.1 0.01 0.01 0.01
> SetPointLight 2 3 0.0 -1500.0 -500.0 7000.0 50000.0 0.30 1.3 1.3 1.9 0.01 0.01 0.01 0.18 1.1 1.1 1.1 0.01 0.01 0.01 ;
>
> this is most simplified function definition - seems qyite okay (and it compiles so its proven to work)
>
> void ProcessMouseMove mouse_x mouse_y { }
> void ProcessKeyDown key { }
> void OnResize { RunFrame }
>
> alseo 3 function definitions
>
> void RunFrame int advance
> {
> Initialise, ClearFrameData 0x666666
> DrawLine3d 100.0 100.0 0.0 100.0 -100.0 0.0 0xffffff
> DrawLine3d 100.0 -100.0 0.0 -100.0 -100.0 0.0 0xffffff
> DrawLine3d -100.0 -100.0 0.0 -100.0 100.0 0.0 0xffffff
> DrawLine3d -100.0 100.0 0.0 100.0 100.0 0.0 0xffffff
> DrawDot3d 0.0 0.0 100.0 20.0 0x557788
> DrawDot3d 0.0 0.0 150.0 30.0 0x557722
> DrawDot3d 0.0 0.0 -100.0 10.0 0xaa7788
> DrawCloud1, DrawCloud2, DrawCloud21,
> DrawCloud3
> DrawSomeText2F 0xa99999 0x666666 10 20 "hello, this is example program compiled by fir's furia compiler \x00"
> }
>
> same
>
> ints array
>
> new type - resizable array of ints
> may be iaccesed by array[i] using array.size,
> size just may be changed by array.size=29; array.size=100; etc
> has alo method add: array.add(10)
>
> i generate code in assembly for that, i got no head in that so i a bit forgot bout the code for eemiting resizes are sorta like
>
> void EmitResize(chunk name, int size) //for seting new size
> {
> FlushOutAsm("\n push %d", size );
> FlushOutAsmChunkPE("\n push (", name, ") ");
> FlushOutAsm("\n call (\"msvcrt.dll\"->realloc)");
> FlushOutAsmChunkPE("\n mov (", name, ") eax ");
> FlushOutAsm("\n pop edx");
> FlushOutAsm("\n pop edx");
> FlushOutAsmChunkPE("\n mov (", name, ") eax ");
> FlushOutAsm("\n mov eax %d", size);
> FlushOutAsmChunkPE("\n mov (", name, "_size) eax ");
> }
>
> void EmitAdd2DynamicArrayByLabel(chunk name, chunk added) //for add
> {
> //inc size by one
> FlushOutAsmChunkPE("\n mov eax (", name, "_size) ");
>
> FlushOutAsm("\n push eax"); //use to assign
>
> FlushOutAsm("\n add eax 4 ");
> FlushOutAsmChunkPE("\n mov (", name, "_size) eax ");
> //reallock
> FlushOutAsm("\n push eax");
> FlushOutAsmChunkPE("\n push (", name, ") ");
> FlushOutAsm("\n call (\"msvcrt.dll\"->realloc)");
> FlushOutAsmChunkPE("\n mov (", name, ") eax ");
> FlushOutAsm("\n pop edx");
> FlushOutAsm("\n pop edx");
> //add value
> FlushOutAsm("\n pop ebx ");
> FlushOutAsmChunkPE("\n mov eax (", name, ") ");
> FlushOutAsm("\n add eax ebx");
> FlushOutAsmChunkPE("\n mov ebx (", added, ")");
> FlushOutAsm("\n mov (eax) ebx ");
>
>
> }
>
> what i did wrong now are loops and ifs.. i tried to simplify loops maximally
> and made it liek this
>
> 1:100: tab.add(i)
>
> which is loop from 1 to 100, but its clearly wrong need something better
> close problem i got also with ifs..but the pure meat of function definitions and calling above is real nice

i made more syntax options and as far as i know it laso compiles:

//////////////////////////////
import "green_fire.dll" (cdecl) Set3dDrawingMode DrawSomeText2 rand2 ToggleFullscreen ClearFrameData DrawCircle RegisterRunFrame RegisterMouseMove RegisterKeyDown RegisterOnResize SetSleepValue SetScaleOnResize SetupWindow3 (var) frame_size_x frame_size_y frame_bitmap
import "user32.dll" (stdcall) MessageBoxA
import "msvcrt.dll" (cdecl) printf
////////////////////////////////////

def ProcessMouseMove mouse_x mouse_y.

def foo z1 z2 z3 z4:
printf " %d %d %d %d \x00" z1 z2 z3 z4.

def AddBackgrounColor zzz
x = rand2 1 2, background_color += x .

def goo z1 z2 z3 -> z4 z5 z6
{z4=z1+z2, z5=z2+z3, z6=z3+z1}


def doo
{a b c=goo 2 3 4, printf " a %d b %d c %d \x00" a b c }

def ProcessKeyDown last_key_pressed
{
PAGE_UP=33
keyR=0x52
keyG=0x47
keyB=0x42
last_key_pressed?=PAGE_UP {ToggleFullscreen}
last_key_pressed?=0x41 {foo frame_size_x frame_size_y/2 3 4}
last_key_pressed?=0x53 {foo 2|3|4|5,foo 6 7 8 9}
last_key_pressed?=0x43 {MessageBoxA 0 "captionC\x00" "title\x00" 0}
last_key_pressed?=keyR {AddBackgrounColor 0x20}
last_key_pressed?=keyG {AddBackgrounColor 0x2000}
last_key_pressed?=keyB {doo}
}

void RollBackgroundColor: ClearFrameData = 0
;
// ClearFrameData int background_color+=0x010201 ;

void RollCircleColors
int circle_color1+=0x000001
int circle_color2+=0x010000
int circle_color3+=0x000100
int circle_color4+=0x010001 ;

double aa=111111.111111111,
double bb=7.22,
cc=2,
dd=3

void draw_circles {
RollCircleColors
10$r$100$2: DrawCircle frame_size_x/4 frame_size_y/3 r circle_color1;
1$r$100$6: DrawCircle frame_size_x/5*4 frame_size_y/4 r circle_color2;
10$r$70 $4: DrawCircle frame_size_x/6*5 frame_size_y/5*4 r circle_color3;
11$r$70 $4: DrawCircle frame_size_x/6*5 frame_size_y/5*4 r circle_color4;
10$r$100$2: DrawCircle mouse_x mouse_y r 0x991133;
}
void header {
DrawSomeText2 0xffffff|10|20|"this app is compiled by furia \x00"
DrawSomeText2 0xffffff|10|40|" compiler by fir, 2022 \x00"
DrawSomeText2 0xffffff|30|70|"mouse %d %d\x00"|mouse_x|mouse_y
}

void test_operators {
c1 = 0x011111<or>0x020202
c2 = 0x011111<and>0x020202
c3 = 0x011111<xor>0x020202
c4 = 0xc0000000+0x50000010
c5 = 0xc0000000<adc>0x50000010
c12 = 1 <rand> 3
c12 = c12 <and> 0xfff
c1=1*1 | c2=2+2 | c3 = 3/3
c10=c1=c2=c3=333
rr = frame_bitmap[4*(mouse_x+frame_size_x*mouse_y)] + 0x777777
frame_bitmap[4*(mouse_x+frame_size_x*mouse_y)]=rr
c1 = 0x011111<or>0x020202 , c2 = 0x011111<and>0x020202
c3 = 0x0fffff<xor>0x020202 , c4 = 0xc0000000+0x50000010
c5 = 0xc0000000<adc>0x50000010 ,
c1 = 0x01234567<shl>1, c2 = 0x01234567<shr>1,
c3 = 0x01234567<sal>1, c4 = 0x01234567<sar>1,
c5 = 0x01234567<rcl>1, c6 = 0x01234567<rcr>1,
c7 = 0x01234567<rol>1, c8 = 0x01234567<ror>1
c1 = (1+1+1)*2+(1*1)+3*(1+1+3*2)
c2 = (1+1+1)*2+(1*1)+3*(1+1+3*2)

c1 = rand2 10 20
// printf " %d \x00" c1
}
void RunFrame:
RollBackgroundColor,
header,
draw_circles,
test_operators,
draw_variables .

void draw_variables
DrawSomeText2 0xffffff|0|160|"c1 %08x c2 %08x c3 %08x \x00"|c1|c2|c3
DrawSomeText2 0xffffff|0|170|"c4 %08x c5 %08x c6 %08x \x00"|c4|c5|c6
DrawSomeText2 0xffffff|0|180|"c7 %08x c8 %08x c9 %08x \x00"|c7|c8|c9
DrawSomeText2 0xffffff|0|190|"c10 %08x c11 %08x c12 %08x \x00"|c10|c11 c12
aa+=0.010101
// aa = c1
DrawSomeText2 0xffffff|10|220|"test aa %f \x00"|aa .

void OnResize1:a?=2:doo;.
void OnResize2:a?=2:doo;;
void OnResize3{a?=2{doo}}

void OnResize.

void main: RegisterRunFrame &RunFrame, RegisterMouseMove &ProcessMouseMove
RegisterKeyDown &ProcessKeyDown, RegisterOnResize &OnResize, SetSleepValue 40,
SetScaleOnResize 1
// Set3dDrawingMode 1
SetupWindow3 " compiled by fir's furia proto c compiler \x00" 20 20 640 480 320 240 .

some of this above is experimental and wrong some is good (the header part with imported symbols is damn ugly but needed = inles i eventually write asemblation and compilation of dlls or at least reading dlls for symbols by default to import all and not write it by hand

i got also idea to define operators ina form of <some> but now i think its wrong, probably operators must be normal words just as imported functions

SubjectRepliesAuthor
o Commandline parsing

By: Malcolm McLean on Wed, 26 Jul 2023

31Malcolm McLean
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor