Code Monkey home page Code Monkey logo

Comments (14)

visrealm avatar visrealm commented on July 22, 2024 1

It works! Thank you so much, dude! Also, I assume you mean "LCD_CMD_DISPLAY_ON" instead of "LCD_DISPLAY_ON"

Nice one!

Yeah, that's what I meant (was on my phone).

Good luck with your project!

from vremulcd.

visrealm avatar visrealm commented on July 22, 2024

As you've seen there are no formal C examples. The only place I'm personally using it is in my HBC-56 Emulator: https://github.com/visrealm/hbc-56/blob/master/emulator/src/devices/lcd_device.c Here, I'm rendering to an SDL texture.

The key steps are:

#define LCD_WIDTH 20
#define LCD_HEIGHT 4

VrEmuLcd      *lcd = vrEmuLcdNew(LCD_WIDTH, LCD_HEIGHT, EmuLcdRomA00);

// send it commands:
vrEmuLcdSendCommand(lcd, LCD_CMD_FUNCTION | LCD_CMD_FUNCTION_LCD_2LINE | 0x10);
vrEmuLcdSendCommand(lcd, LCD_CMD_CLEAR);
vrEmuLcdSendCommand(lcd, LCD_CMD_HOME);

// send it data
vrEmuLcdWriteByte(lcd, 'H');
vrEmuLcdWriteByte(lcd, 'e');
vrEmuLcdWriteByte(lcd, 'l');
vrEmuLcdWriteByte(lcd, 'l');
vrEmuLcdWriteByte(lcd, 'o');

// or cheat
vrEmuLcdWriteString(lcd, " world!");

// then periodically, render it. 
vrEmuLcdUpdatePixels(lcd);   // generates a snapshot of the pixels state

for (int y = 0; y < vrEmuLcdNumPixelsY(lcd); ++y) {
  for (int x = 0; x < vrEmuLcdNumPixelsX(lcd); ++x) {
    // do whatever you like with the pixel information. render it to a texture, output it to  a console, whatever
   // values returned are:  -1 = no pixel (character borders), 0 = pixel off, 1 = pixel on
    char pixel = vrEmuLcdPixelState(lcd, x, y);
  }
}

I'll consider adding a more minimal example.

from vremulcd.

OfficialPixelBrush avatar OfficialPixelBrush commented on July 22, 2024

Hm. Just keeps on spitting errors at me, oddly enough.

Keeps on saying 'vrEmuLcd' isn't declared, which is quite odd...

from vremulcd.

visrealm avatar visrealm commented on July 22, 2024

Are you able to share your code?

One possible issue could be the __declspec. If you're statically linking, you'll need to define VR_LCD_EMU_STATIC.

from vremulcd.

OfficialPixelBrush avatar OfficialPixelBrush commented on July 22, 2024

Right here!
Pix80/Emu/pix80.c

from vremulcd.

visrealm avatar visrealm commented on July 22, 2024

Replace

	// LCD init
	VrEmuLcd *lcd = vrEmuLcd.vrEmuLcdNew(LCD_WIDTH, LCD_HEIGHT, EmuLcdRomA00);

With

	// LCD init
	lcd = vrEmuLcdNew(LCD_WIDTH, LCD_HEIGHT, EmuLcdRomA00);
	

Also, if you're just compiling VrEmuLcd.c in to your project directly, as I mentioned previously, you'll need to add the

VR_LCD_EMU_STATIC=1

Preprocessor directive to your project. The reason for this is the way the functions are defined is different if you're compiling it as a dll.

from vremulcd.

OfficialPixelBrush avatar OfficialPixelBrush commented on July 22, 2024

All I'm doing is including the vrEmuLcd.h file, the vrEmuLcd.c file nowhere to be found.
I've updated my code to be a little bit more detailed, and to explain the situation more clearly. Hope it helps.

from vremulcd.

visrealm avatar visrealm commented on July 22, 2024

No worries. As I mentioned in the previous response, you need to fix that line. Replace the line with this

lcd = vrEmuLcdNew(LCD_WIDTH, LCD_HEIGHT, EmuLcdRomA00);

You already declared lcd in global scope near the top, so don't need to do it again. Also, vrEmuLcd.vrEmuLcdNew is incorrect. It's just vrEmuLcdNew.

from vremulcd.

OfficialPixelBrush avatar OfficialPixelBrush commented on July 22, 2024

Right. But the issue with that is is the fact it then spits out
"tcc: error: undefined symbol 'vrEmuLcdNew'", reason I tried vrEmuLcd.vrEmuLcdNew instead

from vremulcd.

visrealm avatar visrealm commented on July 22, 2024

Ok. I haven't used tcc before, so I downloaded it and gave it a try.

With this command-line:

tcc -DVR_LCD_EMU_STATIC=1 vrEmuLcd.c pix80.c

It compiles fine. However I had to make one change. For some reason, tcc wants a semi-colon here: vrEmuLcd.h:26

#undef byte
;
typedef unsigned char byte;

msvc, gcc and emscripten are all fine with out it, so not sure about that one.

from vremulcd.

OfficialPixelBrush avatar OfficialPixelBrush commented on July 22, 2024

Awesome! It compiled!
Though it seems that every single pixel is a border pixel, even if I just use the example code you provided above.

It's progress none the less!

from vremulcd.

visrealm avatar visrealm commented on July 22, 2024
vrEmuLcdSendCommand(lcd, LCD_CMD_DISPLAY | LCD_DISPLAY_ON);

from vremulcd.

OfficialPixelBrush avatar OfficialPixelBrush commented on July 22, 2024

It works! Thank you so much, dude!
Also, I assume you mean "LCD_CMD_DISPLAY_ON" instead of "LCD_DISPLAY_ON"

from vremulcd.

OfficialPixelBrush avatar OfficialPixelBrush commented on July 22, 2024

Thank you!

from vremulcd.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.