Hi all.
I've been pulling my hair out trying to open console.device.
I can open the screen, window, port and IORequest fine.. but it fails when I call OpenDevice().
I have followed the instructions from the ROM Kernel Reference Manual and I am using the Amiga C/C++ extension for VSCode.
Can someone please tell me what I'm doing wrong?
Thanks so much!
Part 1 of code:
Code:
#include "support/gcc8_c_support.h"
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/graphics.h>
#include <graphics/view.h>
#include <proto/intuition.h>
#include <intuition/intuition.h>
#include <devices/conunit.h>
#include "amiga.h"
struct ExecBase *SysBase;
struct DosLibrary *DOSBase;
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
enum ScreenMode {
PAL_NON_INTERLACED = 256,
NTSC_NON_INTERLACED = 200,
PAL_INTERLACED = 512,
NTSC_INTERLACED = 400
};
struct Config {
enum ScreenMode screenMode;
} config;
int main() {
SysBase = *((struct ExecBase**)4UL);
void openLibraries();
void closeLibraries();
void configureApp();
void initVideo(struct Screen**, struct Window**);
struct Window *window;
struct Screen *screen;
struct View *view;
struct IOStdReq *consoleIO;
struct Port *consoleWritePort;
openLibraries();
configureApp();
initVideo(&screen, &window);
consoleWritePort = CreatePort("mycon.write",0);
if (consoleWritePort == NULL) {
KPrintF("Unable to create port!\n");
return 1;
}
consoleIO = CreateStdIO(consoleWritePort);
if (consoleIO == NULL) {
KPrintF("Unable to create Console IO Request!\n");
return 1;
}
consoleIO->io_Data = (APTR) window;
consoleIO->io_Length = sizeof(*window);
BYTE a;
if (a = !OpenDevice("console.device", CONU_STANDARD, consoleIO, CONFLAG_DEFAULT)) {
KPrintF("Unable to open console.device!");
return 1;
}
UBYTE *susan = "You can't do that to a susan!";
consoleIO->io_Data = susan;
consoleIO->io_Length = strlen(susan);
consoleIO->io_Command = CMD_WRITE;
DoIO(consoleIO);
Wait(1 << window->UserPort->mp_SigBit);
if (!(CheckIO(consoleIO)))
AbortIO(consoleIO);
DeletePort(consoleWritePort);
CloseDevice(consoleIO);
CloseWindow(window);
FreeMem(screen->Font, sizeof(struct TextAttr));
CloseScreen(screen);
OpenWorkBench();
closeLibraries();
return 0;
}