st80

Smalltalk-80 (image Xerox de 1983) dans le navigateur, VM du livre bleu en WebAssembly
git clone https://git.schurger.org/st80.git
Log | Files | Refs | README

hal.h (3021B)


      1 //
      2 //  hal.h
      3 //  Smalltalk-80
      4 //
      5 //  Created by Dan Banay on 4/13/20.
      6 //  Copyright © 2020 Dan Banay. All rights reserved.
      7 //
      8 //  MIT License
      9 //  Permission is hereby granted, free of charge, to any person obtaining a copy
     10 //  of this software and associated documentation files (the "Software"), to deal
     11 //  in the Software without restriction, including without limitation the rights
     12 //  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     13 //  copies of the Software, and to permit persons to whom the Software is
     14 //  furnished to do so, subject to the following conditions:
     15 //
     16 //  The above copyright notice and this permission notice shall be included in all
     17 //  copies or substantial portions of the Software.
     18 //
     19 //  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     20 //  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     21 //  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     22 //  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     23 //  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     24 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     25 //  SOFTWARE.
     26 //
     27 
     28 
     29 #pragma once
     30 #include <cstdint>
     31 
     32 class IHardwareAbstractionLayer
     33 {
     34 public:
     35     // Specify the semaphore to signal on input
     36     virtual void set_input_semaphore(int semaphore) = 0;
     37     
     38     // The number of seconds since 00:00 in the morning of January 1, 1901
     39     virtual std::uint32_t get_smalltalk_epoch_time() = 0;
     40     
     41     // the number of milliseconds since the millisecond clock was
     42     // last reset or rolled over (a 32-bit unsigned number)
     43     virtual std::uint32_t get_msclock() = 0;
     44     
     45     // Schedule a semaphore to be signaled at a time. Only one outstanding
     46     // request may be scheduled at anytime. When called any outstanding
     47     // request will be replaced (or canceled if semaphore is 0).
     48     // Will signal immediate if scheduled time has passed.
     49     virtual void signal_at(int semaphore, std::uint32_t msClockTime) = 0;
     50     
     51     // Set the cursor image
     52     // (a 16 word form)
     53     virtual void set_cursor_image(std::uint16_t *image) = 0;
     54  
     55     // Set the mouse cursor location
     56     virtual void set_cursor_location(int x, int y) = 0;
     57     virtual void get_cursor_location(int *x, int *y) = 0;
     58     virtual void set_link_cursor(bool link) = 0;
     59     
     60     // Set the display size
     61     virtual bool set_display_size(int width, int height) = 0;
     62     
     63     // Notify that screen contents changed
     64     virtual void display_changed(int x, int y, int width, int height) = 0;
     65     
     66     // Input queue
     67     virtual bool next_input_word(std::uint16_t *word) = 0;
     68     
     69     // Report catastrophic failure
     70     virtual void error(const char *message) = 0;
     71     
     72     // Lifetime
     73     virtual void signal_quit() = 0;
     74     virtual void exit_to_debugger() = 0;
     75     
     76     // Snapshot name
     77     virtual const char *get_image_name() = 0;
     78     virtual void set_image_name(const char *new_name) = 0;
     79 };