home *** CD-ROM | disk | FTP | other *** search
- /*-> c.ami_amiga */
-
- /* Modifications for ANSI C under RISC-OS:
- *
- * Date Modification
- * 11-may-90 modifications of headers
- * 11-may-90 removal of non-relevant definitions
- * 23-may-90 modification of display() and sizes
- */
-
- #include "string.h"
- #include "ctype.h"
-
- #include "wimp.h"
- #include "wimpt.h"
- #include "win.h"
- #include "event.h"
- #include "menu.h"
- #include "dbox.h"
- #include "werr.h"
- #include "flex.h"
- #include "bbc.h"
- #include "coords.h"
-
- #include "types.h"
- #include "hp11.h"
- #include "ami_amiga.h"
-
- #define CHAROFFX 4 /* offset in display for first char */
- #define CHAROFFY 6
- #define CHARWIDTH 32 /* Size of char */
- #define CHARHEIGHT 26
-
- #define CR 13
- #define BS 8
- #define ESC 27
-
- /* Annunciator icon info */
- extern wimp_i hp11_display, hp11_user, hp11_f, hp11_g;
- extern wimp_i hp11_rad, hp11_grad, hp11_pgrm;
-
- extern wimp_w hp11_win_handle;
- extern dbox hp11_dbox_handle;
-
- extern struct Border *hp11char[]; /* Character descriptions (as connected
- lines) */
-
- /* Wait for latest key to be released, returns true if button released
- over key (valid only for mouse) */
- BOOL RelKey()
- {
- return(TRUE);
- }
-
- /* Display s */
- void Display(s)
- register char *s;
- {
- wimp_wstate hp11_wind;
- wimp_icon hp11_disp;
- wimp_redrawstr hp11_redraw;
-
- hp11_s = s; /* set up global variable so event handler can find string */
-
- /* Find coords of display and mark as invalid. This will cause the
- Window Manager to clear the display and issue one or more redraw
- requests. These must be handled by the raw event handler. */
- wimp_get_wind_state(hp11_win_handle, &hp11_window);
- wimp_get_icon_info(hp11_win_handle, HP11_DISPLAY, &hp11_disp);
-
- /* I'm not sure if this next bit is right
- -- shouldn't both boxes be the same? */
- coords_box_toscreen(&hp11_disp.box, (coords_cvtstr *)&hp11_wind.o.box);
-
- hp11_redraw.w = -1;
- hp11_redraw.box.x0 = hp11_disp.box.x0;
- hp11_redraw.box.y0 = hp11_disp.box.y0;
- hp11_redraw.box.x1 = hp11_disp.box.x1;
- hp11_redraw.box.y1 = hp11_disp.box.y1;
- wimp_force_redraw(&hp11_redraw);
-
- /* now set a flag to indicate to event handler what should be redrawn */
- }
-
- void Display_2(wimp_redrawstr hp11_redraw)
- {
- void DrawChar(struct Border *, int, int);
-
- int posx, posy;
- int chr;
- BOOL redraw;
- wimp_icon hp11_disp;
-
- do {
- wimp_get_rectangle(&hp11_redraw, &redraw);
- while (redraw) {
- /* Initial position */
- wimp_get_icon_info(hp11_win_handle, HP11_DISPLAY, &hp11_disp);
- /* I'm not sure if this next bit is right
- -- shouldn't both boxes be the same? */
- coords_box_toscreen(&hp11_disp.box, (coords_cvtstr *)&hp11_redraw.box);
- posx = hp11_disp.box.x0 + CHAROFFX;
- posy = hp11_disp.box.y1 - CHAROFFY;
-
- while (*hp11_s) {
- switch (*hp11_s) { /* Position of char in char array */
- case '0': case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9': chr = *hp11_s - '0'; break;
- case '-': chr = 10; break;
- case 'E': chr = 11; break;
- case 'r': chr = 12; break;
- case 'o': chr = 13; break;
- case 'R': chr = 14; break;
- case 'u': chr = 15; break;
- case 'n': chr = 16; break;
- case 'i': chr = 17; break;
- case 'g': chr = 18; break;
- case '.': chr = 19; break;
- case ',': chr = 20; break;
- case 'P': chr = 21; break;
- default: chr = -1; break;
- }
- if (chr != -1)
- DrawChar(hp11char[chr], posx, posy);
- if (*hp11_s != '.' && *hp11_s != ',') posx += CHARWIDTH;
- hp11_s++;
- }
- }
- } while (redraw);
- }
-
- void DrawChar(struct Border *hp11char, int posx, int posy)
- {
- int i, x;
- WORD *pos;
- struct Border *stroke;
-
- stroke = hp11char;
- do {
- pos = stroke->SegDef;
- for (i=1; i<4; i++, pos++) {
- x = *pos;
- bbc_move(posx+x, posy-*(++pos));
- x = *(++pos);
- bbc_draw(posx+x, posy-*(++pos));
- }
- stroke = stroke->NextSeg;
- } while (stroke != NULL);
- }
-
- /* Display the indicators */
- void Dispf(on)
- int on;
- {
- if(on)
- wimp_set_icon_state(hp11_win_handle,HP11_f,wimp_ISELECTED,wimp_ISELECTED);
- else
- wimp_set_icon_state(hp11_win_handle, HP11_f, 0, wimp_ISELECTED);
- }
-
- void Dispg(on)
- int on;
- {
- if(on)
- wimp_set_icon_state(hp11_win_handle,HP11_g,wimp_ISELECTED,wimp_ISELECTED);
- else
- wimp_set_icon_state(hp11_win_handle, HP11_g, 0, wimp_ISELECTED);
- }
-
- void DispUSER(on)
- int on;
- {
- if(on)
- wimp_set_icon_state(hp11_win_handle, HP11_USER, wimp_ISELECTED,
- wimp_ISELECTED);
- else
- wimp_set_icon_state(hp11_win_handle, HP11_USER, 0, wimp_ISELECTED);
- }
-
- void DispG(on)
- int on;
- {
- if(on)
- wimp_set_icon_state(hp11_win_handle, HP11_GRAD, wimp_ISELECTED,
- wimp_ISELECTED);
- else
- wimp_set_icon_state(hp11_win_handle, HP11_GRAD, 0, wimp_ISELECTED);
- }
-
- void DispRAD(on)
- int on;
- {
- if(on)
- wimp_set_icon_state(hp11_win_handle, HP11_RAD, wimp_ISELECTED,
- wimp_ISELECTED);
- else
- wimp_set_icon_state(hp11_win_handle, HP11_RAD, 0, wimp_ISELECTED);
- }
-
- void DispPRGM(on)
- int on;
- {
- if(on)
- wimp_set_icon_state(hp11_win_handle, HP11_PGRM, wimp_ISELECTED,
- wimp_ISELECTED);
- else
- wimp_set_icon_state(hp11_win_handle, HP11_PGRM, 0, wimp_ISELECTED);
- }
-
- void beep(void)
- {
- bbc_vdu(7);
- }
-
- void EditOn(void){}
- void EditOff(void){}
- void sleep(void){}
- void MenusOn(void){}
- void MenusOff(void){}
- void ArcCleanUp(void){}
- void WaitSync(long tick)
- {
- int x, y, i;
-
- for (i=1, i < (int)tick; i++) {
- os_byte(19, &x, &y);
- }
- }
-