flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > Ultimate C Library - 700+ Functions, 75+ Examples, Graphics

Author
Thread Post new topic Reply to topic
soul_master



Joined: 30 Jun 2023
Posts: 7
soul_master 30 Jun 2023, 20:31
Ultimate C Library (TinyCC) - 700+ Functions, 75+ Examples, Graphics, Icons, Fonts

My Ultimate Programming Package: Includes Editor, Compiler, Library (700+ functions!), 75+ Examples,
Graphics, Fonts, Icons, etc.

Download: https://github.com/starpow3r/ez

* Easiest C programming package/library for TinyCC
* 75+ Examples. Just one-click (NAME.BAT) to compile/build/run,
and the program instantly appears in 1-3 seconds. No nonsense.
Press Esc (Escape) to exit.
* All the essentials needed to create programs, interfaces, games
and graphics demonstrations.
* Includes TinyCC compiler and Notepad++ editor
* 700+ Library Functions! Hand written over the years.
Functions use the simplest, most logical names that are easiest
to remember - load_image, draw_image, open_file, save_file,
load_font, text_copy, draw_text, draw_gradient. Draws everything
from scratch in the language without using OS. Modern programmers
are dependent on the OS for everything, so their code is incompatible
with other systems like Android (C4Droid > Enable TCC)
* Includes Custom Graphics, Fonts and Icons (/MEDIA/).
* Portable algorithms for any system. Every single pixel, line, image,
font, etc, is drawn directly to memory using only CPU instructions and
no OS specific graphics
* Tutorial: Introduction to C (/HELP/). See HELP/INDEX.HTML for tutorial,
and HELP/REFERENCE.HTML for a list of functions
* For TinyCC, the smallest fully featured C compiler. Many times
faster than other compilers. Visual C++ disadvantages: Big (gigabytes!),
wasteful, slow compile/build, illogical design, setup takes forever.
* Author has been programming since 1988 at age 11 with BASIC on
Commodore 64, then C/C++ and assembler in DOS mode 13h, then scripting
languages (HTML, CSS, JS, PHP). Made countless programs, libraries, languages,
compilers, assemblers (for various cpus), disassemblers, human intelligence
demonstrations, world simulations, science programming, and much more.
* Personal statement: "My code is entirely unique, unlike anything you've ever
seen before. It is the easiest to understand and use, the clearest,
most logical, concise, compact and efficient code ever written. You won't
find code like this anywhere else online. I have the greatest love for
programming that I want to share with the world. I sincerely hope my code
helps and teaches programmers, and inspires them to be creative, innovative,
and think differently. To me, life is all about having positive effects on people.
It is the only thing that makes us truly happy".


SETUP

Just copy /TCC/ folder (in /BINARY/) to: C:/ (C:/TCC/TCC.EXE). See /BINARY/ for TinyCC and Notepad++.

This example creates an image, loads it (space.bmp), and draws it in only 10 lines. What could be easier? C programmers rewrite 150-300+ lines of code to do this in WinAPI with WinMain for every project.
Code:
#include "visual.h"

IMAGE image;

event_create
  create_screen(512, 512+36);
  set_title("Draw Image");
  load_image(&image, "space");
ende

event_draw
  draw_image_at(&image, 0, 40);
ende    


See HELP/INDEX.HTML for tutorial, and HELP/REFERENCE.HTML for a list of functions.


Description:
Filesize: 1.1 MB
Viewed: 1221 Time(s)

examples.jpg


Post 30 Jun 2023, 20:31
View user's profile Send private message Reply with quote
soul_master



Joined: 30 Jun 2023
Posts: 7
soul_master 30 Jun 2023, 21:02
A custom "s/printf" that supports binary. See INCLUDE/TEXT.H
Code:
//////////////////// PRINT/X /////////////////////

// a custom "s/printf" that supports binary

// %%      = one %
// %r      = return
// %0      = alignment: %08h, %032b
// %s/%t   = "text"/"string"
// %c      = 'c'haracter
// %u      = unsigned 32BIT decimal
// %i/%d   = signed 32BIT decimal
// %x/X/%h = hexadecimal. uppercase
// %b      = binary: 1010b = 10/0xA

// written in only a few lines! one of the most
// useful functions for text/string processing

text print(text p, text t, ...) {
  int n, c, align;
  text q;
  va_list va;
  va_start(va, t);
  align=0;
  while (*t) { // while text, until end 0
    c=*t;
    if (c==0xA) { // convert returns \n
      *p++=0xD, // inside "strings\n"
      *p++=0xA,
      t++;
      continue;
    }
    if (c!='%') { // copy next character
      *p++=*t++; // if not %
      continue;
    }
    t++, c=*t;
    if (c=='%') { // use %% for one %
      *p++='%', t++;
      continue;
    }
    if (c=='r') { // %r = return
      *p++=0xD;
      *p++=0xA, t++;
      continue;
    }
    if (c=='0') { // alignment: %08b
      t++;
      if (!is_number(*t)) { // error
        *t++='?';
        break;
      }
      if (!is_number(t[1])) // single digit?
        align=*t++-'0';
      else
        align=(t[1]-'0')+ // 2 decimal digits
          ((t[0]-'0')*10),
          t+=2;
      c=*t;
    }
    if (c=='t' or c=='s') { // "text/string"
      q=va_arg(va, text);
      n=text_n(q);
      while (align-n>0) // align with spaces?
        *p++=' ', align--;
      p=text_copy(p, q);
      t++;
      continue;
    }
    n=va_arg(va, int); // get number
    if (c=='c') { // character
      *p++=n, t++;
      continue;
    }
    if (c=='u') // convert integer to text
      p=u2ta(n, p, align);
    else if (c=='i' or c=='d') // signed/int
      p=i2ta(n, p, align);
    else if (c=='x' or // hexadecimal
      c=='X' or c=='h')
      p=h2ta(n, p, align);
    else if (c=='b') // binary
      p=b2ta(n, p, align);
    else
      *p++='?'; // unrecognized suffix
    align=0;
    t++;
    continue;
  }
  *p=0;
  va_end(va);
  return p;
}

/* example: printf alternative. display "text"
to console.

char my_console[1024];

#define my_printf(p...) \
  print(my_console, p), \
  printf(my_console)

notice macro with variable arguments. syntax:

#define call_printf(p...) printf(p)
*/    


Last edited by soul_master on 30 Jun 2023, 21:29; edited 1 time in total
Post 30 Jun 2023, 21:02
View user's profile Send private message Reply with quote
soul_master



Joined: 30 Jun 2023
Posts: 7
soul_master 30 Jun 2023, 21:13
Create image manually from pixel[] array. See EXAMPLES/DRAW/CREATE_IMAGE.C/EXE
Code:
// CREATE A SMALL EXAMPLE IMAGE MANUALLY FROM
// AN ARRAY OF PIXELS/COLORS, THEN SET IMAGE
// PIXELS, AND DRAW IT ENLARGED BY 4000%

#include "visual.h"

IMAGE image1;

// small face image: 8x8x32 

#define B 0
#define W 0xFFFFFF
#define Y 0xFFFF00

color face[] = {
  W,W,B,B,B,B,W,W, // head outline
  W,B,Y,Y,Y,Y,B,W,
  B,Y,B,Y,Y,B,Y,B, // 2 eyes
  B,Y,B,Y,Y,B,Y,B,
  B,Y,Y,Y,Y,Y,Y,B,
  B,Y,B,B,B,B,Y,B, // mouth
  W,B,Y,Y,Y,Y,B,W,
  W,W,B,B,B,B,W,W  // chin
};

event_create
  create_screen(328, 360);
  set_title("Create Image");
  create_image(&image1, 8, 8);
  set_image_pixels(&image1, face);
ende

event_draw
  move_image(&image1, 4, 36);
  draw_image_size_p(&image1, 4000);
ende    
Post 30 Jun 2023, 21:13
View user's profile Send private message Reply with quote
sylware



Joined: 23 Oct 2020
Posts: 371
Location: Marseille/France
sylware 01 Jul 2023, 16:17
I see only a rar file once cloned from github? (I don't have unrar on linux, can we get a .tar.xz or .tar.bz2 or .tar.gz?)
Post 01 Jul 2023, 16:17
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 19871
Location: In your JS exploiting you and your system
revolution 01 Jul 2023, 16:26
sylware wrote:
I don't have unrar on linux
It is available. Mint has it by default.
Post 01 Jul 2023, 16:26
View user's profile Send private message Visit poster's website Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2343
Furs 01 Jul 2023, 17:25
Just use 7zip, it supports unrar.

But the code.rar seems to only have TCC and Notepad++ binaries…? Where's the actual code?
Post 01 Jul 2023, 17:25
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1378
Location: Piraeus, Greece
Picnic 30 Jul 2023, 09:40
Hello soul_master,

Impressive work mate. Everything ran flawlessly on my Windows 10 PC. I like that you chose TCC, I use it too occasionally (I got tired of the endless GBs of the studios). There is a lot of material to study.
Post 30 Jul 2023, 09:40
View user's profile Send private message Reply with quote
soul_master



Joined: 30 Jun 2023
Posts: 7
soul_master 18 Sep 2023, 02:43
Picnic: Thanks. My code is not perfect. Always improving. Years ago, noticed a handful of small games on a page created by you. Nice.

Uploaded 2 repositories: https://github.com/starpow3r/ 1. "EZ" library with 75+ examples. Includes TCC and editor, 100s of FREE graphics, fonts, icons, etc. See /media/. 2. MDV: Multiple Document Viewer

Updates: Renamed draw_box_z/fade_z/shade_z to draw_box/fade/shade. Removed temporary _z suffix. Created examples/control for custom controls (include/control/). Organized font.h into include/font/. Now easier to manage, and modular with defines to include only what's needed instead of the entire library (TCC inserts all functions inside the executable even if not used/referenced, so #ifdef is needed). Incorporated match (include/match.h). Created examples/parse/ for examples related to scripts and compilers. Updated custom console (examples/console/) to use main_c() with event interface. New examples/console/text tests functions in include/text.h. Fixed file.h > extract_file/name/ext/etc. Renamed temporary STYLE1 to GRAPHICS. Now, there are 2 styles, a generic GRAPHICS style for any shape, and a higher level STYLE for controls with text, image, etc. Upgraded code_2_html_visual (in examples/parse/). A visual interface that converts source code to HTML. Supports multiple languages: C, ASM, HTML, CSS, JS, PHP. Resolution 1920x1080. Toolbar: "Paste Source Code", "Copy Output HTML", "View in Browser". Main source is only about 700 lines. New draw_table examples in several colors/styles. See examples/font/draw_my_character2 that draws my custom character set in a big colorful table. Updated Notepad++ to support all keywords.
Post 18 Sep 2023, 02:43
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.