home *** CD-ROM | disk | FTP | other *** search
- /* Title: -> $.!hp11.amiga.c.arc_hp11 */
-
- /* 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
- * 09-jul-90 correcton of flag handling in ExecIns()
- */
-
- #define TRACE 0
-
- #include <stdlib.h>
- #include <stdio.h>
- #include <math.h>
- #include <string.h>
- #include <ctype.h>
-
- #include "wimp.h"
- #include "wimpt.h"
- #include "win.h"
- #include "event.h"
- #include "baricon.h"
- #include "res.h"
- #include "resspr.h"
- #include "menu.h"
- #include "template.h"
- #include "dbox.h"
- #include "werr.h"
- #include "flex.h"
- #include "heap.h"
- #include "trace.h"
- #include "font.h"
- #include "bbc.h"
- #include "coords.h"
- #include "alarm.h"
- #include "saveas.h"
- #include "os.h"
-
- #include "types.h"
- #include "hp11.h"
- #include "ami_amiga.h"
- #include "io.h"
- #include "support.h"
- #include "ins.h"
- #include "codes.h"
- #include "arc_hp11.h"
- #include "loadsave.h"
-
- #define CHAROFFX 0 /* offset in display for first char */
- #define CHAROFFY 6
- #define CHARWIDTH 30 /* Size of char */
- #define CHARHEIGHT 26
-
- #define CR 13
- #define BS 8
- #define ESC 27
-
- /*---------------------------------------------------------------------------*/
- /*================ CONSTANTS ==============*/
- /*---------------------------------------------------------------------------*/
- /* Menu items */
- #define hp11_menu_info 1
- #define hp11_menu_quit 2
-
- #define HP11_POPUP_STACK 1
- #define HP11_POPUP_SAVE 2
- #define HP11_POPUP_RESET 3
- #define HP11_POPUP_SPEED 4
- #define HP11_POPUP_RADIX 5
-
- #define HP11_POPUP_STATUS 1
- #define HP11_POPUP_PROGRAM 2
- #define HP11_POPUP_DISPLAY 3
-
-
- /* Info box field for the version string */
- #define hp11_info_field 4
-
- /* Radix box fields */
- #define radix_point 0
- #define radix_comma 1
-
- /* Speed box fields */
- #define speed_slow 0
- #define speed_fast 1
-
- /*---------------------------------------------------------------------------*/
- /*================ GLOBAL DATA ==============*/
- /*---------------------------------------------------------------------------*/
- /* The top of the menu tree */
- menu hp11_menu;
- menu hp11_pop_up;
- menu hp11_popup_savemenu;
-
- /* Handle for the hp11 dbox etc.*/
- dbox hp11_dbox_handle, hp11_stack_dbox_handle;
- wimp_w hp11_win_handle, hp11_save_window;
-
- /* information about the display icon */
- wimp_icon hp11_disp;
-
- /* Annunciator icon info */
- wimp_i hp11_display, hp11_user, hp11_f, hp11_g;
- wimp_i hp11_rad, hp11_grad, hp11_pgrm;
-
- /* Flag - is the window open */
- BOOL hp11_window_open = FALSE;
-
- /* Application version */
- static char *hp11_Version_String = "0.5 (28 June 1990)";
-
- BOOL hp11_show_stack = FALSE;
-
- struct Regs hp11r;
- int running, fast, error, skip;
- int PC, retStack[MAXSTACK], retCnt;
- int Flags;
-
- int quit, on = TRUE; /* Set to false to quit */
-
- enum AlarmType Pause = Paused, Wait = Waiting, ProgStep = ProgramStep;
- enum AlarmType *hp11_alarm = &ProgStep;
- int waiting, paused, ProgStepWait, ProgStepTime;
- BOOL oldrun;
-
- int key;
- enum KeyStatus keyflag;
- int comma;
-
- extern struct Border *hp11char[]; /* Character descriptions (as connected
- lines) */
- static char *hp11_s; /* this global pointer will be set equal to the argument
- of Display(), so that the event handler can find it. */
- /*---------------------------------------------------------------------------*/
- /*================ WINDOW FUNCTIONS ==============*/
- /*---------------------------------------------------------------------------*/
-
- void hp11_close_window(void)
- {
- dbox_hide(hp11_dbox_handle);
- dbox_hide(hp11_stack_dbox_handle);
- hp11_window_open = FALSE;
- }
-
- static void hp11_redraw_window(wimp_w handle)
- {
- void Display_2(wimp_redrawstr);
- int more;
- wimp_redrawstr r;
-
- /* Start the redraw */
- r.w = handle;
- wimpt_noerr(wimp_redraw_wind(&r, &more));
- while (more) /* Do the redraw loop */
- {
- Display_2(r);
- wimp_get_rectangle(&r, &more);
- }
- }
-
- /*---------------------------------------------------------------------------*/
- /*================ INITIALISATION ==============*/
- /*---------------------------------------------------------------------------*/
-
- /*---------- Initialise the program, returning TRUE if it was all OK. -------*/
- BOOL ArcInit(void)
- {
-
- /*-------------- Application and RISC_OSlib initialisation ------------------*/
- wimpt_init("HP11"); /* Main Wimp initialisation */
- res_init("HP11"); /* Resources */
- resspr_init(); /* Application sprites */
- template_init(); /* Templates */
- dbox_init(); /* Dialogue boxes */
- flex_init(); /* flex system (for heap) */
- heap_init(TRUE); /* heap memory allocation */
- alarm_init(); /* Alarm system */
-
- /*------------------------ Create the main window ---------------------------*/
- hp11_dbox_handle = dbox_new("hp11");
- if (hp11_dbox_handle == 0) return FALSE; /* Window creation failed */
- hp11_win_handle = (wimp_w)dbox_syshandle(hp11_dbox_handle);
- hp11_dat.hp11_w = hp11_win_handle;
-
- /*----------------------- Create the stack window ---------------------------*/
- hp11_stack_dbox_handle = dbox_new("stack");
- if (hp11_stack_dbox_handle == 0) return FALSE; /* Window creation failed */
-
- /*--------------------------- Create the menus ------------------------------*/
- if(hp11_menu = menu_new("HP11", ">Info,Quit"), hp11_menu == NULL)
- return FALSE; /* Menu create failed */
- if(hp11_pop_up = menu_new("HP11", "Stack,Save,Reset,>Speed,>Radix"),
- hp11_pop_up == NULL) return FALSE;
- if(hp11_popup_savemenu = menu_new("Save", ">Status,>Program,>Display"),
- hp11_popup_savemenu == NULL) return FALSE;
- menu_submenu(hp11_pop_up, HP11_POPUP_SAVE, hp11_popup_savemenu);
-
- /*---------------------- Set up the icon on the icon bar --------------------*/
- baricon("!hp11", (int)resspr_area(), hp11_iconclick);
-
- /*------------------------ Declare the event handlers -----------------------*/
- if (!event_attachmenu(win_ICONBAR, hp11_menu, hp11_menuproc, &hp11_dat))
- return FALSE; /* Unable to attach menu */
- if (!event_attachmenu(hp11_win_handle, hp11_pop_up, hp11_popup_proc,
- &hp11_dat)) return FALSE; /* Unable to attach menu */
- win_register_event_handler(win_ICONBARLOAD, hp11_bar_load, &hp11_dat);
- /*------------------------------ All went ok --------------------------------*/
- return TRUE;
- }
- /*---------------------------------------------------------------------------*/
- /*================ MAIN PROGRAM ==============*/
- /*---------------------------------------------------------------------------*/
-
- /*---------------------------- Main entry point -----------------------------*/
- int main(int argc, char * argv[])
- {
- os_filestr infile;
-
- if (! trace_is_on()) trace_on(); /* this compiles to nothing if TRACE is 0 */
- /* tracef(" argc = %d\n argv[0] = %s\n argv[1] = %s\n", argc, argv[0],argv[1]);*/
-
- if (Init())
- {
- if (argc >= 2)
- { /* load a file identified on the command line */
- infile.action = 12; /* Load named file into memory */
- infile.name = argv[1];
- infile.loadaddr = (int)&hp11r; /* Where to load file */
- infile.execaddr = 0; /* Load at address flag */
- wimpt_complain(os_file(&infile));
- dbox_showstatic(hp11_dbox_handle);
- dbox_raw_eventhandler(hp11_dbox_handle, hp11_dbox_raw_handler,&hp11_dat);
- dbox_eventhandler(hp11_dbox_handle, hp11_dbox_handler, &hp11_dat);
- hp11_window_open = TRUE;
- wimpt_complain(wimp_get_icon_info(hp11_win_handle, HP11_DISPLAY,
- &hp11_disp));
- Disp();
- }
-
- while (TRUE) event_process(); /* The main event loop */
- }
- return 0;
- }
- /*---------------------------------------------------------------------------*/
- /*================ EVENT HANDLERS ==============*/
- /*---------------------------------------------------------------------------*/
- BOOL hp11_dbox_raw_handler(dbox hp11_d, void *ev, void *handle)
- {
- wimp_eventstr *event;
-
- event = (wimp_eventstr *)ev;
- switch (event->e)
- {
- case wimp_EREDRAW: /* need to redraw the display window */
- hp11_redraw_window(event->data.o.w);
- return(TRUE);
- break;
-
- case wimp_ECLOSE: /* hide the calculator display */
- dbox_hide(hp11_dbox_handle);
- dbox_hide(hp11_stack_dbox_handle);
- hp11_window_open = FALSE;
- return(TRUE);
- break;
-
- case wimp_ESEND:
- case wimp_ESENDWANTACK:
- {
- switch (event->data.msg.hdr.action)
- {
- case wimp_MDATASAVE: /* import data */
- hp11_load_ram(handle);
- break;
- case wimp_MDATALOAD: /* insert data */
- case wimp_MDATAOPEN:
- hp11_load_file(handle);
- break;
- default: break; /* ignore other messages */
- }
- }
- }
- return (FALSE); /* this will later include file transfer actions */
- }
-
- void hp11_dbox_handler(dbox hp11_d, void *handle)
- {
- static int code;
- int j;
- enum KeyTypes type;
- dbox_field i;
-
- handle = handle; /* stops compiler warning about non-use of handle */
-
- /* respond to each type of calculator key click (reference by key-code) */
- i = dbox_get(hp11_d);
-
- if (!waiting) {
- if (i < 36) key = (int)(i-1);
- else key = (int)i;
- overflow = FALSE;
- if (running || paused) /* Run or paused mode */
- {
- alarm_remove(ProgStepTime, (void *)hp11_alarm);
- error = FALSE;
- running = FALSE; /* User pressed a key */
- oldrun = FALSE;
- Disp();
- }
- else /* normal mode operation */
- {
- if (error) {
- error = FALSE;
- Disp();
- }
- else {
- type = ReadKey(&code);
- if (type != Null) {
- if (!inprog) { /* not in program entry mode */
- switch (type) { /* Read an instruction/action */
- case Action:
- ExecAction(code); /* Execute corresponding action */
- break;
- case Instruction:
- ExecIns(code); /* Interpret instruction */
- break;
- default:
- break;
- };
- if (!error && !waiting) Disp();
- }
- else { /* in program entry mode */
- DisplayLine();
- switch (type) {
- case Instruction: /* Save it */
- if (lastIns == MAXPROG) Error('4'); /* Memory full */
- else {
- for (j = lastIns; j > PC; j--) Prog[j + 1] = Prog[j];
- /* Move program up */
- lastIns++;
- Prog[++PC] = code; /* store instruction */
- retCnt = 0; /* Empty return stack */
- };
- break;
- case Action: /* Act on it */
- if (code >= IGTO_LINE) GTOLine(code - IGTO_LINE);
- else switch (code) {
- case ION: on = inprog = !RelKey(); break; /* Allow user to
- change his mind */
- case IP_R: case IRESET:
- inprog = FALSE; DispPRGM(FALSE); break;/* exit prog mode */
- case IMEM: MEM(); break;
- case IBACK: /* delete line */
- if (PC != 0) {
- for (j = PC; j < lastIns; j++) Prog[j] = Prog[j + 1];
- /* delete line */
- lastIns--;
- PC--;
- retCnt = 0; /* empty stack when prog changed */
- }
- break;
- case ISST: if (PC++ == lastIns) PC = 0; break;
- case IBST: if (PC-- == 0) PC = lastIns; break;
- case IUSER: USER(); break;
- case ICLR_PRGM: lastIns = PC = 0; break;
- }
- break;
- }
- RelKey();
- }
- if (!error && !waiting) {
- if (inprog) DisplayLine();
- else Disp();
- }
- }
- }
- }
- }
- }
-
- /*--- Display the program info box - called from the menu processor. ---*/
- static void hp11_info_about_program(void)
- {
- dbox d; /* Dialogue box handle */
-
- if (d = dbox_new("ProgInfo"), d != NULL) /* Create the dialogue box */
- {
- dbox_setfield(d, hp11_info_field, hp11_Version_String);
- /* Fill in the version number */
- dbox_show(d); /* Show the dialogue box */
- dbox_fillin(d); /* Keep it on the screen as long as needed */
- dbox_dispose(&d); /* Dispose of the dialogue box */
- }
- }
-
- /*--- Event handler for the menu. ---*/
- void hp11_menuproc(void *handle, char *hit)
- {
- handle = handle; /* We don't need handle: this stops compiler warning */
-
- /* Find which menu item was hit and take action as appropriate */
- switch (hit[0])
- {
- case hp11_menu_info:
- hp11_info_about_program();
- break;
-
- case hp11_menu_quit:
- /* Exit from the program. The wimp gets rid of the window and icon */
- exit(0);
- }
- }
-
- static void hp11_get_radix(void)
- {
- dbox d; /* Dialogue box handle */
- dbox_field button;
-
- if (d = dbox_new("Radix"), d != NULL) /* Create the dialogue box */
- {
- if (comma) { /* set up the selected values */
- dbox_setnumeric(d, radix_point, 0);
- dbox_setnumeric(d, radix_comma, 1);
- }
- else {
- dbox_setnumeric(d, radix_point, 1);
- dbox_setnumeric(d, radix_comma, 0);
- }
- dbox_show(d);
- do {
- button = dbox_fillin(d);
- comma = dbox_getnumeric(d, radix_comma);
- Disp();
- } while (dbox_persist());
- dbox_dispose(&d); /* Dispose of the dialogue box */
- }
- }
-
- static void hp11_get_speed(void)
- {
- dbox d; /* Dialogue box handle */
- dbox_field button;
-
- if (d = dbox_new("Speed"), d != NULL) /* Create the dialogue box */
- {
- if (fast) { /* set up the selected values */
- dbox_setnumeric(d, speed_slow, 0);
- dbox_setnumeric(d, speed_fast, 1);
- }
- else {
- dbox_setnumeric(d, speed_slow, 1);
- dbox_setnumeric(d, speed_fast, 0);
- }
- dbox_show(d);
- do {
- button = dbox_fillin(d);
- fast = dbox_getnumeric(d, speed_fast);
- } while (dbox_persist());
- dbox_dispose(&d); /* Dispose of the dialogue box */
- }
- }
-
- /*--- Event handler for the pop-up menu. ---*/
- void hp11_popup_proc(void *handle, char *hit)
- {
- hp11_data *d = (hp11_data *)handle;
-
- /* Find which menu item was hit and take action as appropriate */
- switch (hit[0])
- {
- case HP11_POPUP_STACK:
- if (hp11_show_stack)
- {
- menu_setflags(hp11_pop_up, HP11_POPUP_STACK, 0, 0);
- hp11_show_stack = FALSE;
- dbox_hide(hp11_stack_dbox_handle);
- }
- else
- {
- menu_setflags(hp11_pop_up, HP11_POPUP_STACK, 1, 0);
- hp11_show_stack = TRUE;
- Disp(); /* fill in contents */
- dbox_showstatic(hp11_stack_dbox_handle);
- }
- break;
-
- case HP11_POPUP_SAVE: /* Initiate save operation */
- switch (hit[1]) {
- case HP11_POPUP_STATUS: /* Complete status, including propgram */
- hp11_save_window = hp11_win_handle; /* this is to check if the */
- /* save is to the same window */
- saveas(HP11_STATUSTYPE, d->stat, 2000, hp11_stat_saver,
- hp11_stat_sender, 0, handle);
- hp11_save_window = -1;
- break;
- case HP11_POPUP_PROGRAM: /* Program listing */
- saveas(HP11_PROGTYPE, d->prog, 2000, hp11_prog_saver,
- hp11_prog_sender, 0, handle);
- break;
- case HP11_POPUP_DISPLAY: /* X-register */
- saveas(HP11_DISPLAYTYPE, d->disp, 2000, hp11_disp_saver,
- hp11_disp_sender, 0, handle);
- break;
- }
- break;
-
- case HP11_POPUP_RESET:
- HP11ColdReset();
- break;
-
- case HP11_POPUP_SPEED:
- if(hit[1] != 0) { /* don't respond to menu entry clicks */
- hp11_get_speed();
- }
- break;
-
- case HP11_POPUP_RADIX:
- if(hit[1] != 0) { /* don't respond to menu entry clicks */
- hp11_get_radix();
- }
- break;
- }
- }
-
-
- /*--- Event handler called on a left click on the icon. ---*/
- void hp11_iconclick(wimp_i icon)
- {
- icon = icon; /* We don't need the handle: this stops compiler warning */
-
- /* Open the window - only one allowed */
- if (!hp11_window_open)
- {
- dbox_showstatic(hp11_dbox_handle);
- dbox_raw_eventhandler(hp11_dbox_handle, hp11_dbox_raw_handler, &hp11_dat);
- dbox_eventhandler(hp11_dbox_handle, hp11_dbox_handler, &hp11_dat);
- hp11_window_open = TRUE;
- wimpt_complain(wimp_get_icon_info(hp11_win_handle,HP11_DISPLAY,&hp11_disp)); Disp();
- if (hp11_show_stack)
- {
- dbox_showstatic(hp11_stack_dbox_handle);
- }
- }
- }
-
- /*---------------------------------------------------------------------------*/
- /*================ ORIGINAL FUNCTIONS ==============*/
- /*---------------------------------------------------------------------------*/
-
- void ExecAction(int act) /* Execute an Action in normal mode */
- {
- if (act >= IGTO_LINE) { /* GTO .nnn where act = IGTO_LINE + nnn */
- entering = FALSE; /* Digit entry disabled */
- GTOLine(act - IGTO_LINE);
- }
- else switch (act) {
- case ISST: SST(); break;
- case IBST: BST(); break;
- case IP_R: ProgramEntry(); break;
- case IUSER: USER(); break;
- case ICLR_PRGM: RTN(); break; /* Clear Prgm = RTN() in normal mode */
- case ION: on = !RelKey(); break; /* Allow user to change his mind */
- case IMEM: MEM(); break;
- case ICLR_PREFIX: PREFIX(); break;
- case IBACK:if (entering) EnterNum(-IBACK); /* Correct during digit entry
- */
- else CLX();
- break;
- }
- }
-
- void ExecIns(ins) /* Execute an instruction (normal or run mode) */
- register int ins;
- {
- skip = FALSE;
-
- if (ins < KCOMPLEX) (*insfunc[ins])(); /* miscellaneous ins */
- else if (ins < KFLAGS + OCF) SF(ins - (KFLAGS + OSF));
- else if (ins < KFLAGS + OSET) CF(ins - (KFLAGS + OCF));
- else if (ins < KFIG) Set(ins - (KFLAGS + OSET));
- else if (ins < KFIX) EnterNum(ins);
- else if (ins < KSCI) FIX(ins - KFIX);
- else if (ins < KENG) SCI(ins - KSCI);
- else if (ins < KLBL) ENG(ins - KENG);
- else if (ins < KGTO) ENABLE() /* LBL : ignore, just enable stack */;
- else if (ins < KGSB) GTO(ins - KGTO);
- else if (ins < KSTO) GSB(ins - KGSB);
- else if (ins < KRCL) STO((ins - KSTO) % OPLUS,
- (enum StoTypes)((ins - KSTO) / OPLUS));
- /* compute type of operation to do : there are 21 regs per operation,
- + indirect, the codes are sequential : all the stos, all the pluses ...
- PLUS is first so it is 22, hence the division to determine the operation */
- else if (ins < KRCL + 22) RCL(ins - KRCL);
-
- X = Check(X); Y = Check(Y); /* Check the values in X & Y to conform to HP11
- limits. The testing is done here to save code space so that all the
- instructions
- don't have to include the check */
- }
-
- BOOL Init(void) /* Initialize the calculator, return FALSE if it fails */
- {
- DEG(); /* Initial state, all other values are zero */
- FIX(4);
- keyflag = NewSeq;
- inprog = FALSE;
- waiting = FALSE;
- ProgStepWait = FALSE;
- PC = 0;
- Rdoffset = 0;
-
- /* Computer specific intialisation, can load an initial program */
- return(ArcInit());
- }
-
- static void CleanUp(void)
- {
- ArcCleanUp();
- }
-
-
- /* 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_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_wind);
- hp11_redraw.w = hp11_win_handle;
- 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;
- wimpt_noerr(wimp_force_redraw(&hp11_redraw));
-
- /* now set a flag to indicate to event handler what should be redrawn */
- /* ie main display, stack etc */
-
- }
-
- void Display_2(wimp_redrawstr hp11_redraw)
- {
- void DrawChar(struct Border *, int, int);
- int posx, posy;
- int chr;
- char *save;
- wimp_box disp;
-
- save = hp11_s;
-
- disp.x0 = hp11_disp.box.x0;
- disp.y0 = hp11_disp.box.y0;
- disp.x1 = hp11_disp.box.x1;
- disp.y1 = hp11_disp.box.y1;
- coords_box_toscreen(&disp, (coords_cvtstr *)&hp11_redraw.box);
- posx = disp.x0 + CHAROFFX;
- posy = disp.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++;
- }
- hp11_s = save; /* restore pointer value for next function call */
- }
-
- 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 Wait50(long tick)
- {
- enum AlarmType *handle;
-
- waiting = TRUE;
- handle = &Wait;
-
- alarm_set(alarm_timenow() + 2*(int)tick, hp11_alarm_proc, (void *)handle);
- }
-
- void hp11_alarm_proc(int called_at, void *handle)
- /* gets control when the alarm timer goes off. Has to decide why it
- was called, and what to do about it */
- {
- enum AlarmType *action = (enum AlarmType *)handle;
-
- switch(*action) {
- case Waiting:
- waiting = FALSE;
- if (inprog) DisplayLine();
- else Disp();
- break;
- case Paused:
- waiting = FALSE;
- paused = FALSE;
- running = oldrun;
- if (running) {
- if (fast) FastRun();
- else SlowRun();
- }
- break;
- case ProgramStep:
- SlowRun();
- break;
- }
- }
-
- void SlowRun(void)
- {
- Disp();
- ExecIns(Prog[PC]); /* Exec current ins */
- if (error || overflow) {
- running = FALSE; /* An error occured, halt */
- oldrun = FALSE;
- }
- else {
- if (skip) PC++; /* A conditional instruction asked for the next
- instruction to be skipped */
- PC++;
- while (PC > lastIns) /* There is an implicit return at the */
- { /* end of the program */
- RTN();
- PC++;
- }
- }
- if (running) {
- hp11_alarm = &ProgStep;
- ProgStepTime = alarm_timenow() + 5;
- alarm_set(ProgStepTime, hp11_alarm_proc, (void *)hp11_alarm);
- }
- else if (!error && !paused) Disp();
- }
-
- void FastRun(void)
- {
- while (running)
- {
- ExecIns(Prog[PC]); /* Exec current ins */
- if (error || overflow) { /* An error occured, halt */
- running = FALSE;
- oldrun = FALSE;
- }
- else
- {
- if (skip) PC++; /* A conditional instruction asked for the next
- instruction to be skipped */
- PC++;
- while (PC > lastIns) /* There is an implicit return at the */
- { /* end of the program */
- RTN();
- PC++;
- }
- }
- }
- Disp();
- }
-