My paint() in C

Page 1/2
| 2

Par sp4

Master (214)

Portrait de sp4

07-02-2015, 14:05

Hi, I wrote the follow code for creare the PAINT BASIC with C:

void paint(unsigned char x, unsigned char y, char c)
{
  __asm
       pop hl
	     pop bc
	     pop de
	     dec sp
	     pop af
	     push af
	     inc sp
	     push de
	     push bc
	     push hl
	     push af
       ld h, 4(ix)
       ld l, 5(ix)
       call #0x0069    ; ---> BIOS call for color the screen
       ld 6(ix),#0x9D
	     call #0x0069
  __endasm;
}

my app.c is the follow:

#include "graphic.h"


extern int x, y, a, b, ray, col;

void (*function)() = (void (*)())0xc0;




void main()
{
  color(5,15,5);
  screen(5);
  paint(100,100,6);
  a=100;
  b=100;
  ray=50;
  col=2;
  circle();
  while(1){};
}

If I compile the project I can see a circle but that it hasn't been colored with my paint().
I researched in the web how to create my paint with the right register and call but it doesn't work. Why?

!login ou Inscrivez-vous pour poster

Par Manuel

Ascended (17944)

Portrait de Manuel

07-02-2015, 14:30

Are you sure you want to use the BASIC paint instruction? It's really slow.... You will get the same speed as in BASIC if you use these BASIC routines.

Par sp4

Master (214)

Portrait de sp4

07-02-2015, 14:46

What can I use for color the screen more quickly?
I want write a paint() like the BASIC call but I want than it to be quick.

Par Manuel

Ascended (17944)

Portrait de Manuel

07-02-2015, 16:32

Just load graphics from a file?

Par sp4

Master (214)

Portrait de sp4

07-02-2015, 16:36

Manuel wrote:

Just load graphics from a file?

Not loading graphics from a file, but use the bios call or calling at vdp registers.

Par Manuel

Ascended (17944)

Portrait de Manuel

07-02-2015, 17:27

Do you want to color a rectangular area, the entire screen or an irregular shape with a single color?

Par sp4

Master (214)

Portrait de sp4

07-02-2015, 17:59

Manuel wrote:

Do you want to color a rectangular area, the entire screen or an irregular shape with a single color?

I want color a rectangular area and an irregular shape with a single color.
Is it right my code?

Par Manuel

Ascended (17944)

Portrait de Manuel

07-02-2015, 18:52

For rectangular areas you'd better use a block-fill (there's a VDP command for it). In BASIC that would be line with the ,BF at the end (Block Fill).

For irregular shapes, why would you use paint? What exactly do you want to do? For such cases, it is always fastest and simplest to load graphics from disk.

Par sp4

Master (214)

Portrait de sp4

07-02-2015, 19:55

I want to fill a rectangular area and a circle or a triangle.
For irregular area I don't care.
The important thing is than it's also fast.

Par sp4

Master (214)

Portrait de sp4

07-02-2015, 20:01

Manuel wrote:

For rectangular areas you'd better use a block-fill (there's a VDP command for it).

What is the VDP command for fill the rectangular area?

Par Manuel

Ascended (17944)

Portrait de Manuel

07-02-2015, 21:04

sp4 wrote:

I want to fill a rectangular area and a circle or a triangle.
For irregular area I don't care.
The important thing is than it's also fast.

When doing anything else than rectangular areas: draw the graphics with a drawing program on beforehand and load them from disk into the VRAM and copy them to the place where you need them. Do not draw them 'live' with primitive commands, it will be much slower.

sp4 wrote:
Manuel wrote:

For rectangular areas you'd better use a block-fill (there's a VDP command for it).

What is the VDP command for fill the rectangular area?

LMMV and HMMV. See the documentation in the V99x8 application manual.

Page 1/2
| 2