fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
at master 166 lines 3.3 kB view raw
1/***************************************************************************** 2 * pce * 3 *****************************************************************************/ 4 5/***************************************************************************** 6 * File name: src/arch/dos/int.c * 7 * Created: 2013-01-03 by Hampa Hug <hampa@hampa.ch> * 8 * Copyright: (C) 2013-2015 Hampa Hug <hampa@hampa.ch> * 9 *****************************************************************************/ 10 11/***************************************************************************** 12 * This program is free software. You can redistribute it and / or modify it * 13 * under the terms of the GNU General Public License version 2 as published * 14 * by the Free Software Foundation. * 15 * * 16 * This program is distributed in the hope that it will be useful, but * 17 * WITHOUT ANY WARRANTY, without even the implied warranty of * 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * 19 * Public License for more details. * 20 *****************************************************************************/ 21 22 23#include "main.h" 24#include "dos.h" 25#include "int.h" 26#include "int10.h" 27#include "int21.h" 28 29#include <cpu/e8086/e8086.h> 30 31#include <stdio.h> 32#include <stdlib.h> 33#include <string.h> 34 35 36/* 37 * Int 11 38 */ 39static 40int sim_int11 (dos_t *sim) 41{ 42 e86_set_ax (&sim->cpu, 0x0061); 43 44 return (0); 45} 46 47/* 48 * Int 12 49 */ 50static 51int sim_int12 (dos_t *sim) 52{ 53 e86_set_ax (&sim->cpu, sim_get_uint16 (sim, 0x40, 0x13)); 54 55 return (0); 56} 57 58 59/* 60 * Int 16 61 */ 62static 63int sim_int16 (dos_t *sim) 64{ 65 switch (e86_get_ah (&sim->cpu)) { 66 case 0x01: 67 case 0x11: 68 e86_set_zf (&sim->cpu, 1); 69 e86_set_ax (&sim->cpu, 0); 70 break; 71 72 case 0x02: 73 case 0x12: 74 e86_set_al (&sim->cpu, 0); 75 break; 76 77 case 5: 78 break; 79 80 default: 81 return (1); 82 } 83 84 return (0); 85} 86 87 88/* 89 * 1A / 00: Get time 90 */ 91static 92int int1a_fct_00 (dos_t *sim) 93{ 94 e86_set_cx (&sim->cpu, 0); 95 e86_set_dx (&sim->cpu, 0); 96 97 return (0); 98} 99 100/* 101 * Int 1A 102 */ 103static 104int sim_int1a (dos_t *sim) 105{ 106 switch (e86_get_ah (&sim->cpu)) { 107 case 0x00: 108 return (int1a_fct_00 (sim)); 109 } 110 111 return (1); 112} 113 114 115void sim_int (dos_t *sim, unsigned char val) 116{ 117 int ret; 118 119 if (sim->log_int) { 120 fprintf (stderr, "%02X: ", val); 121 sim_print_state_cpu (sim, stderr); 122 } 123 124 ret = 0; 125 126 if ((val < 0x10) || (val > 0x28)) { 127 ret = 0; 128 } 129 else if (val == 0x10) { 130 ret = sim_int10 (sim); 131 } 132 else if (val == 0x11) { 133 ret = sim_int11 (sim); 134 } 135 else if (val == 0x12) { 136 ret = sim_int12 (sim); 137 } 138 else if (val == 0x16) { 139 ret = sim_int16 (sim); 140 } 141 else if (val == 0x1a) { 142 ret = sim_int1a (sim); 143 } 144 else if (val == 0x21) { 145 ret = sim_int21 (sim); 146 } 147 else if (val == 0x28) { 148 ; 149 } 150 else { 151 ret = 1; 152 } 153 154 if (sim->log_int) { 155 fprintf (stderr, "%02X: ", val); 156 sim_print_state_cpu (sim, stderr); 157 fputc ('\n', stderr); 158 fflush (stderr); 159 } 160 161 if (ret) { 162 sim_print_state_cpu (sim, stderr); 163 fprintf (stderr, "unknown int: %02X / %04X\n", val, e86_get_ax (&sim->cpu)); 164 exit (1); 165 } 166}