I am creating text editor using C. Can you explain these macros?
#define Ad (unsigned char far *)0xb8000000
#define Pos(y,x) (2*((y)*80+x))
#define Write(y,x,ch) *(Ad+Pos(y,x))=ch
#define WriteA(y,x,fb) *(Ad+1+Pos(y,x))=fb
Back in the dark ages of console programs, people used to output text by writing directly to the screen buffer.
The console screen buffer is organized as a continuous array of pairs of bytes, describing the displayed character and its attributes (color, background color, and eventually blinking).
In your case, the screen buffer seems to be at 0xb800000 (Ad). Pos translates a screen position (y,x) to a memory offset in the screen buffer, assuming a screen width of 80.
Write changes the displayed character at the specified position, while WriteA changes the character's color.
My goodness, it's like 1990 all over again...
I don't want to be harsh, but you're going to struggle to write a text editor if you're struggling at this level.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With